Feature 11011: Multiple NS deletion in OSM 96/14396/6
authoradurti <adurti.v@tataelxsi.co.in>
Fri, 31 May 2024 06:06:57 +0000 (11:36 +0530)
committerAdurti <adurti.v@tataelxsi.co.in>
Thu, 18 Jul 2024 15:42:27 +0000 (15:42 +0000)
Change-Id: I79e2195e1d5228165d7672fcc6bab78aba407253
Signed-off-by: adurti <adurti.v@tataelxsi.co.in>
osm_nbi/nbi.py
osm_nbi/resources_to_operations.yml

index dcee50c..14a0899 100644 (file)
@@ -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
index 3c5ba3d..6e2eb45 100644 (file)
@@ -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/<nsInstanceId>": "ns_instances:id:get"
   "GET /nslcm/v1/ns_instances/<nsInstanceId>": "ns_instances:id:get"