X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_nbi%2Finstance_topics.py;h=b4ce2706a6abbc81e00fad9fc9997c73fdc0d14f;hb=cee2ebfe3b4a0e4fe7a566eeb6e3f959649e1fce;hp=39d98342cb2bcef6de376271a4aeab289bd89587;hpb=9fb3271fa1d2568ef693d6f71d25884d7e6ea45e;p=osm%2FNBI.git diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 39d9834..b4ce270 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -348,6 +348,9 @@ class NsrTopic(BaseTopic): ) if vnfd_id not in needed_vnfds: vnfd = self._get_vnfd_from_db(vnfd_id, session) + if "revision" in vnfd["_admin"]: + vnfd["revision"] = vnfd["_admin"]["revision"] + vnfd.pop("_admin") needed_vnfds[vnfd_id] = vnfd nsr_descriptor["vnfd-id"].append(vnfd["_id"]) else: @@ -397,7 +400,6 @@ class NsrTopic(BaseTopic): _filter = self._get_project_filter(session) _filter["id"] = vnfd_id vnfd = self.db.get_one("vnfds", _filter, fail_on_empty=True, fail_on_more=True) - vnfd.pop("_admin") return vnfd def _add_nsr_to_db(self, nsr_descriptor, rollback, session): @@ -507,6 +509,7 @@ class NsrTopic(BaseTopic): ) vnfd = self._get_vnfd_from_db(vnf_profile.get("vnfd-id"), session) + vnfd.pop("_admin") for vdu in vnfd.get("vdu", ()): flavor_data = {} @@ -706,6 +709,13 @@ class NsrTopic(BaseTopic): "connection-point": [], "ip-address": None, # mgmt-interface filled by LCM } + + # Revision backwards compatility. Only specify the revision in the record if + # the original VNFD has a revision. + if "revision" in vnfd: + vnfr_descriptor["revision"] = vnfd["revision"] + + vnf_k8s_namespace = ns_k8s_namespace if vnf_params: if vnf_params.get("k8s-namespace"): @@ -1282,7 +1292,14 @@ class NsLcmOpTopic(BaseTopic): "Invalid parameter member_vnf_index='{}' is not one of the " "nsd:constituent-vnfd".format(member_vnf_index) ) - vnfd = self.db.get_one("vnfds", {"_id": vnfr["vnfd-id"]}, fail_on_empty=False) + + ## Backwards compatibility: if there is no revision, get it from the one and only VNFD entry + if "revision" in vnfr: + vnfd_revision = vnfr["vnfd-id"] + ":" + str(vnfr["revision"]) + vnfd = self.db.get_one("vnfds_revisions", {"_id": vnfd_revision}, fail_on_empty=False) + else: + vnfd = self.db.get_one("vnfds", {"_id": vnfr["vnfd-id"]}, fail_on_empty=False) + if not vnfd: raise EngineException( "vnfd id={} has been deleted!. Operation cannot be performed".format(