Feature 10916: Remove VNF Instance from NS - NS Update
[osm/NBI.git] / osm_nbi / instance_topics.py
index 74815ca..2df6a7d 100644 (file)
@@ -28,6 +28,7 @@ from osm_nbi.validation import (
     ns_scale,
     ns_update,
     nsi_instantiate,
+    ns_migrate,
 )
 from osm_nbi.base_topic import (
     BaseTopic,
@@ -1158,6 +1159,7 @@ class NsLcmOpTopic(BaseTopic):
         "update": ns_update,
         "scale": ns_scale,
         "terminate": ns_terminate,
+        "migrate": ns_migrate,
     }
 
     def __init__(self, db, fs, msg, auth):
@@ -1276,6 +1278,9 @@ class NsLcmOpTopic(BaseTopic):
         - it checks the vnfInstanceId, whether it's available under ns instance
         - it checks the vnfdId whether it matches with the vnfd-id in the vnf-record of specified VNF.
         Otherwise exception will be raised.
+        If updateType is REMOVE_VNF:
+        - it checks if the vnfInstanceId is available in the ns instance
+        - Otherwise exception will be raised.
 
         Args:
             indata: includes updateType such as CHANGE_VNFPKG,
@@ -1336,6 +1341,14 @@ class NsLcmOpTopic(BaseTopic):
                         ),
                         http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
                     )
+            elif indata["updateType"] == "REMOVE_VNF":
+                vnf_instance_id = indata["removeVnfInstanceId"]
+                ns_instance_id = indata["nsInstanceId"]
+                if vnf_instance_id not in nsr["constituent-vnfr-ref"]:
+                    raise EngineException(
+                        "Invalid VNF Instance Id. '{}' is not "
+                        "present in the NS '{}'".format(vnf_instance_id, ns_instance_id)
+                    )
 
         except (
             DbException,