db_nslcmop = None
db_nslcmop_update = {}
nslcmop_operation_state = None
+ old_db_update = {}
+ q_filter = {}
+ old_vdu_index = None
+ old_flavor_id = None
db_nsr_update = {}
target = {}
exc = None
)
db_nslcmop = self.db.get_one("nslcmops", {"_id": nslcmop_id})
operationParams = db_nslcmop.get("operationParams")
+ # Update the VNFRS and NSRS with the requested flavour detail, So that ro tasks can function properly
+ db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+ db_flavor = db_nsr.get("flavor")
+ db_flavor_index = str(len(db_flavor))
+ change_vnf_flavor_data = operationParams["changeVnfFlavorData"]
+ flavor_dict = change_vnf_flavor_data["additionalParams"]
+ count_index = flavor_dict["vduCountIndex"]
+ vdu_id_ref = flavor_dict["vduid"]
+ flavor_dict_update = {
+ "id": db_flavor_index,
+ "memory-mb": flavor_dict["virtualMemory"],
+ "name": f"{vdu_id_ref}-{count_index}-flv",
+ "storage-gb": flavor_dict["sizeOfStorage"],
+ "vcpu-count": flavor_dict["numVirtualCpu"],
+ }
+ db_flavor.append(flavor_dict_update)
+ db_update = {}
+ db_update["flavor"] = db_flavor
+ ns_q_filter = {
+ "_id": nsr_id,
+ }
+ self.db.set_one(
+ "nsrs",
+ q_filter=ns_q_filter,
+ update_dict=db_update,
+ fail_on_empty=True,
+ )
+ db_vnfr = self.db.get_one(
+ "vnfrs", {"_id": change_vnf_flavor_data["vnfInstanceId"]}
+ )
+ for vdu_index, vdur in enumerate(db_vnfr.get("vdur", ())):
+ if (
+ vdur.get("count-index") == count_index
+ and vdur.get("vdu-id-ref") == vdu_id_ref
+ ):
+ old_flavor_id = vdur.get("ns-flavor-id", 0)
+ old_vdu_index = vdu_index
+ filter_text = {
+ "_id": change_vnf_flavor_data["vnfInstanceId"],
+ "vdur.count-index": count_index,
+ "vdur.vdu-id-ref": vdu_id_ref,
+ }
+ q_filter.update(filter_text)
+ db_update = {}
+ db_update[
+ "vdur.{}.ns-flavor-id".format(vdu_index)
+ ] = db_flavor_index
+ self.db.set_one(
+ "vnfrs",
+ q_filter=q_filter,
+ update_dict=db_update,
+ fail_on_empty=True,
+ )
target = {}
target.update(operationParams)
desc = await self.RO.vertical_scale(nsr_id, target)
self.timeout.verticalscale,
operation="verticalscale",
)
- except (ROclient.ROClientException, DbException, LcmException) as e:
+ except (
+ NgRoException,
+ ROclient.ROClientException,
+ DbException,
+ LcmException,
+ ) as e:
self.logger.error("Exit Exception {}".format(e))
exc = e
except asyncio.CancelledError:
if exc:
db_nslcmop_update["detailed-status"] = "FAILED {}: {}".format(step, exc)
nslcmop_operation_state = "FAILED"
+ old_db_update[
+ "vdur.{}.ns-flavor-id".format(old_vdu_index)
+ ] = old_flavor_id
else:
nslcmop_operation_state = "COMPLETED"
db_nslcmop_update["detailed-status"] = "Done"
operation_state=nslcmop_operation_state,
other_update=db_nslcmop_update,
)
+ if old_vdu_index and old_db_update != {}:
+ self.logger.critical(
+ "Reverting Old Flavor -- : {}".format(old_db_update)
+ )
+ self.db.set_one(
+ "vnfrs",
+ q_filter=q_filter,
+ update_dict=old_db_update,
+ fail_on_empty=True,
+ )
if nslcmop_operation_state:
try:
msg = {