Tuple[Dict[str, Any], bool]: [description]
"""
numa = {}
+ numa_list = []
epa_vcpu_set = False
if guest_epa_quota.get("numa-node-policy"):
numa_node_policy = guest_epa_quota.get("numa-node-policy")
if numa_node_policy.get("node"):
- numa_node = numa_node_policy["node"][0]
-
- if numa_node.get("num-cores"):
- numa["cores"] = numa_node["num-cores"]
- epa_vcpu_set = True
-
- paired_threads = numa_node.get("paired-threads", {})
- if paired_threads.get("num-paired-threads"):
- numa["paired-threads"] = int(
- numa_node["paired-threads"]["num-paired-threads"]
- )
- epa_vcpu_set = True
+ for numa_node in numa_node_policy["node"]:
+ vcpu_list = []
+ if numa_node.get("id"):
+ numa["id"] = int(numa_node["id"])
+
+ if numa_node.get("vcpu"):
+ for vcpu in numa_node.get("vcpu"):
+ vcpu_id = int(vcpu.get("id"))
+ vcpu_list.append(vcpu_id)
+ numa["vcpu"] = vcpu_list
+
+ if numa_node.get("num-cores"):
+ numa["cores"] = numa_node["num-cores"]
+ epa_vcpu_set = True
+
+ paired_threads = numa_node.get("paired-threads", {})
+ if paired_threads.get("num-paired-threads"):
+ numa["paired_threads"] = int(
+ numa_node["paired-threads"]["num-paired-threads"]
+ )
+ epa_vcpu_set = True
- if paired_threads.get("paired-thread-ids"):
- numa["paired-threads-id"] = []
+ if paired_threads.get("paired-thread-ids"):
+ numa["paired-threads-id"] = []
- for pair in paired_threads["paired-thread-ids"]:
- numa["paired-threads-id"].append(
- (
- str(pair["thread-a"]),
- str(pair["thread-b"]),
+ for pair in paired_threads["paired-thread-ids"]:
+ numa["paired-threads-id"].append(
+ (
+ str(pair["thread-a"]),
+ str(pair["thread-b"]),
+ )
)
- )
- if numa_node.get("num-threads"):
- numa["threads"] = int(numa_node["num-threads"])
- epa_vcpu_set = True
+ if numa_node.get("num-threads"):
+ numa["threads"] = int(numa_node["num-threads"])
+ epa_vcpu_set = True
- if numa_node.get("memory-mb"):
- numa["memory"] = max(int(int(numa_node["memory-mb"]) / 1024), 1)
+ if numa_node.get("memory-mb"):
+ numa["memory"] = max(int(int(numa_node["memory-mb"]) / 1024), 1)
- return numa, epa_vcpu_set
+ numa_list.append(numa)
+ numa = {}
+
+ return numa_list, epa_vcpu_set
@staticmethod
def _process_guest_epa_cpu_pinning_params(
"""
extended = {}
numa = {}
+ numa_list = []
if target_flavor.get("guest-epa"):
guest_epa = target_flavor["guest-epa"]
- numa, epa_vcpu_set = Ns._process_guest_epa_numa_params(
+ numa_list, epa_vcpu_set = Ns._process_guest_epa_numa_params(
guest_epa_quota=guest_epa
)
if guest_epa.get("mempage-size"):
extended["mempage-size"] = guest_epa.get("mempage-size")
+ if guest_epa.get("cpu-pinning-policy"):
+ extended["cpu-pinning-policy"] = guest_epa.get("cpu-pinning-policy")
+
+ if guest_epa.get("cpu-thread-pinning-policy"):
+ extended["cpu-thread-pinning-policy"] = guest_epa.get(
+ "cpu-thread-pinning-policy"
+ )
+
+ if guest_epa.get("numa-node-policy"):
+ if guest_epa.get("numa-node-policy").get("mem-policy"):
+ extended["mem-policy"] = guest_epa.get("numa-node-policy").get(
+ "mem-policy"
+ )
+
tmp_numa, epa_vcpu_set = Ns._process_guest_epa_cpu_pinning_params(
guest_epa_quota=guest_epa,
vcpu_count=int(target_flavor.get("vcpu-count", 1)),
epa_vcpu_set=epa_vcpu_set,
)
- numa.update(tmp_numa)
+ for numa in numa_list:
+ numa.update(tmp_numa)
extended.update(
Ns._process_guest_epa_quota_params(
)
if numa:
- extended["numas"] = [numa]
+ extended["numas"] = numa_list
return extended
"id": vim_info.get("vim_network_id"),
},
}
- elif target_vld.get("mgmt-network"):
+ elif target_vld.get("mgmt-network") and not vim_info.get("provider_network"):
extra_dict["find_params"] = {
"mgmt": True,
"name": target_vld["id"],
== "persistent-storage:persistent-storage"
):
for vdu_volume in vdu_instantiation_volumes_list:
-
if (
vdu_volume["vim-volume-id"]
and root_disk["id"] == vdu_volume["name"]
):
-
persistent_root_disk[vsd["id"]] = {
"vim_volume_id": vdu_volume["vim-volume-id"],
"image_id": vdu.get("sw-image-desc"),
return disk_list, persistent_root_disk
else:
-
if root_disk.get("size-of-storage"):
persistent_root_disk[vsd["id"]] = {
"image_id": vdu.get("sw-image-desc"),
and disk["id"] not in persistent_root_disk.keys()
):
for vdu_volume in vdu_instantiation_volumes_list:
-
if vdu_volume["vim-volume-id"] and disk["id"] == vdu_volume["name"]:
-
persistent_disk[disk["id"]] = {
"vim_volume_id": vdu_volume["vim-volume-id"],
}
)
if vdu_instantiation_volumes_list:
-
# Find the root volumes and add to the disk_list
- (disk_list, persistent_root_disk,) = Ns.find_persistent_root_volumes(
+ (
+ disk_list,
+ persistent_root_disk,
+ ) = Ns.find_persistent_root_volumes(
vnfd, target_vdu, vdu_instantiation_volumes_list, disk_list
)
)
else:
-
# vdu_instantiation_volumes_list is empty
for vdu in vnfd.get("vdu", ()):
if vdu["name"] == target_vdu["vdu-name"]:
vim_details = yaml.safe_load(f"{vim_details_text}")
for iface_index, interface in enumerate(existing_vdu["interfaces"]):
-
if "port-security-enabled" in interface:
interface["port_security"] = interface.pop("port-security-enabled")
# Check each VNF of the target
for target_vnf in target_list:
- # Find this VNF in the list from DB
- vnfr_id = target_vnf.get("vnfInstanceId", None)
- if vnfr_id:
- existing_vnf = db_vnfrs.get(vnfr_id)
- db_record = "vnfrs:{}:{}".format(vnfr_id, db_path)
- # vim_account_id = existing_vnf.get("vim-account-id", "")
+ # Find this VNF in the list from DB, raise exception if vnfInstanceId is not found
+ vnfr_id = target_vnf["vnfInstanceId"]
+ existing_vnf = db_vnfrs.get(vnfr_id)
+ db_record = "vnfrs:{}:{}".format(vnfr_id, db_path)
+ # vim_account_id = existing_vnf.get("vim-account-id", "")
+ target_vdus = target_vnf.get("additionalParams", {}).get("vdu", [])
# Check each VDU of this VNF
- for target_vdu in target_vnf["additionalParams"].get("vdu", None):
+ if not target_vdus:
+ # Create target_vdu_list from DB, if VDUs are not specified
+ target_vdus = []
+ for existing_vdu in existing_vnf.get("vdur"):
+ vdu_name = existing_vdu.get("vdu-name", None)
+ vdu_index = existing_vdu.get("count-index", 0)
+ vdu_to_be_healed = {"vdu-id": vdu_name, "count-index": vdu_index}
+ target_vdus.append(vdu_to_be_healed)
+ for target_vdu in target_vdus:
vdu_name = target_vdu.get("vdu-id", None)
# For multi instance VDU count-index is mandatory
# For single session VDU count-indes is 0
task_index += 1
break
else:
-
for vdu_index, vdu in enumerate(db_vnfr["vdur"]):
extra_dict["params"] = {
"vim_vm_id": vdu["vim-id"],