Enable store multi flavour in nested topo template

If user tries to load CSAR file with multiple flavours (eg: simple,
complex) of VNFD, it only stores one object in
nested_tosca_templates_with_topology.

This patch fixes the issue for load VNFD that has multiple deployment
flavours.

Change-Id: I490b2189fd594f1acceb931215f8a665c758441c
Closes-Bug: 1883220
This commit is contained in:
Ayumu Ueha 2020-06-12 08:51:12 +00:00 committed by ueha.ayumu
parent 9b42fa3d32
commit 7f675dec21
3 changed files with 20 additions and 1 deletions

View File

@ -982,3 +982,16 @@ class ToscaTemplateTest(TestCase):
os.path.dirname(os.path.abspath(__file__)),
'data/CSAR/csar_relative_path_import_check.zip')
self.assertTrue(ToscaTemplate(csar_archive))
def test_csar_multiple_deployment_flavours(self):
csar_archive = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'data/CSAR/csar_multiple_deployment_flavour.zip')
tosca = ToscaTemplate(csar_archive)
flavours = list()
for tp in tosca.nested_tosca_templates_with_topology:
flavour_id = tp.substitution_mappings.properties.get('flavour_id')
flavour = {'flavour_id': flavour_id}
flavours.append(flavour)
self.assertEqual(flavours[0]['flavour_id'], 'simple')
self.assertEqual(flavours[1]['flavour_id'], 'complex')

View File

@ -321,7 +321,13 @@ class ToscaTemplate(object):
def _is_sub_mapped_node(self, nodetemplate, tosca_tpl):
"""Return True if the nodetemple is substituted."""
if (nodetemplate and not nodetemplate.sub_mapping_tosca_template and
# NOTE(ueha): Since condition "not nodetemplate.sub_mapping_tosca_\
# template" was deleted as a fix for bug/1883220, there is
# some possibility of breaking something on translator side
# that current tests not coverd.
# And this enhancement does not align with TOSCA standard
# but needed for ETSI NFV-SOL 001.
if (nodetemplate and
self.get_sub_mapping_node_type(tosca_tpl) == nodetemplate.type
and len(nodetemplate.interfaces) < 1):
return True