From 18101ea2396dcd53d7a8b6a2e923cebaddae4735 Mon Sep 17 00:00:00 2001 From: vegall Date: Mon, 6 Mar 2023 13:49:21 +0000 Subject: [PATCH] Feature 10972: Support of volume multi-attach Change-Id: I6e22ec266f56074176ce8cbd0d7f92545a3b00f3 Signed-off-by: vegall --- osm_nbi/instance_topics.py | 41 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index d7f826f..4a5293d 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -440,6 +440,22 @@ class NsrTopic(BaseTopic): return ns_k8s_namespace + def _add_shared_volumes_to_nsr( + self, vdu, vnfd, nsr_descriptor, member_vnf_index, revision=None + ): + svsd = [] + for vsd in vnfd.get("virtual-storage-desc", ()): + if vsd.get("vdu-storage-requirements"): + if ( + vsd.get("vdu-storage-requirements")[0].get("key") == "multiattach" + and vsd.get("vdu-storage-requirements")[0].get("value") == "True" + ): + if "shared" not in vsd["id"]: + vsd["id"] = f"shared-{vsd['id']}-{vnfd['id']}" + svsd.append(vsd) + if svsd: + nsr_descriptor["shared-volumes"] = svsd + def _add_flavor_to_nsr( self, vdu, vnfd, nsr_descriptor, member_vnf_index, revision=None ): @@ -543,6 +559,7 @@ class NsrTopic(BaseTopic): "flavor": [], "image": [], "affinity-or-anti-affinity-group": [], + "shared-volumes": [], } if "revision" in nsd["_admin"]: nsr_descriptor["revision"] = nsd["_admin"]["revision"] @@ -580,6 +597,9 @@ class NsrTopic(BaseTopic): for vdu in vnfd.get("vdu", ()): member_vnf_index = vnf_profile.get("id") self._add_flavor_to_nsr(vdu, vnfd, nsr_descriptor, member_vnf_index) + self._add_shared_volumes_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) @@ -619,7 +639,6 @@ class NsrTopic(BaseTopic): ) vld["name"] = vld["id"] nsr_descriptor["vld"] = nsr_vld - return nsr_descriptor def _get_affinity_or_anti_affinity_group_data_from_vnfd( @@ -1021,6 +1040,21 @@ class NsrTopic(BaseTopic): if nsr_flavor_desc: vdur["ns-flavor-id"] = nsr_flavor_desc["id"] + # Adding Shared Volume information to vdur + if vdur.get("virtual-storages"): + nsr_sv = [] + for vsd in vdur["virtual-storages"]: + if vsd.get("vdu-storage-requirements"): + if ( + vsd["vdu-storage-requirements"][0].get("key") + == "multiattach" + and vsd["vdu-storage-requirements"][0].get("value") + == "True" + ): + nsr_sv.append(vsd["id"]) + if nsr_sv: + vdur["shared-volumes-id"] = nsr_sv + # Adding Affinity groups information to vdur try: vdu_profile_affinity_group = utils.find_in_list( @@ -1081,7 +1115,6 @@ class NsrTopic(BaseTopic): vdur["id"] = vdur["_id"] vdur["count-index"] = index vnfr_descriptor["vdur"].append(vdur) - return vnfr_descriptor def vca_status_refresh(self, session, ns_instance_content, filter_q): @@ -2279,6 +2312,9 @@ class NsLcmOpTopic(BaseTopic): vnf_index = vnfr["member-vnf-index-ref"] self.logger.info("nsr {}".format(nsr)) for vdu in vnfd["vdu"]: + self.nsrtopic._add_shared_volumes_to_nsr( + vdu, vnfd, nsr, vnf_index, latest_vnfd_revision + ) self.nsrtopic._add_flavor_to_nsr( vdu, vnfd, nsr, vnf_index, latest_vnfd_revision ) @@ -2295,6 +2331,7 @@ class NsLcmOpTopic(BaseTopic): self.nsrtopic._add_image_to_nsr(nsr, image_data) nsr_update["image"] = nsr["image"] nsr_update["flavor"] = nsr["flavor"] + nsr_update["shared-volumes"] = nsr["shared-volumes"] self.db.set_one("nsrs", {"_id": nsr["_id"]}, nsr_update) ns_k8s_namespace = self.nsrtopic._get_ns_k8s_namespace( nsd, ns_request, session -- 2.25.1