- if mgmt_network:
- RO_ns_params["scenario"] = {"nets": [{"name": vld_item["name"],
- "external": True, "type": "bridge"}]}
- else:
- RO_ns_params["scenario"] = {"nets": [{"name": vld_item["name"],
- "external": False, "type": "bridge"}]}
-
- # Creating netslice-vld at RO
- RO_nsir_id = db_nsir["_admin"].get("deployed", {}).get("RO", {}).get("nsir_id")
-
- # if RO vlds are present use it unless in error status
- if RO_nsir_id:
- try:
- step = db_nsir_update["detailed-status"] = "Looking for existing ns at RO"
- self.logger.debug(logging_text + step + " RO_ns_id={}".format(RO_nsir_id))
- desc = await RO.show("ns", RO_nsir_id)
- except ROclient.ROClientException as e:
- if e.http_code != HTTPStatus.NOT_FOUND:
- raise
- RO_nsir_id = db_nsir_update["_admin.deployed.RO.nsir_id"] = None
- if RO_nsir_id:
- ns_status, ns_status_info = RO.check_ns_status(desc)
- db_nsir_update["_admin.deployed.RO.nsir_status"] = ns_status
- if ns_status == "ERROR":
- step = db_nsir_update["detailed-status"] = "Deleting ns at RO. RO_ns_id={}"\
- .format(RO_nsir_id)
- self.logger.debug(logging_text + step)
- await RO.delete("ns", RO_nsir_id)
- RO_nsir_id = db_nsir_update["_admin.deployed.RO.nsir_id"] = None
-
- # If network doesn't exists then create it
- else:
- step = db_nsir_update["detailed-status"] = "Checking dependencies"
- self.logger.debug(logging_text + step)
- # check if VIM is creating and wait look if previous tasks in process
- # TODO: Check the case for multiple datacenters specified in instantiation parameter
- for vimAccountId_unit in RO_ns_params["datacenter"]:
- task_name, task_dependency = self.lcm_tasks.lookfor_related("vim_account",
- vimAccountId_unit)
- if task_dependency:
- step = "Waiting for related tasks to be completed: {}".format(task_name)
- self.logger.debug(logging_text + step)
- await asyncio.wait(task_dependency, timeout=3600)
-
- step = db_nsir_update["detailed-status"] = "Creating netslice-vld at RO"
- desc = await RO.create("ns", descriptor=RO_ns_params)
- RO_nsir_id = db_nsir_update["_admin.deployed.RO.nsir_id"] = desc["uuid"]
- db_nsir_update["_admin.nsState"] = "INSTANTIATED"
- db_nsir_update["_admin.deployed.RO.nsir_status"] = "BUILD"
- self.logger.debug(logging_text + "netslice-vld created at RO. RO_id={}".format(desc["uuid"]))
- self.update_db_2("nsis", nsir_id, db_nsir_update)
+ for nss_conn_point_ref in get_iterable(netslice_vld, "nss-connection-point-ref"):
+ if nss_conn_point_ref.get("vimAccountId"):
+ if nss_conn_point_ref["vimAccountId"] != netslice_vld["vimAccountId"]:
+ RO_vld_sites.append({
+ "netmap-create": None,
+ "datacenter": vim_account_2_RO(nss_conn_point_ref["vimAccountId"])})
+
+ if vld_shared:
+ populate_dict(RO_ns_params, ("networks", netslice_vld["name"], "use-network"), vld_shared)
+
+ if RO_vld_sites:
+ populate_dict(RO_ns_params, ("networks", netslice_vld["name"], "sites"), RO_vld_sites)
+
+ RO_ns_params["scenario"] = {"nets": [{"name": netslice_vld["name"],
+ "external": mgmt_network, "type": "bridge"}]}
+
+ # self.logger.debug(logging_text + step)
+ desc = await RO.create("ns", descriptor=RO_ns_params)
+ db_nsir_update_RO["netslice_scenario_id"] = desc["uuid"]
+ db_nsir_update["_admin.deployed.RO"].append(db_nsir_update_RO)
+
+ def overwrite_nsd_params(self, db_nsir, nslcmop):
+ nonlocal nsi_vld_instantiationi_params
+ nonlocal db_nsir_update
+ vld_op_list = []
+ vld = None
+ nsr_id = nslcmop.get("nsInstanceId")
+ # Overwrite instantiation parameters in netslice runtime
+ 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)
+ nslcmop["operationParams"]["vld"] = vld_op_list
+ self.update_db_2("nslcmops", nslcmop["_id"], {"operationParams.vld": vld_op_list})
+ return nsr_id, nslcmop