- if db_nsir.get("_admin"):
- if db_nsir["_admin"].get("deployed"):
- db_admin_deployed_nsir = db_nsir["_admin"].get("deployed")
- if db_admin_deployed_nsir.get("RO"):
- RO_list = db_admin_deployed_nsir["RO"]
-
- for RO_item in RO_list:
- for netslice_vld in get_iterable(db_nsir["_admin"], "netslice-vld"):
- # if is equal vld of _admin with vld of netslice-vld then go for the CPs
- if RO_item.get("vld_id") == netslice_vld.get("id"):
- # Search the cp of netslice-vld that match with nst:netslice-subnet
- for nss_cp_item in get_iterable(netslice_vld, "nss-connection-point-ref"):
- # Search the netslice-subnet of nst that match
- for nss in get_iterable(db_nsir["_admin"], "netslice-subnet"):
- # Compare nss-ref equal nss from nst
- if nss_cp_item["nss-ref"] == nss["nss-id"]:
- db_nsds = self.db.get_one("nsds", {"_id": nss["nsdId"]})
- # Go for nsd, and search the CP that match with nst:CP to get vld-id-ref
- for cp_nsd in db_nsds.get("connection-point", ()):
- if cp_nsd["name"] == nss_cp_item["nsd-connection-point-ref"]:
- if nslcmop.get("operationParams"):
- if nslcmop["operationParams"].get("nsName") == nss["nsName"]:
- vld_id = RO_item["vld_id"]
- netslice_scenario_id = RO_item["netslice_scenario_id"]
- nslcmop_vld = {}
- nslcmop_vld["ns-net"] = {vld_id: netslice_scenario_id}
- nslcmop_vld["name"] = cp_nsd["vld-id-ref"]
- for vld in get_iterable(nslcmop["operationParams"], "vld"):
- if vld["name"] == cp_nsd["vld-id-ref"]:
- nslcmop_vld.update(vld)
- vld_op_list.append(nslcmop_vld)
+ RO_list = db_nsir_admin["deployed"]["RO"]
+
+ for ro_item_index, RO_item in enumerate(RO_list):
+ netslice_vld = next((n for n in get_iterable(db_nsir["_admin"], "netslice-vld")
+ if RO_item.get("vld_id") == n.get("id")), None)
+ if not netslice_vld:
+ continue
+ # if is equal vld of _admin with vld of netslice-vld then go for the CPs
+ # Search the cp of netslice-vld that match with nst:netslice-subnet
+ for nss_cp_item in get_iterable(netslice_vld, "nss-connection-point-ref"):
+ # Search the netslice-subnet of nst that match
+ nss = next((nss for nss in get_iterable(db_nsir["_admin"], "netslice-subnet")
+ if nss_cp_item["nss-ref"] == nss["nss-id"]), None)
+ # Compare nss-ref equal nss from nst
+ if not nss:
+ continue
+ db_nsds = self.db.get_one("nsds", {"_id": nss["nsdId"]})
+ # Go for nsd, and search the CP that match with nst:CP to get vld-id-ref
+ for cp_nsd in db_nsds.get("sapd", ()):
+ if cp_nsd["id"] == nss_cp_item["nsd-connection-point-ref"]:
+ if nslcmop.get("operationParams"):
+ if nslcmop["operationParams"].get("nsName") == nss["nsName"]:
+ vld_id = RO_item["vld_id"]
+ netslice_scenario_id = RO_item["netslice_scenario_id"]
+ nslcmop_vld = {}
+ nslcmop_vld["name"] = cp_nsd["virtual-link-desc"]
+ for vld in get_iterable(nslcmop["operationParams"], "vld"):
+ if vld["name"] == cp_nsd["virtual-link-desc"]:
+ nslcmop_vld.update(vld)
+ if self.ro_config["ng"]:
+ nslcmop_vld["common_id"] = netslice_scenario_id
+ nslcmop_vld.update(nsi_vld_instantiationi_params.get(RO_item["vld_id"], {}))
+ else:
+ nslcmop_vld["ns-net"] = {vld_id: netslice_scenario_id}
+ vld_op_list.append(nslcmop_vld)