diff --git a/IM/tosca/Tosca.py b/IM/tosca/Tosca.py index 2c2565959..28fe73195 100644 --- a/IM/tosca/Tosca.py +++ b/IM/tosca/Tosca.py @@ -557,12 +557,13 @@ def _get_relationships_interfaces(relationships, node): rel_tpl = Tosca._get_relationship_template(rel, src, trgt) rel_tlp_def_interfaces = {} - if rel_tpl.type_definition.interfaces and 'Standard' in rel_tpl.type_definition.interfaces: - rel_tlp_def_interfaces = rel_tpl.type_definition.interfaces['Standard'] + for inteface_name in ['Standard', 'Configure']: + if rel_tpl.type_definition.interfaces and inteface_name in rel_tpl.type_definition.interfaces: + rel_tlp_def_interfaces = rel_tpl.type_definition.interfaces[inteface_name] if src.name == node.name: # Also add the configure of the target node of the relation - trgt_interfaces = Tosca._get_interfaces(trgt, ['pre_configure_source', 'post_configure_source']) + trgt_interfaces = Tosca._get_interfaces(trgt, steps=['pre_configure_source', 'post_configure_source']) for name in ['pre_configure_source', 'post_configure_source', 'add_source']: if trgt_interfaces and name in trgt_interfaces: res[name] = trgt_interfaces[name] @@ -576,7 +577,7 @@ def _get_relationships_interfaces(relationships, node): node_template=rel_tpl) elif trgt.name == node.name: - src_interfaces = Tosca._get_interfaces(src, ['pre_configure_target', 'post_configure_target']) + src_interfaces = Tosca._get_interfaces(src, steps=['pre_configure_target', 'post_configure_target']) for name in ['pre_configure_target', 'post_configure_target', 'add_target', 'target_changed', 'remove_target']: if src_interfaces and name in src_interfaces: @@ -1619,7 +1620,8 @@ def _get_root_parent_type(node): return node_type @staticmethod - def _get_interfaces(node, steps=['create', 'configure', 'start', 'stop', 'delete']): + def _get_interfaces(node, interface_names=['Standard', 'Configure'], + steps=['create', 'configure', 'start', 'stop', 'delete']): """ Get a dict of InterfacesDef of the specified node """ @@ -1630,12 +1632,13 @@ def _get_interfaces(node, steps=['create', 'configure', 'start', 'stop', 'delete node_type = node.type_definition while True: - if node_type.interfaces and 'Standard' in node_type.interfaces: - for name, elems in node_type.interfaces['Standard'].items(): - if name in steps: - if name not in interfaces: - interfaces[name] = InterfacesDef(node_type, 'Standard', name=name, - value=elems, node_template=node) + for interface_name in interface_names: + if node_type.interfaces and interface_name in node_type.interfaces: + for name, elems in node_type.interfaces[interface_name].items(): + if name in steps: + if name not in interfaces: + interfaces[name] = InterfacesDef(node_type, interface_name, name=name, + value=elems, node_template=node) if node_type.parent_type is not None: node_type = node_type.parent_type diff --git a/test/files/tosca_long.yml b/test/files/tosca_long.yml index 1193ba375..77f9af03f 100644 --- a/test/files/tosca_long.yml +++ b/test/files/tosca_long.yml @@ -101,18 +101,9 @@ topology_template: - local_storage: node: my_onedata_storage relationship: - type: AttachesTo + type: tosca.relationships.indigo.OneDataStorage.AttachesTo properties: location: /mnt/disk - interfaces: - Configure: - pre_configure_source: - implementation: - file: https://raw.githubusercontent.com/indigo-dc/tosca-types/master/artifacts/onedata/oneclient_install.yml - type: tosca.artifacts.Implementation.YAML - inputs: - onedata_token: { get_property: [ TARGET, credential, token ] } - onedata_location: { get_property: [ SELF, location ] } my_onedata_storage: type: tosca.nodes.indigo.OneDataStorage diff --git a/test/unit/Tosca.py b/test/unit/Tosca.py index 028c30d2a..32e5b9a28 100755 --- a/test/unit/Tosca.py +++ b/test/unit/Tosca.py @@ -49,7 +49,6 @@ def test_tosca_to_radl(self): tosca_data = read_file_as_string('../files/tosca_long.yml') tosca = Tosca(tosca_data) _, radl = tosca.to_radl() - print(radl) radl = parse_radl(str(radl)) net = radl.get_network_by_id('public_net') net1 = radl.get_network_by_id('public_net_1') @@ -94,6 +93,8 @@ def test_tosca_to_radl(self): "{{ groups['lrms_wn']|map('extract', hostvars,'IM_NODE_PRIVATE_IP')|list" " if 'lrms_wn' in groups else []}}") self.assertEqual([d.id for d in radl.deploys][2], 'lrms_wn') + att_conf = radl.get_configure_by_name('lrms_server_tosca.relationships.indigo.onedatastorage.attachesto_conf') + conf = yaml.safe_load(att_conf.recipes)[0] def test_tosca_get_outputs(self): """Test TOSCA get_outputs function"""