2 # Licensed under the Apache License, Version 2.0 (the "License"); you may
3 # not use this file except in compliance with the License. You may obtain
4 # a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11 # License for the specific language governing permissions and limitations
14 from toscaparser.functions import GetInput
15 from translator.hot.syntax.hot_resource import HotResource
17 # Name used to dynamically load appropriate map class.
18 TARGET_CLASS_NAME = 'ToscaBlockStorageAttachment'
21 class ToscaBlockStorageAttachment(HotResource):
22 '''Translate TOSCA relationship AttachesTo for Compute and BlockStorage.'''
24 toscatype = 'tosca.nodes.BlockStorageAttachment'
26 def __init__(self, template, nodetemplates, instance_uuid, volume_id,
28 super(ToscaBlockStorageAttachment,
29 self).__init__(template, type='OS::Cinder::VolumeAttachment',
31 self.nodetemplates = nodetemplates
32 self.instance_uuid = {'get_resource': instance_uuid}
33 self.volume_id = {'get_resource': volume_id}
35 def handle_properties(self):
37 for prop in self.nodetemplate.get_properties_objects():
38 if isinstance(prop.value, GetInput):
39 tosca_props[prop.name] = {'get_param': prop.value.input_name}
41 tosca_props[prop.name] = prop.value
42 self.properties = tosca_props
43 # instance_uuid and volume_id for Cinder volume attachment
44 self.properties['instance_uuid'] = self.instance_uuid
45 self.properties['volume_id'] = self.volume_id
46 if 'location' in self.properties:
47 self.properties['mountpoint'] = self.properties.pop('location')
49 # TOSCA type can have a device name specified,
50 # this is unsupported by Heat
51 if 'device' in self.properties:
52 self.properties.pop('device')
54 def handle_life_cycle(self):
55 return None, None, None