From: Rahul Kumar Date: Wed, 8 Nov 2023 06:25:06 +0000 (+0000) Subject: Fix Bug 2304: Flavor Not getting Updated in Mongodb nsrs after Vertical scaling X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fv14.0;hp=ba3bae32479541d826dc7cdea872d7b9c22514bc;p=osm%2FRO.git Fix Bug 2304: Flavor Not getting Updated in Mongodb nsrs after Vertical scaling Change-Id: I37cdd030613cfe56ab3a75dc74a4a55f7858d7d7 Signed-off-by: Rahul Kumar --- diff --git a/NG-RO/osm_ng_ro/monitor.py b/NG-RO/osm_ng_ro/monitor.py index 529ce0e1..a7f41a13 100644 --- a/NG-RO/osm_ng_ro/monitor.py +++ b/NG-RO/osm_ng_ro/monitor.py @@ -624,10 +624,18 @@ class MonitorVms: vdur_path + ".interfaces." + str(index) + ".mac-address" ] = interface_info.get("mac_address") + @staticmethod + def _get_dual_ip(data=None): + if data: + ip_addresses = [item["ip_address"] for item in data] + return ";".join(ip_addresses) if len(ip_addresses) > 1 else ip_addresses[0] + else: + return None + @staticmethod def _get_current_ip_address(interface_info: dict) -> Optional[str]: if interface_info.get("fixed_ips") and interface_info["fixed_ips"][0]: - return interface_info["fixed_ips"][0].get("ip_address") + return MonitorVms._get_dual_ip(interface_info.get("fixed_ips")) @staticmethod def backup_vdu_interfaces(vdur_vim_info_update: dict) -> None: diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index a1d27364..85b8c08d 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -1611,9 +1611,9 @@ class Ns(object): extra_dict["params"] = { "name": "{}-{}-{}-{}".format( - indata["name"][:16], - vnfr["member-vnf-index-ref"][:16], - target_vdu["vdu-name"][:32], + indata["name"], + vnfr["member-vnf-index-ref"], + target_vdu["vdu-name"], target_vdu.get("count-index") or 0, ), "description": target_vdu["vdu-name"], @@ -1844,9 +1844,9 @@ class Ns(object): extra_dict["params"] = { "name": "{}-{}-{}-{}".format( - db_nsr["name"][:16], - vnfr["member-vnf-index-ref"][:16], - existing_vdu["vdu-name"][:32], + db_nsr["name"], + vnfr["member-vnf-index-ref"], + existing_vdu["vdu-name"], existing_vdu.get("count-index") or 0, ), "description": existing_vdu["vdu-name"], @@ -3121,6 +3121,10 @@ class Ns(object): ): target_vim, vim_info = next(k_v for k_v in vdu["vim_info"].items()) self._assign_vim(target_vim) + ns_preffix = "nsrs:{}".format(nsr_id) + flavor_text = ns_preffix + ":flavor." + vdu["ns-flavor-id"] + extra_dict["depends_on"] = [flavor_text] + extra_dict["params"].update({"flavor_id": "TASK-" + flavor_text}) target_record = "vnfrs:{}:vdur.{}.vim_info.{}".format( vnf["_id"], vdu_index, target_vim ) @@ -3142,9 +3146,36 @@ class Ns(object): ) return task + def verticalscale_flavor_task( + self, vdu, vnf, vdu_index, action_id, nsr_id, task_index, extra_dict + ): + target_vim, vim_info = next(k_v for k_v in vdu["vim_info"].items()) + self._assign_vim(target_vim) + db_nsr = self.db.get_one("nsrs", {"_id": nsr_id}) + target_record = "nsrs:{}:flavor.{}.vim_info.{}".format( + nsr_id, len(db_nsr["flavor"]) - 1, target_vim + ) + target_record_id = "nsrs:{}:flavor.{}".format(nsr_id, len(db_nsr["flavor"]) - 1) + deployment_info = { + "action_id": action_id, + "nsr_id": nsr_id, + "task_index": task_index, + } + task = Ns._create_task( + deployment_info=deployment_info, + target_id=target_vim, + item="flavor", + action="CREATE", + target_record=target_record, + target_record_id=target_record_id, + extra_dict=extra_dict, + ) + return task + def verticalscale(self, session, indata, version, nsr_id, *args, **kwargs): task_index = 0 extra_dict = {} + flavor_extra_dict = {} now = time() action_id = indata.get("action_id", str(uuid4())) step = "" @@ -3166,6 +3197,13 @@ class Ns(object): "vcpus": numVirtualCpu, "disk": sizeOfStorage, } + flavor_data = { + "ram": virtualMemory, + "vcpus": numVirtualCpu, + "disk": sizeOfStorage, + } + flavor_extra_dict["find_params"] = {"flavor_data": flavor_data} + flavor_extra_dict["params"] = {"flavor_data": flavor_dict} db_new_tasks = [] step = "Creating Tasks for vertical scaling" with self.write_lock: @@ -3177,7 +3215,21 @@ class Ns(object): extra_dict["params"] = { "vim_vm_id": vdu["vim-id"], "flavor_dict": flavor_dict, + "vdu-id-ref": vdu["vdu-id-ref"], + "count-index": vdu["count-index"], + "vnf_instance_id": vnf_instance_id, } + task = self.verticalscale_flavor_task( + vdu, + db_vnfr, + vdu_index, + action_id, + nsr_id, + task_index, + flavor_extra_dict, + ) + db_new_tasks.append(task) + task_index += 1 task = self.verticalscale_task( vdu, db_vnfr, diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 42a8a591..66de3487 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -1005,8 +1005,6 @@ class VimInteractionUpdateVdu(VimInteractionBase): task = ro_task["tasks"][task_index] task_id = task["task_id"] db_task_update = {"retries": 0} - created = False - created_items = {} target_vim = self.my_vims[ro_task["target_id"]] try: @@ -1020,10 +1018,6 @@ class VimInteractionUpdateVdu(VimInteractionBase): ro_vim_item_update = { "vim_id": vim_vm_id, "vim_status": "ACTIVE", - "created": created, - "created_items": created_items, - "vim_details": None, - "vim_message": None, } self.logger.debug( "task={} {} vm-migration done".format(task_id, ro_task["target_id"]) @@ -1036,7 +1030,6 @@ class VimInteractionUpdateVdu(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "created": created, "vim_message": str(e), } @@ -1446,8 +1439,6 @@ class VimInteractionMigration(VimInteractionBase): db_task_update = {"retries": 0} target_vim = self.my_vims[ro_task["target_id"]] vim_interfaces = [] - created = False - created_items = {} refreshed_vim_info = {} try: @@ -1486,8 +1477,6 @@ class VimInteractionMigration(VimInteractionBase): ro_vim_item_update = { "vim_id": vim_vm_id, "vim_status": "ACTIVE", - "created": created, - "created_items": created_items, "vim_details": None, "vim_message": None, } @@ -1514,7 +1503,6 @@ class VimInteractionMigration(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "created": created, "vim_message": str(e), } @@ -1526,27 +1514,17 @@ class VimInteractionResize(VimInteractionBase): task = ro_task["tasks"][task_index] task_id = task["task_id"] db_task_update = {"retries": 0} - created = False target_flavor_uuid = None - created_items = {} refreshed_vim_info = {} target_vim = self.my_vims[ro_task["target_id"]] try: + params = task["params"] + params_copy = deepcopy(params) + target_flavor_uuid = task_depends[params_copy["flavor_id"]] vim_vm_id = "" if task.get("params"): - vim_vm_id = task["params"].get("vim_vm_id") - flavor_dict = task["params"].get("flavor_dict") - self.logger.info("flavor_dict %s", flavor_dict) - - try: - target_flavor_uuid = target_vim.get_flavor_id_from_data(flavor_dict) - except Exception as e: - self.logger.info("Cannot find any flavor matching %s.", str(e)) - try: - target_flavor_uuid = target_vim.new_flavor(flavor_dict) - except Exception as e: - self.logger.error("Error creating flavor at VIM %s.", str(e)) + self.logger.info("vim_vm_id %s", vim_vm_id) if target_flavor_uuid is not None: resized_status = target_vim.resize_instance( @@ -1562,8 +1540,6 @@ class VimInteractionResize(VimInteractionBase): ro_vim_item_update = { "vim_id": vim_vm_id, "vim_status": "ACTIVE", - "created": created, - "created_items": created_items, "vim_details": None, "vim_message": None, } @@ -1584,7 +1560,6 @@ class VimInteractionResize(VimInteractionBase): ) ro_vim_item_update = { "vim_status": "VIM_ERROR", - "created": created, "vim_message": str(e), } diff --git a/NG-RO/osm_ng_ro/tests/test_ns.py b/NG-RO/osm_ng_ro/tests/test_ns.py index c692c51b..0fc4cfac 100644 --- a/NG-RO/osm_ng_ro/tests/test_ns.py +++ b/NG-RO/osm_ng_ro/tests/test_ns.py @@ -181,7 +181,7 @@ expected_extra_dict = { "disk_list": [], "flavor_id": f"TASK-{ns_preffix}:flavor.0", "image_id": f"TASK-{ns_preffix}:image.0", - "name": "sample_name-vnf-several-volu-several_volumes-VM-0", + "name": "sample_name-vnf-several-volumes-several_volumes-VM-0", "net_list": [], "start": True, }, @@ -201,7 +201,7 @@ expected_extra_dict2 = { "disk_list": [], "flavor_id": f"TASK-{ns_preffix}:flavor.0", "image_id": f"TASK-{ns_preffix}:image.0", - "name": "sample_name-vnf-several-volu-without_volumes-VM-0", + "name": "sample_name-vnf-several-volumes-without_volumes-VM-0", "net_list": [], "start": True, }, @@ -331,11 +331,14 @@ expected_result_vertical_scale = { "params": { "vim_vm_id": "f37b18ef-3caa-4dc9-ab91-15c669b16396", "flavor_dict": "flavor_dict", + "flavor_id": "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0", }, + "depends_on": ["nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0"], } vdu = { "id": vdu_id, "vim_info": {target_vim: {"interfaces": []}}, + "ns-flavor-id": "0", } vnf = {"_id": vnf_id} extra_dict_vertical_scale = { @@ -3210,11 +3213,25 @@ class TestNs(unittest.TestCase): self, assign_vim ): self.ns = Ns() - extra_dict = {} + extra_dict = {"params": {}} vdu_index = "1" task_index = 1 - expected_result = deepcopy(expected_result_vertical_scale) - expected_result.pop("params") + expected_result = { + "target_id": "vim:f9f370ac-0d44-41a7-9000-457f2332bc35", + "action_id": "bb937f49-3870-4169-b758-9732e1ff40f3", + "nsr_id": "993166fe-723e-4680-ac4b-b1af2541ae31", + "task_id": "bb937f49-3870-4169-b758-9732e1ff40f3:1", + "status": "SCHEDULED", + "action": "EXEC", + "item": "verticalscale", + "target_record": "vnfrs:665b4165-ce24-4320-bf19-b9a45bade49f:vdur.1.vim_info.vim:f9f370ac-0d44-41a7-9000-457f2332bc35", + "target_record_id": "vnfrs:665b4165-ce24-4320-bf19-b9a45bade49f:vdur.bb9c43f9-10a2-4569-a8a8-957c3528b6d1", + "params": { + "flavor_id": "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0" + }, + "depends_on": ["nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0"], + } + task = self.ns.verticalscale_task( vdu, vnf, vdu_index, action_id, nsr_id_2, task_index, extra_dict ) diff --git a/NG-RO/osm_ng_ro/tests/test_ns_thread.py b/NG-RO/osm_ng_ro/tests/test_ns_thread.py index ad3efe82..7e4388fc 100644 --- a/NG-RO/osm_ng_ro/tests/test_ns_thread.py +++ b/NG-RO/osm_ng_ro/tests/test_ns_thread.py @@ -1921,12 +1921,16 @@ class TestVimInteractionResize(unittest.TestCase): "params": { "vim_vm_id": "f37b18ef-3caa-4dc9-ab91-15c669b16396", "flavor_dict": "flavor_dict", + "flavor_id": "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0", }, } }, } + task_depends = { + "TASK-nsrs:993166fe-723e-4680-ac4b-b1af2541ae31:flavor.0": "1" + } task_index = "task_index_1" - result = instance.exec(ro_task, task_index, self.task_depends) + result = instance.exec(ro_task, task_index, task_depends) self.assertEqual(result[0], "DONE") self.assertEqual(result[1].get("vim_status"), "ACTIVE") diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index 9d474371..2017d563 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -3902,7 +3902,9 @@ class vimconnector(vimconn.VimConnector): self.nova.servers.resize(server=vm_id, flavor=new_flavor_id) vm_state = self.__wait_for_vm(vm_id, "VERIFY_RESIZE") if vm_state: - instance_resized_status = self.confirm_resize(vm_id) + instance_resized_status = self.confirm_resize( + vm_id, instance_status + ) return instance_resized_status else: raise nvExceptions.BadRequest( @@ -3923,7 +3925,7 @@ class vimconnector(vimconn.VimConnector): ) as e: self._format_exception(e) - def confirm_resize(self, vm_id): + def confirm_resize(self, vm_id, instance_state): """ Confirm the resize of an instance param: @@ -3932,7 +3934,7 @@ class vimconnector(vimconn.VimConnector): self._reload_connection() self.nova.servers.confirm_resize(server=vm_id) if self.get_vdu_state(vm_id)[0] == "VERIFY_RESIZE": - self.__wait_for_vm(vm_id, "ACTIVE") + self.__wait_for_vm(vm_id, instance_state) instance_status = self.get_vdu_state(vm_id)[0] return instance_status diff --git a/releasenotes/notes/bug_2310_fix-a89efc73f53f5578.yaml b/releasenotes/notes/bug_2310_fix-a89efc73f53f5578.yaml new file mode 100644 index 00000000..830f002e --- /dev/null +++ b/releasenotes/notes/bug_2310_fix-a89efc73f53f5578.yaml @@ -0,0 +1,21 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + This fixes the bug 2310 - NS Termination/Update failing after + Vertical-Scaling/Migration/Operate-VNF diff --git a/releasenotes/notes/bug_fix_2304_Flavor_Not_getting_Updated_in_Mongodb_nsrs_after_Vertical_scale-2dab98ac5b1072e7.yaml b/releasenotes/notes/bug_fix_2304_Flavor_Not_getting_Updated_in_Mongodb_nsrs_after_Vertical_scale-2dab98ac5b1072e7.yaml new file mode 100644 index 00000000..97bb2394 --- /dev/null +++ b/releasenotes/notes/bug_fix_2304_Flavor_Not_getting_Updated_in_Mongodb_nsrs_after_Vertical_scale-2dab98ac5b1072e7.yaml @@ -0,0 +1,22 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Bug Fix 2304 Flavor Not getting Updated in Mongodb nsrs after Vertical scaling, + because In vertical scale feature Ro task creation is not not added for flavor. + This fix will add the new flavor in nsrs after scaling and it's refrence in vnfrs. diff --git a/releasenotes/notes/bug_fix_2306_Monitoring_task_in_RO_monitoring.py_is_replacing_the_dual_stcak_IP_with_IPV4-d18276e037a118a7.yaml b/releasenotes/notes/bug_fix_2306_Monitoring_task_in_RO_monitoring.py_is_replacing_the_dual_stcak_IP_with_IPV4-d18276e037a118a7.yaml new file mode 100644 index 00000000..20ee4ba0 --- /dev/null +++ b/releasenotes/notes/bug_fix_2306_Monitoring_task_in_RO_monitoring.py_is_replacing_the_dual_stcak_IP_with_IPV4-d18276e037a118a7.yaml @@ -0,0 +1,81 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +prelude: > + Replace this text with content to appear at the top of the section for this + release. All of the prelude content is merged together and then rendered + separately from the items listed in other parts of the file, so the text + needs to be worded so that both the prelude and the other items make sense + when read independently. This may mean repeating some details. Not every + release note requires a prelude. Usually only notes describing major + features or adding release theme details should have a prelude. +features: + - | + List new features here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +issues: + - | + List known issues here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +upgrade: + - | + List upgrade notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +deprecations: + - | + List deprecations notes here, or remove this section. All of the list + items in this section are combined when the release notes are rendered, so + the text needs to be worded so that it does not depend on any information + only available in another section, such as the prelude. This may mean + repeating some details. +critical: + - | + Add critical notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +security: + - | + Add security notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +fixes: + - | + Add normal bug fixes here, or remove this section. All of the list items + in this section are combined when the release notes are rendered, so the + text needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +other: + - | + Add other notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. diff --git a/releasenotes/notes/bug_fix_2316-94732548c63aea74.yaml b/releasenotes/notes/bug_fix_2316-94732548c63aea74.yaml new file mode 100644 index 00000000..cdc420dc --- /dev/null +++ b/releasenotes/notes/bug_fix_2316-94732548c63aea74.yaml @@ -0,0 +1,21 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Fix for bug 2316 Unable to do vertical scaling when VM is in shutdown + state. diff --git a/releasenotes/notes/fix_bug_2303-ce9784503f03a941.yaml b/releasenotes/notes/fix_bug_2303-ce9784503f03a941.yaml new file mode 100644 index 00000000..af477b7c --- /dev/null +++ b/releasenotes/notes/fix_bug_2303-ce9784503f03a941.yaml @@ -0,0 +1,24 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Fix bug 2303: RO Openstack connector was truncating each of the fields used to + build the name of VM instances. This fix removes that truncate in favor of + generating the whole name `---`. In case + the name must be truncated, it should be done from the resulting full name. +