Bug 2376 fixed: NBI fix for Performing NS-Update through CLI
Change-Id: Ic7ce37d4a6197459fd535e55f9914e47c4daa2ff
Signed-off-by: 36970 <jegan.s@tataelxsi.co.in>
diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py
index 0e4d9ba..115f433 100644
--- a/osm_nbi/instance_topics.py
+++ b/osm_nbi/instance_topics.py
@@ -1338,6 +1338,11 @@
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 @@
"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,