else: # timeout_ns_deploy
raise NgRoException("Timeout waiting ns to deploy")
+ def rollback_scaling(self, nsr_id, nslcmop_id):
+ try:
+ db_nslcmop = self.db.get_one("nslcmops", {"_id": nslcmop_id})
+ db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+ vnf_index = db_nslcmop["operationParams"]["scaleVnfData"][
+ "scaleByStepData"
+ ]["member-vnf-index"]
+ db_vnfr = self.db.get_one(
+ "vnfrs", {"member-vnf-index-ref": vnf_index, "nsr-id-ref": nsr_id}
+ )
+ vim_id = "vim:{}".format(db_vnfr["vim-account-id"])
+ db_vnfr_update = {"vdur": db_vnfr["vdur"]}
+ counter = len(db_vnfr_update["vdur"])
+ updated_db_vnfr = []
+ for index, vdur in enumerate(db_vnfr_update["vdur"]):
+ if vdur["vim_info"][vim_id].get("vim_status") == "ACTIVE":
+ updated_db_vnfr.append(vdur)
+ db_vnfr_update["vdur"] = updated_db_vnfr
+ self.update_db_2("vnfrs", db_vnfr["_id"], db_vnfr_update)
+ scaling_group = db_nslcmop["operationParams"]["scaleVnfData"][
+ "scaleByStepData"
+ ]["scaling-group-descriptor"]
+ counter -= len(updated_db_vnfr)
+ db_nsr_update = {
+ "_admin.scaling-group": db_nsr["_admin"].get("scaling-group")
+ }
+ if db_nsr["_admin"].get("scaling-group"):
+ for index, group in enumerate(db_nsr_update["_admin.scaling-group"]):
+ if (
+ group["name"] == scaling_group
+ and group["vnf_index"] == vnf_index
+ ):
+ group["nb-scale-op"] -= counter
+ self.update_db_2("nsrs", nsr_id, db_nsr_update)
+ except Exception as e:
+ self.logger.info(f"There is an error in updating the database. Error {e}")
+
async def _terminate_ng_ro(
self, logging_text, nsr_deployed, nsr_id, nslcmop_id, stage
):
old_config_status = ""
nsi_id = None
prom_job_name = ""
+ exe = None
+ nb_scale_op_update = False
try:
# wait for any previous tasks in process
step = "Waiting for previous operations to terminate"
db_nsr_update[
"_admin.scaling-group.{}.time".format(admin_scale_index)
] = time()
+ nb_scale_op_update = True
# SCALE-IN VCA - BEGIN
if vca_scaling_info:
return
except (
ROclient.ROClientException,
+ NgRoException,
+ ) as e:
+ exe = "RO exception"
+ self.logger.error(logging_text + "Exit Exception {}".format(e))
+ exc = e
+ except (
DbException,
LcmException,
- NgRoException,
) as e:
self.logger.error(logging_text + "Exit Exception {}".format(e))
exc = e
current_operation_id=None,
other_update=db_nsr_update,
)
+ if exe:
+ if (
+ scaling_type == "SCALE_OUT"
+ and nb_scale_op_update
+ and exe == "RO exception"
+ ):
+ self.rollback_scaling(nsr_id, nslcmop_id)
if nslcmop_operation_state:
try: