From: tierno Date: Mon, 21 May 2018 16:13:29 +0000 (+0200) Subject: Enhance checking at nsd:constituent-vnfd:member-vnf-index X-Git-Tag: v4.0.0 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=dce10e2d28ce2cd4625d2ec209e6e5225010b3e6;p=osm%2FNBI.git Enhance checking at nsd:constituent-vnfd:member-vnf-index Change-Id: I03dbbf168c8f459a30e883ed5bc415f5a1aec8f9 Signed-off-by: tierno --- diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index 193ae6c..ed35c7c 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -310,8 +310,14 @@ class Engine(object): if self.db.get_one(item, filter, fail_on_empty=False): raise EngineException("{} with id '{}' already exists for this tenant".format(item[:-1], indata["id"]), HTTPStatus.CONFLICT) + # TODO validate with pyangbind. Load and dumps to convert data types + if item == "nsds": + # transform constituent-vnfd:member-vnf-index to string + if indata.get("constituent-vnfd"): + for constituent_vnfd in indata["constituent-vnfd"]: + if "member-vnf-index" in constituent_vnfd: + constituent_vnfd["member-vnf-index"] = str(constituent_vnfd["member-vnf-index"]) - # TODO validate with pyangbind if item == "nsds" and not force: self._check_descriptor_dependencies(session, "nsds", indata) elif item == "userDefinedData": @@ -368,12 +374,6 @@ class Engine(object): indata["_admin"]["projects_read"] = [session["project_id"]] if not indata["_admin"].get("projects_write"): indata["_admin"]["projects_write"] = [session["project_id"]] - if item == "nsds": - # transform constituent-vnfd:member-vnf-index to string - if indata.get("constituent-vnfd"): - for constituent_vnfd in indata["constituent-vnfd"]: - if "member-vnf-index" in constituent_vnfd: - constituent_vnfd["member-vnf-index"] = str(constituent_vnfd["member-vnf-index"]) if item in ("vnfds", "nsds"): indata["_admin"]["onboardingState"] = "CREATED" indata["_admin"]["operationalState"] = "DISABLED" @@ -934,12 +934,13 @@ class Engine(object): self._add_delete_filter(session, item, filter) if item in ("vnfds", "nsds") and not force: descriptor = self.get_item(session, item, _id) - descriptor_id = descriptor["id"] - self._check_dependencies_on_descriptor(session, item, descriptor_id) + descriptor_id = descriptor.get("id") + if descriptor_id: + self._check_dependencies_on_descriptor(session, item, descriptor_id) if item == "nsrs": nsr = self.db.get_one(item, filter) - if nsr["_admin"]["nsState"] == "INSTANTIATED" and not force: + if nsr["_admin"].get("nsState") == "INSTANTIATED" and not force: raise EngineException("nsr '{}' cannot be deleted because it is in 'INSTANTIATED' state. " "Launch 'terminate' operation first; or force deletion".format(_id), http_code=HTTPStatus.CONFLICT) diff --git a/osm_nbi/html_public/version b/osm_nbi/html_public/version index 16dfe9f..af29d72 100644 --- a/osm_nbi/html_public/version +++ b/osm_nbi/html_public/version @@ -1,3 +1,3 @@ -0.1.8 -2018-05-18 +0.1.9 +2018-05-21