Solves the "TypeError: 'NoneType' object is not iterable" when getting nodetemplate relationships.
Closes-Bug: #1527214 Change-Id: Ibf5ecb0cc5a600387ef98603087abab084741211
This commit is contained in:
parent
4c65bf3f75
commit
4d4ef5fa72
@ -102,6 +102,7 @@ class NodeTemplate(EntityTemplate):
|
|||||||
if relationship:
|
if relationship:
|
||||||
found_relationship_tpl = False
|
found_relationship_tpl = False
|
||||||
# apply available relationship templates if found
|
# apply available relationship templates if found
|
||||||
|
if self.available_rel_tpls:
|
||||||
for tpl in self.available_rel_tpls:
|
for tpl in self.available_rel_tpls:
|
||||||
if tpl.name == relationship:
|
if tpl.name == relationship:
|
||||||
rtype = RelationshipType(tpl.type, None,
|
rtype = RelationshipType(tpl.type, None,
|
||||||
|
23
toscaparser/tests/data/test_available_rel_tpls.yaml
Normal file
23
toscaparser/tests/data/test_available_rel_tpls.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
tosca_definitions_version: tosca_simple_yaml_1_0
|
||||||
|
|
||||||
|
description: TOSCA test for bug 1527214
|
||||||
|
|
||||||
|
topology_template:
|
||||||
|
|
||||||
|
node_templates:
|
||||||
|
|
||||||
|
test_db:
|
||||||
|
type: tosca.nodes.Database
|
||||||
|
requirements:
|
||||||
|
- host:
|
||||||
|
node: mysql
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
type: tosca.nodes.DBMS
|
||||||
|
requirements:
|
||||||
|
- host:
|
||||||
|
node: db_server
|
||||||
|
|
||||||
|
db_server:
|
||||||
|
type: tosca.nodes.Compute
|
||||||
|
|
@ -544,3 +544,15 @@ class ToscaTemplateTest(TestCase):
|
|||||||
"data/CSAR/csar_elk.csar")
|
"data/CSAR/csar_elk.csar")
|
||||||
tosca = ToscaTemplate(tosca_tpl)
|
tosca = ToscaTemplate(tosca_tpl)
|
||||||
self.assertTrue(tosca.topology_template.custom_defs)
|
self.assertTrue(tosca.topology_template.custom_defs)
|
||||||
|
|
||||||
|
def test_available_rel_tpls(self):
|
||||||
|
tosca_tpl = os.path.join(
|
||||||
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
"data/test_available_rel_tpls.yaml")
|
||||||
|
tosca = ToscaTemplate(tosca_tpl)
|
||||||
|
for node in tosca.nodetemplates:
|
||||||
|
for relationship, target in node.relationships.items():
|
||||||
|
try:
|
||||||
|
target.relationships
|
||||||
|
except TypeError as error:
|
||||||
|
self.fail(error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user