X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_nbi%2Finstance_topics.py;h=60722676126f9b6781da9691ecbc2bbbd2f54fed;hb=5cdcb80a5a968efc0f21c358974200c0f7bf75c5;hp=2eefb962034011cbd7258682fc3ae26c03c71a83;hpb=f2af4a100d308e07f355d61b94fb27d1ccc97aa2;p=osm%2FNBI.git diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 2eefb96..6072267 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -440,6 +440,23 @@ 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" + ): + # Avoid setting the volume name multiple times + if not match(f"shared-.*-{vnfd['id']}", 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 +560,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 +598,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 +640,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( @@ -885,7 +905,7 @@ class NsrTopic(BaseTopic): # Name, mac-address and interface position is taken from VNFD # and included into VNFR. By this way RO can process this information # while creating the VDU. - iface_fields = ("name", "mac-address", "position") + iface_fields = ("name", "mac-address", "position", "ip-address") vdu_iface = { x: iface[x] for x in iface_fields if iface.get(x) is not None } @@ -955,7 +975,7 @@ class NsrTopic(BaseTopic): if ( cpd.get("constituent-cpd-id") == iface_ext_cp - ): + ) and vnf_profile.get("id") == vnf_index: vdu_iface["ns-vld-id"] = vlc.get( "virtual-link-profile-id" ) @@ -1021,6 +1041,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 +1116,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): @@ -1313,7 +1347,6 @@ class NsLcmOpTopic(BaseTopic): vnfd_id_2update = indata["changeVnfPackageData"]["vnfdId"] if vnf_instance_id not in nsr["constituent-vnfr-ref"]: - raise EngineException( f"Error in validating ns-update request: vnf {vnf_instance_id} does not " f"belong to NS {ns_instance_id}", @@ -1333,7 +1366,6 @@ class NsLcmOpTopic(BaseTopic): # Check the given vnfd-id belongs to given vnf instance if constituent_vnfd_id and (vnfd_id_2update != constituent_vnfd_id): - raise EngineException( f"Error in validating ns-update request: vnfd-id {vnfd_id_2update} does not " f"match with the vnfd-id: {constituent_vnfd_id} of VNF instance: {vnf_instance_id}", @@ -1537,8 +1569,8 @@ class NsLcmOpTopic(BaseTopic): ivld.get("id"): set() for ivld in get_iterable(vnfd.get("int-virtual-link-desc")) } - for vdu in get_iterable(vnfd.get("vdu")): - for cpd in get_iterable(vnfd.get("int-cpd")): + for vdu in vnfd.get("vdu", {}): + for cpd in vdu.get("int-cpd", {}): if cpd.get("int-virtual-link-desc"): vnfd_ivlds_cpds[cpd.get("int-virtual-link-desc")] = cpd.get("id") @@ -2281,6 +2313,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 ) @@ -2297,6 +2332,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