X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=NG-RO%2Fosm_ng_ro%2Fns.py;h=ece7ee5bf2d55744d2dcf07a8058c859078ba693;hb=730cfaff466fb3c9b1446ecef5213916195ff861;hp=c6f918b27b9ee93dabd67df78585de7e0b3a5191;hpb=4bc8eb99dbadadf5013de93fcb424038149e1576;p=osm%2FRO.git diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index c6f918b2..ece7ee5b 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -722,9 +722,12 @@ class Ns(object): guest_epa_quota.get("cpu-pinning-policy") == "DEDICATED" and not epa_vcpu_set ): + # Pinning policy "REQUIRE" uses threads as host should support SMT architecture + # Pinning policy "ISOLATE" uses cores as host should not support SMT architecture + # Pinning policy "PREFER" uses threads in case host supports SMT architecture numa[ "cores" - if guest_epa_quota.get("cpu-thread-pinning-policy") != "PREFER" + if guest_epa_quota.get("cpu-thread-pinning-policy") == "ISOLATE" else "threads" ] = max(vcpu_count, 1) local_epa_vcpu_set = True @@ -859,44 +862,6 @@ class Ns(object): return extra_dict - @staticmethod - def _ip_profile_to_ro( - ip_profile: Dict[str, Any], - ) -> Dict[str, Any]: - """[summary] - - Args: - ip_profile (Dict[str, Any]): [description] - - Returns: - Dict[str, Any]: [description] - """ - if not ip_profile: - return None - - ro_ip_profile = { - "ip_version": "IPv4" - if "v4" in ip_profile.get("ip-version", "ipv4") - else "IPv6", - "subnet_address": ip_profile.get("subnet-address"), - "gateway_address": ip_profile.get("gateway-address"), - "dhcp_enabled": ip_profile.get("dhcp-params", {}).get("enabled", False), - "dhcp_start_address": ip_profile.get("dhcp-params", {}).get( - "start-address", None - ), - "dhcp_count": ip_profile.get("dhcp-params", {}).get("count", None), - } - - if ip_profile.get("dns-server"): - ro_ip_profile["dns_address"] = ";".join( - [v["address"] for v in ip_profile["dns-server"] if v.get("address")] - ) - - if ip_profile.get("security-group"): - ro_ip_profile["security_group"] = ip_profile["security-group"] - - return ro_ip_profile - @staticmethod def _process_net_params( target_vld: Dict[str, Any], @@ -949,7 +914,7 @@ class Ns(object): "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"], @@ -960,7 +925,7 @@ class Ns(object): "net_name": ( f"{indata.get('name')[:16]}-{target_vld.get('name', target_vld.get('id'))[:16]}" ), - "ip_profile": Ns._ip_profile_to_ro(vim_info.get("ip_profile")), + "ip_profile": vim_info.get("ip_profile"), "provider_network_profile": vim_info.get("provider_network"), } @@ -1009,12 +974,10 @@ class Ns(object): == "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"), @@ -1025,11 +988,11 @@ class Ns(object): return persistent_root_disk else: - if root_disk.get("size-of-storage"): persistent_root_disk[vsd["id"]] = { "image_id": vdu.get("sw-image-desc"), "size": root_disk.get("size-of-storage"), + "keep": Ns.is_volume_keeping_required(root_disk), } disk_list.append(persistent_root_disk[vsd["id"]]) @@ -1061,9 +1024,7 @@ class Ns(object): 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"], } @@ -1073,9 +1034,29 @@ class Ns(object): if disk["id"] not in persistent_disk.keys(): persistent_disk[disk["id"]] = { "size": disk.get("size-of-storage"), + "keep": Ns.is_volume_keeping_required(disk), } disk_list.append(persistent_disk[disk["id"]]) + @staticmethod + def is_volume_keeping_required(virtual_storage_desc: Dict[str, Any]) -> bool: + """Function to decide keeping persistent volume + upon VDU deletion. + + Args: + virtual_storage_desc (Dict[str, Any]): virtual storage description dictionary + + Returns: + bool (True/False) + """ + + if not virtual_storage_desc.get("vdu-storage-requirements"): + return False + for item in virtual_storage_desc.get("vdu-storage-requirements", {}): + if item.get("key") == "keep-volume" and item.get("value") == "true": + return True + return False + @staticmethod def _sort_vdu_interfaces(target_vdu: dict) -> None: """Sort the interfaces according to position number. @@ -1302,7 +1283,6 @@ class Ns(object): net_list (list): Net list of VDU """ for iface_index, interface in enumerate(target_vdu["interfaces"]): - net_text = Ns._check_vld_information_of_interfaces( interface, ns_preffix, vnf_preffix ) @@ -1397,13 +1377,13 @@ class Ns(object): if vdu["name"] == target_vdu["vdu-name"]: for vsd in vnfd.get("virtual-storage-desc", ()): root_disk = Ns._select_persistent_root_disk(vsd, vdu) - if not root_disk: continue persistent_root_disk[vsd["id"]] = { "image_id": vdu.get("sw-image-desc"), "size": root_disk["size-of-storage"], + "keep": Ns.is_volume_keeping_required(root_disk), } disk_list.append(persistent_root_disk[vsd["id"]]) @@ -1434,6 +1414,7 @@ class Ns(object): ): persistent_ordinary_disk[disk["id"]] = { "size": disk["size-of-storage"], + "keep": Ns.is_volume_keeping_required(disk), } disk_list.append(persistent_ordinary_disk[disk["id"]]) @@ -1503,13 +1484,13 @@ class Ns(object): vnf_preffix = "vnfrs:{}".format(vnfr_id) ns_preffix = "nsrs:{}".format(nsr_id) image_text = ns_preffix + ":image." + target_vdu["ns-image-id"] - flavor_text = ns_preffix + ":flavor." + target_vdu["ns-flavor-id"] - extra_dict = {"depends_on": [image_text, flavor_text]} + extra_dict = {"depends_on": [image_text]} net_list = [] persistent_root_disk = {} persistent_ordinary_disk = {} vdu_instantiation_volumes_list = [] + vdu_instantiation_flavor_id = None disk_list = [] vnfd_id = vnfr["vnfd-id"] vnfd = db.get_one("vnfds", {"_id": vnfd_id}) @@ -1520,13 +1501,11 @@ class Ns(object): True if i.get("position") is not None else False for i in target_vdu["interfaces"] ): - Ns._sort_vdu_interfaces(target_vdu) # If the position info is provided for some interfaces but not all of them, the interfaces # which has specific position numbers will be placed and others' positions will not be taken care. else: - Ns._partially_locate_vdu_interfaces(target_vdu) # If the position info is not provided for the interfaces, interfaces will be attached @@ -1549,11 +1528,21 @@ class Ns(object): if target_vdu.get("additionalParams"): vdu_instantiation_volumes_list = ( - target_vdu.get("additionalParams").get("OSM").get("vdu_volumes") + target_vdu.get("additionalParams").get("OSM", {}).get("vdu_volumes") + ) + vdu_instantiation_flavor_id = ( + target_vdu.get("additionalParams").get("OSM", {}).get("vim_flavor_id") ) - if vdu_instantiation_volumes_list: + # flavor id + if vdu_instantiation_flavor_id: + flavor_id = vdu_instantiation_flavor_id + else: + flavor_text = ns_preffix + ":flavor." + target_vdu["ns-flavor-id"] + flavor_id = "TASK-" + flavor_text + extra_dict["depends_on"].append(flavor_text) + if vdu_instantiation_volumes_list: # Find the root volumes and add to the disk_list persistent_root_disk = Ns.find_persistent_root_volumes( vnfd, target_vdu, vdu_instantiation_volumes_list, disk_list @@ -1593,7 +1582,7 @@ class Ns(object): "description": target_vdu["vdu-name"], "start": True, "image_id": "TASK-" + image_text, - "flavor_id": "TASK-" + flavor_text, + "flavor_id": flavor_id, "affinity_group_list": affinity_group_list, "net_list": net_list, "cloud_config": cloud_config or None, @@ -1679,7 +1668,6 @@ class Ns(object): 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") @@ -3008,7 +2996,6 @@ class Ns(object): task_index += 1 break else: - for vdu_index, vdu in enumerate(db_vnfr["vdur"]): extra_dict["params"] = { "vim_vm_id": vdu["vim-id"],