From: adurti Date: Fri, 31 May 2024 06:06:57 +0000 (+0530) Subject: Feature 11011: Multiple NS deletion in OSM X-Git-Tag: release-v16.0-start~10 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=3af50955fa4c63fa334fd23d4081250657e1ccb3;p=osm%2FNBI.git Feature 11011: Multiple NS deletion in OSM Change-Id: I79e2195e1d5228165d7672fcc6bab78aba407253 Signed-off-by: adurti --- 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"