From 99078a9577483842df536a706651542dfcde35be Mon Sep 17 00:00:00 2001 From: elumalai Date: Tue, 5 Jul 2022 17:53:59 +0530 Subject: [PATCH] Bug 2097: Fix for flavor name Added member-vnf-index and revision number in flavor name to keep it unique. Change-Id: Ie1e3bc23cba30812a0b917f1518bc4567c9e31b3 Signed-off-by: elumalai --- osm_nbi/instance_topics.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 176f86d..16bd406 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -441,7 +441,7 @@ class NsrTopic(BaseTopic): return ns_k8s_namespace - def _add_flavor_to_nsr(self, vdu, vnfd, nsr_descriptor): + def _add_flavor_to_nsr(self, vdu, vnfd, nsr_descriptor, member_vnf_index, revision=None): flavor_data = {} guest_epa = {} # Find this vdu compute and storage descriptors @@ -511,7 +511,8 @@ class NsrTopic(BaseTopic): if guest_epa: flavor_data["guest-epa"] = guest_epa - flavor_data["name"] = vdu["id"][:56] + "-flv" + revision = revision if revision is not None else 1 + flavor_data["name"] = vdu["id"][:56] + "-" + member_vnf_index + "-" + str(revision) + "-flv" flavor_data["id"] = str(len(nsr_descriptor["flavor"])) nsr_descriptor["flavor"].append(flavor_data) @@ -593,7 +594,8 @@ class NsrTopic(BaseTopic): vnfd.pop("_admin") for vdu in vnfd.get("vdu", ()): - self._add_flavor_to_nsr(vdu, vnfd, nsr_descriptor) + member_vnf_index = vnf_profile.get("id") + self._add_flavor_to_nsr(vdu, vnfd, nsr_descriptor, member_vnf_index) sw_image_id = vdu.get("sw-image-desc") if sw_image_id: image_data = self._get_image_data_from_vnfd(vnfd, sw_image_id) @@ -719,6 +721,7 @@ class NsrTopic(BaseTopic): nsr_descriptor, ns_request, ns_k8s_namespace, + revision=None, ): vnfr_id = str(uuid4()) nsr_id = nsr_descriptor["id"] @@ -1023,7 +1026,8 @@ class NsrTopic(BaseTopic): alt_image_ids.append(nsr_sw_image_data["id"]) vdur["alt-image-ids"] = alt_image_ids - flavor_data_name = vdu["id"][:56] + "-flv" + revision = revision if revision is not None else 1 + flavor_data_name = vdu["id"][:56] + "-" + vnf_index + "-" + str(revision) + "-flv" nsr_flavor_desc = utils.find_in_list( nsr_descriptor["flavor"], lambda flavor: flavor["name"] == flavor_data_name, @@ -2259,7 +2263,7 @@ class NsLcmOpTopic(BaseTopic): vnf_index = vnfr["member-vnf-index-ref"] self.logger.info("nsr {}".format(nsr)) for vdu in vnfd["vdu"]: - self.nsrtopic._add_flavor_to_nsr(vdu, vnfd, nsr) + self.nsrtopic._add_flavor_to_nsr(vdu, vnfd, nsr, vnf_index, latest_vnfd_revision) sw_image_id = vdu.get("sw-image-desc") if sw_image_id: image_data = self.nsrtopic._get_image_data_from_vnfd(vnfd, sw_image_id) @@ -2279,6 +2283,7 @@ class NsLcmOpTopic(BaseTopic): nsr, ns_request, ns_k8s_namespace, + latest_vnfd_revision, ) indata["newVdur"] = vnfr_descriptor["vdur"] nslcmop_desc = self._create_nslcmop(nsInstanceId, operation, indata) -- 2.25.1