From 6b35077372a583b45c7bdb36972db0f801b226f7 Mon Sep 17 00:00:00 2001 From: Naoaki Horie Date: Fri, 1 Jul 2022 05:07:08 +0000 Subject: [PATCH] Fix Desired Capacity for heat is not updated For v1 API, heal doesn't delete original VM after running scale-out unexpectedly because `desired_capacity` for stack update for heat is not updated while heal operation. This update is for the fix. Closes-Bug: #1980329 Change-Id: I61ee8b6e08a6af54f04cf09c8a0123332946ccb5 --- .../openstack/test_openstack_driver.py | 11 +++++++++++ tacker/vnfm/infra_drivers/openstack/openstack.py | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py index c8759dcfc..49e1206ac 100644 --- a/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py +++ b/tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py @@ -2178,6 +2178,12 @@ class TestOpenStack(base.FixturedTestCase): inst_vnf_info = fd_utils.get_vnf_instantiated_info( virtual_storage_resource_info=[v_s_resource_info], vnfc_resource_info=[vnfc_resource_info]) + + mock_get_vnf_package_path.return_value = os.path.abspath( + os.path.join(os.path.dirname(__file__), + "../../../../etc/samples/etsi/nfv", + "stack_update_in_heal")) + vnf_instance = fd_utils.get_vnf_instance_object( instantiated_vnf_info=inst_vnf_info) @@ -2319,6 +2325,11 @@ class TestOpenStack(base.FixturedTestCase): virtual_storage_resource_info=[v_s_resource_info], vnfc_resource_info=[vnfc_resource_info]) + mock_get_vnf_package_path.return_value = os.path.abspath( + os.path.join(os.path.dirname(__file__), + "../../../../etc/samples/etsi/nfv", + "stack_update_in_heal")) + vnf_instance = fd_utils.get_vnf_instance_object( instantiated_vnf_info=inst_vnf_info) diff --git a/tacker/vnfm/infra_drivers/openstack/openstack.py b/tacker/vnfm/infra_drivers/openstack/openstack.py index 4d3925976..7f77c277b 100644 --- a/tacker/vnfm/infra_drivers/openstack/openstack.py +++ b/tacker/vnfm/infra_drivers/openstack/openstack.py @@ -53,6 +53,7 @@ from tacker.vnfm.infra_drivers.openstack import update_template as ut from tacker.vnfm.infra_drivers.openstack import vdu from tacker.vnfm.infra_drivers import scale_driver from tacker.vnfm.lcm_user_data.constants import USER_DATA_TIMEOUT +from tacker.vnfm.lcm_user_data import utils as user_data_utils eventlet.monkey_patch(time=True) @@ -1544,7 +1545,22 @@ class OpenStack(abstract_driver.VnfAbstractDriver, stack_update_param = { 'existing': True} + vnfd_dict = vnflcm_utils.get_vnfd_dict( + context, vnf_instance.vnfd_id, + vnf_instance.instantiated_vnf_info.flavour_id) + if base_hot_dict: + tmp_base_hot_dict = {'heat_template': base_hot_dict} + desired_capacity_dict = user_data_utils.get_desired_capacity_dict( + tmp_base_hot_dict, vnfd_dict, inst_vnf_info) + + for key, value in base_hot_dict.get('resources').items(): + for an, dc in desired_capacity_dict.items(): + if key == an and value.get('properties').get( + 'desired_capacity'): + value['properties']['desired_capacity'] = dc + base_hot_dict['resources'][key] = value + stack_update_param['template'] = \ self._format_base_hot(base_hot_dict)