Browse Source

Merge "Fix: flavour_description is not updated when instantiating"

changes/48/743748/2
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
896d03804d
2 changed files with 30 additions and 6 deletions
  1. +10
    -0
      tacker/tests/unit/vnflcm/test_utils.py
  2. +20
    -6
      tacker/vnflcm/utils.py

+ 10
- 0
tacker/tests/unit/vnflcm/test_utils.py View File

@@ -47,3 +47,13 @@ class VnfLcmUtilsTestCase(base.TestCase):
extracted_path)
self.assertEqual(expected_image_path,
vnf_software_images['VDU1'].image_path)

def test_get_param_data_with_flavour_description(self):
vnfd_dict = fakes.get_vnfd_dict()
vnfd_dict.update({'imports': []})
instantiate_vnf_req = fakes.get_instantiate_vnf_request_obj()
param_value = vnflcm_utils._get_param_data(vnfd_dict,
instantiate_vnf_req)
expected_flavour_description = 'A simple flavor'
self.assertEqual(expected_flavour_description,
param_value['flavour_description'])

+ 20
- 6
tacker/vnflcm/utils.py View File

@@ -214,6 +214,16 @@ def _get_param_data(vnfd_dict, instantiate_vnf_req):
input_attributes = vnfd_dict.get('topology_template', {}).get('inputs')
if substitution_map is not None:
subs_map_node_type = substitution_map.get('node_type')
# Get properties in lower-level VNFD for top-level VNFD
node_templates = vnfd_dict.get('topology_template',
{}).get('node_templates', {})
for node in node_templates.values():
if node.get('type') == subs_map_node_type:
node_property = node.get('properties', {})
if node_property:
param_value.update(node_property)
# Import `_type.yaml` file and get default properties.
# If new value provided in additional_param, the property is updated.
import_paths = vnfd_dict.get('imports', {})
for imp_path in import_paths:
with open(imp_path) as file_obj:
@@ -223,12 +233,16 @@ def _get_param_data(vnfd_dict, instantiate_vnf_req):
for key, value in imp_node_type.items():
if key == subs_map_node_type:
properties = value.get('properties')
for key, prop in properties.items():
if additional_param.get(key):
param_value.update({
key: additional_param.get(key)})
else:
param_value.update({key: prop.get('default')})
if properties:
for key, prop in properties.items():
if additional_param.get(key):
param_value.update({
key: additional_param.get(key)})
# If the parameter is provided in lower-level
# VNFD, use it. Otherwise use the default.
elif not param_value.get(key):
param_value.update(
{key: prop.get('default')})

for input_attr, value in input_attributes.items():
if additional_param.get(input_attr):


Loading…
Cancel
Save