Merge "Fix: flavour_description is not updated when instantiating"
This commit is contained in:
commit
896d03804d
|
@ -47,3 +47,13 @@ class VnfLcmUtilsTestCase(base.TestCase):
|
||||||
extracted_path)
|
extracted_path)
|
||||||
self.assertEqual(expected_image_path,
|
self.assertEqual(expected_image_path,
|
||||||
vnf_software_images['VDU1'].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'])
|
||||||
|
|
|
@ -214,6 +214,16 @@ def _get_param_data(vnfd_dict, instantiate_vnf_req):
|
||||||
input_attributes = vnfd_dict.get('topology_template', {}).get('inputs')
|
input_attributes = vnfd_dict.get('topology_template', {}).get('inputs')
|
||||||
if substitution_map is not None:
|
if substitution_map is not None:
|
||||||
subs_map_node_type = substitution_map.get('node_type')
|
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', {})
|
import_paths = vnfd_dict.get('imports', {})
|
||||||
for imp_path in import_paths:
|
for imp_path in import_paths:
|
||||||
with open(imp_path) as file_obj:
|
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():
|
for key, value in imp_node_type.items():
|
||||||
if key == subs_map_node_type:
|
if key == subs_map_node_type:
|
||||||
properties = value.get('properties')
|
properties = value.get('properties')
|
||||||
for key, prop in properties.items():
|
if properties:
|
||||||
if additional_param.get(key):
|
for key, prop in properties.items():
|
||||||
param_value.update({
|
if additional_param.get(key):
|
||||||
key: additional_param.get(key)})
|
param_value.update({
|
||||||
else:
|
key: additional_param.get(key)})
|
||||||
param_value.update({key: prop.get('default')})
|
# 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():
|
for input_attr, value in input_attributes.items():
|
||||||
if additional_param.get(input_attr):
|
if additional_param.get(input_attr):
|
||||||
|
|
Loading…
Reference in New Issue