Solves an error in the _create_interfaces function in case of custom relationships defined in TOSCA document.

Change-Id: Id780d8a3ddea6f85bc555644b933c1782d7d98e2
Related-Bug: 1551608
This commit is contained in:
Miguel Caballer
2016-03-01 09:31:35 +01:00
parent e30a7df906
commit 820f9c8ec4
3 changed files with 45 additions and 10 deletions

View File

@@ -283,6 +283,9 @@ class EntityTemplate(object):
type_interfaces = None
if isinstance(self.type_definition, RelationshipType):
if isinstance(self.entity_tpl, dict):
if self.INTERFACES in self.entity_tpl:
type_interfaces = self.entity_tpl[self.INTERFACES]
else:
for rel_def, value in self.entity_tpl.items():
if rel_def != 'type':
rel_def = self.entity_tpl.get(rel_def)

View File

@@ -0,0 +1,23 @@
tosca_definitions_version: tosca_simple_yaml_1_0
description: Test template of a custom relationship with a configure script
topology_template:
node_templates:
apache:
type: tosca.nodes.WebServer
requirements:
- host:
node: web_server
relationship: my_custom_rel
web_server:
type: tosca.nodes.Compute
relationship_templates:
my_custom_rel:
type: HostedOn
interfaces:
Configure:
pre_configure_source: scripts/wp_db_configure.sh

View File

@@ -716,3 +716,12 @@ class ToscaTemplateTest(TestCase):
os.path.dirname(os.path.abspath(__file__)),
"data/test_custom_caps_def.yaml")
ToscaTemplate(tosca_tpl)
def test_custom_rel_with_script(self):
tosca_tpl = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"data/test_tosca_custom_rel_with_script.yaml")
tosca = ToscaTemplate(tosca_tpl)
rel = tosca.relationship_templates[0]
self.assertEqual(len(rel.interfaces), 1)
self.assertEqual(rel.interfaces[0].type, "Configure")