From: tierno Date: Fri, 21 Dec 2018 13:31:52 +0000 (+0000) Subject: fix error ns_instances_content when not instantiated, rollback problems and pdu usage... X-Git-Tag: v5.0.3~11^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=e86317875d395c37b3ded147b554ced8a8115358;p=osm%2FNBI.git fix error ns_instances_content when not instantiated, rollback problems and pdu usage references Change-Id: Ieeb601d329baa3c8a69755b48b45b53b96b865bd Signed-off-by: tierno --- diff --git a/osm_nbi/html_public/version b/osm_nbi/html_public/version index 1b5afc2..630b94d 100644 --- a/osm_nbi/html_public/version +++ b/osm_nbi/html_public/version @@ -1,2 +1,2 @@ -0.1.31 -2018-12-12 +0.1.32 +2018-12-21 diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index ac0dba9..b9d929d 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -517,10 +517,10 @@ class NsLcmOpTopic(BaseTopic): } self.db.set_one("pdus", {"_id": pdu["_id"]}, {"_admin.usageState": "IN_USE", - "_admin.usage.vnfr_id": vnfr["_id"], - "_admin.usage.nsr_id": vnfr["nsr-id-ref"], - "_admin.usage.vdur": vdur["vdu-id-ref"]} - ) + "_admin.usage": {"vnfr_id": vnfr["_id"], + "nsr_id": vnfr["nsr-id-ref"], + "vdur": vdur["vdu-id-ref"]} + }) rollback.append({"topic": "pdus", "_id": pdu["_id"], "operation": "set", "content": rollback_pdu}) # step 3. Fill vnfr info by filling vdur @@ -668,7 +668,7 @@ class NsLcmOpTopic(BaseTopic): if not nsr["_admin"].get("nsState") or nsr["_admin"]["nsState"] == "NOT_INSTANTIATED": if operation == "terminate" and indata.get("autoremove"): # NSR must be deleted - return self.delete(session, nsInstanceId) + return None # a none in this case is used to indicate not instantiated. It can be removed if operation != "instantiate": raise EngineException("ns_instance '{}' cannot be '{}' because it is not instantiated".format( nsInstanceId, operation), HTTPStatus.CONFLICT) @@ -1037,7 +1037,7 @@ class NsiLcmOpTopic(BaseTopic): if not nsir["_admin"].get("nsiState") or nsir["_admin"]["nsiState"] == "NOT_INSTANTIATED": if operation == "terminate" and indata.get("autoremove"): # NSIR must be deleted - return self.delete(session, nsiInstanceId) + return None # a none in this case is used to indicate not instantiated. It can be removed if operation != "instantiate": raise EngineException("netslice_instance '{}' cannot be '{}' because it is not instantiated".format( nsiInstanceId, operation), HTTPStatus.CONFLICT) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 3dd3348..46c7c9b 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -815,6 +815,7 @@ class Server(object): outdata = self.engine.del_item_list(session, engine_topic, kwargs) cherrypy.response.status = HTTPStatus.OK.value else: # len(args) > 1 + delete_in_process = False if topic == "ns_instances_content" and not force: nslcmop_desc = { "lcmOperationType": "terminate", @@ -822,8 +823,10 @@ class Server(object): "autoremove": True } opp_id = self.engine.new_item(rollback, session, "nslcmops", nslcmop_desc, None) - outdata = {"_id": opp_id} - cherrypy.response.status = HTTPStatus.ACCEPTED.value + if opp_id: + delete_in_process = True + outdata = {"_id": opp_id} + cherrypy.response.status = HTTPStatus.ACCEPTED.value elif topic == "netslice_instances_content" and not force: nsilcmop_desc = { "lcmOperationType": "terminate", @@ -831,9 +834,11 @@ class Server(object): "autoremove": True } opp_id = self.engine.new_item(rollback, session, "nsilcmops", nsilcmop_desc, None) - outdata = {"_id": opp_id} - cherrypy.response.status = HTTPStatus.ACCEPTED.value - else: + if opp_id: + delete_in_process = True + outdata = {"_id": opp_id} + cherrypy.response.status = HTTPStatus.ACCEPTED.value + if not delete_in_process: self.engine.del_item(session, engine_topic, _id, force) cherrypy.response.status = HTTPStatus.NO_CONTENT.value if engine_topic in ("vim_accounts", "wim_accounts", "sdns"): @@ -875,7 +880,8 @@ class Server(object): self.engine.db.set_one(rollback_item["topic"], {"_id": rollback_item["_id"]}, rollback_item["content"], fail_on_empty=False) else: - self.engine.del_item(**rollback_item, session=session, force=True) + self.engine.db.del_one(rollback_item["topic"], {"_id": rollback_item["_id"]}, + fail_on_empty=False) except Exception as e2: rollback_error_text = "Rollback Exception {}: {}".format(rollback_item, e2) cherrypy.log(rollback_error_text)