Handle TOSCA relationship with 'type' keyword

TOSCA relationship can be explicitely provided with in-line reference or with
'type' keyword in the template. The current code only handles in-line reference.

Change-Id: Id5b38fef1b099f8170e2941b348637372665c8f9
This commit is contained in:
spzala 2015-01-26 19:45:34 -08:00
parent 0012e96819
commit 509360110b
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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