Bug 2376 fixed: NBI fix for Performing NS-Update through CLI 77/14377/4
authorjegan <jegan.s@tataelxsi.co.in>
Thu, 16 May 2024 07:07:27 +0000 (07:07 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 9 Jul 2024 15:09:50 +0000 (17:09 +0200)
Change-Id: Ic7ce37d4a6197459fd535e55f9914e47c4daa2ff
Signed-off-by: 36970 <jegan.s@tataelxsi.co.in>
osm_nbi/instance_topics.py

index 0e4d9ba..115f433 100644 (file)
@@ -1338,6 +1338,11 @@ class NsLcmOpTopic(BaseTopic):
         If updateType is REMOVE_VNF:
         - it checks if the vnfInstanceId is available in the ns instance
         - Otherwise exception will be raised.
+        If updateType is OPERATE_VNF
+        - it checks if the vdu-id is persent in the descriptor or not
+        - it checks if the changeStateTo is either start, stop or rebuild
+        If updateType is VERTICAL_SCALE
+        - it checks if the vdu-id is persent in the descriptor or not
 
         Args:
             indata: includes updateType such as CHANGE_VNFPKG,
@@ -1404,6 +1409,36 @@ class NsLcmOpTopic(BaseTopic):
                         "Invalid VNF Instance Id. '{}' is not "
                         "present in the NS '{}'".format(vnf_instance_id, ns_instance_id)
                     )
+            elif indata["updateType"] == "OPERATE_VNF":
+                if indata.get("operateVnfData"):
+                    if indata["operateVnfData"]["changeStateTo"] not in (
+                        "start",
+                        "stop",
+                        "rebuild",
+                    ):
+                        raise EngineException(
+                            f"The operate type should be either start, stop or rebuild not {indata['operateVnfData']['changeStateTo']}",
+                            http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
+                        )
+                    if indata["operateVnfData"].get("additionalParam"):
+                        vdu_id = indata["operateVnfData"]["additionalParam"]["vdu_id"]
+                        vnfinstance_id = indata["operateVnfData"]["vnfInstanceId"]
+                        vnf = self.db.get_one("vnfrs", {"_id": vnfinstance_id})
+                        vnfd_member_vnf_index = vnf.get("member-vnf-index-ref")
+                        vnfd = self._get_vnfd_from_vnf_member_index(
+                            vnfd_member_vnf_index, nsr["_id"]
+                        )
+                        self._check_valid_vdu(vnfd, vdu_id)
+            elif indata["updateType"] == "VERTICAL_SCALE":
+                if indata.get("verticalScaleVnf"):
+                    vdu_id = indata["verticalScaleVnf"]["vduId"]
+                    vnfinstance_id = indata["verticalScaleVnf"]["vnfInstanceId"]
+                    vnf = self.db.get_one("vnfrs", {"_id": vnfinstance_id})
+                    vnfd_member_vnf_index = vnf.get("member-vnf-index-ref")
+                    vnfd = self._get_vnfd_from_vnf_member_index(
+                        vnfd_member_vnf_index, nsr["_id"]
+                    )
+                    self._check_valid_vdu(vnfd, vdu_id)
 
         except (
             DbException,