diff --git a/translator/toscalib/nodetemplate.py b/translator/toscalib/nodetemplate.py index 6ee7d4bd..32ec87d0 100644 --- a/translator/toscalib/nodetemplate.py +++ b/translator/toscalib/nodetemplate.py @@ -95,6 +95,8 @@ class NodeTemplate(EntityTemplate): found_relationship_tpl = True #create relationship template object. if not found_relationship_tpl: + if isinstance(relationship, dict): + relationship = relationship.get('type') for rtype in self.type_definition.relationship.keys(): if rtype.type == relationship: explicit_relation[rtype] = related_tpl diff --git a/translator/toscalib/tests/data/test_requirements.yaml b/translator/toscalib/tests/data/test_requirements.yaml index 09c9ec3a..ba2eda16 100644 --- a/translator/toscalib/tests/data/test_requirements.yaml +++ b/translator/toscalib/tests/data/test_requirements.yaml @@ -10,7 +10,8 @@ node_templates: my_app: description: > Specify multiple requirement via node and relationship keyword, - as an explicit relationship. + as an explicit relationship. Also demonstrates relationship with + type keyword and without it as an in-line reference. type: tosca.nodes.WebApplication.WordPress requirements: - req1: @@ -18,7 +19,8 @@ node_templates: relationship: tosca.relationships.HostedOn - req2: node: mysql_database - relationship: tosca.relationships.ConnectsTo + relationship: + type: tosca.relationships.ConnectsTo mysql_database: description: Specify requirement via a capability as an implicit relationship. type: tosca.nodes.Database