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
This commit is contained in:
Naoaki Horie 2022-07-01 05:07:08 +00:00
parent 3ce72ac65f
commit 6b35077372
2 changed files with 27 additions and 0 deletions

View File

@ -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)

View File

@ -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)