From 3af50955fa4c63fa334fd23d4081250657e1ccb3 Mon Sep 17 00:00:00 2001 From: adurti Date: Fri, 31 May 2024 11:36:57 +0530 Subject: [PATCH] Feature 11011: Multiple NS deletion in OSM Change-Id: I79e2195e1d5228165d7672fcc6bab78aba407253 Signed-off-by: adurti --- osm_nbi/nbi.py | 27 +++++++++++++++++++++++++++ osm_nbi/resources_to_operations.yml | 1 + 2 files changed, 28 insertions(+) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index dcee50c..14a0899 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -436,6 +436,10 @@ valid_url_methods = { }, "nslcm": { "v1": { + "ns_instances_terminate": { + "METHODS": ("POST"), + "ROLE_PERMISSION": "ns_instances:", + }, "ns_instances_content": { "METHODS": ("GET", "POST"), "ROLE_PERMISSION": "ns_instances:", @@ -1623,6 +1627,29 @@ class Server(object): ) self._set_location_header(main_topic, version, topic, _id) outdata = {"id": _id, "nslcmop_id": nslcmop_id, "nsName": nsName} + elif topic == "ns_instances_terminate": + if indata.get("ns_ids"): + for ns_id in indata.get("ns_ids"): + nslcmop_desc = { + "lcmOperationType": "terminate", + "nsInstanceId": ns_id, + "autoremove": indata.get("autoremove") + if "autoremove" in indata + else True, + } + op_id, _, _ = self.engine.new_item( + rollback, + engine_session, + "nslcmops", + nslcmop_desc, + kwargs, + ) + if not op_id: + _ = self.engine.del_item( + engine_session, engine_topic, ns_id + ) + outdata = {"ns_ids": indata.get("ns_ids")} + cherrypy.response.status = HTTPStatus.ACCEPTED.value elif topic == "ns_instances" and item: indata["lcmOperationType"] = item indata["nsInstanceId"] = _id diff --git a/osm_nbi/resources_to_operations.yml b/osm_nbi/resources_to_operations.yml index 3c5ba3d..6e2eb45 100644 --- a/osm_nbi/resources_to_operations.yml +++ b/osm_nbi/resources_to_operations.yml @@ -116,6 +116,7 @@ resources_to_operations: "GET /nslcm/v1/ns_instances": "ns_instances:get" "POST /nslcm/v1/ns_instances_content": "ns_instances:content:post" + "POST /nslcm/v1/ns_instances_terminate": "ns_instances:content:post" "GET /nslcm/v1/ns_instances_content/": "ns_instances:id:get" "GET /nslcm/v1/ns_instances/": "ns_instances:id:get" -- 2.25.1