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:
@@ -283,16 +283,19 @@ class EntityTemplate(object):
|
|||||||
type_interfaces = None
|
type_interfaces = None
|
||||||
if isinstance(self.type_definition, RelationshipType):
|
if isinstance(self.type_definition, RelationshipType):
|
||||||
if isinstance(self.entity_tpl, dict):
|
if isinstance(self.entity_tpl, dict):
|
||||||
for rel_def, value in self.entity_tpl.items():
|
if self.INTERFACES in self.entity_tpl:
|
||||||
if rel_def != 'type':
|
type_interfaces = self.entity_tpl[self.INTERFACES]
|
||||||
rel_def = self.entity_tpl.get(rel_def)
|
else:
|
||||||
rel = None
|
for rel_def, value in self.entity_tpl.items():
|
||||||
if isinstance(rel_def, dict):
|
if rel_def != 'type':
|
||||||
rel = rel_def.get('relationship')
|
rel_def = self.entity_tpl.get(rel_def)
|
||||||
if rel:
|
rel = None
|
||||||
if self.INTERFACES in rel:
|
if isinstance(rel_def, dict):
|
||||||
type_interfaces = rel[self.INTERFACES]
|
rel = rel_def.get('relationship')
|
||||||
break
|
if rel:
|
||||||
|
if self.INTERFACES in rel:
|
||||||
|
type_interfaces = rel[self.INTERFACES]
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
type_interfaces = self.type_definition.get_value(self.INTERFACES,
|
type_interfaces = self.type_definition.get_value(self.INTERFACES,
|
||||||
self.entity_tpl)
|
self.entity_tpl)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -716,3 +716,12 @@ class ToscaTemplateTest(TestCase):
|
|||||||
os.path.dirname(os.path.abspath(__file__)),
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
"data/test_custom_caps_def.yaml")
|
"data/test_custom_caps_def.yaml")
|
||||||
ToscaTemplate(tosca_tpl)
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user