X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=RO-VIM-openstack%2Fosm_rovim_openstack%2Fvimconn_openstack.py;h=9e6f7aab633ff4b4ac6bf8ac83e95add6a84cef3;hb=0bb2d81cc74ef6f98500b7e89083b4f34dc5c41d;hp=fe7c847db80ef6d143c70fa90bd17bc4c6a089ca;hpb=cb767b954aaae6504bd6e3bc4a4f68692e89a8a9;p=osm%2FRO.git diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index fe7c847d..9e6f7aab 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -1287,16 +1287,17 @@ class vimconnector(vimconn.VimConnector): extra_specs (dict): To be filled. Returns: - vcpus (int) Number of virtual cpus + threads (int) Number of virtual cpus """ if not numa.get("paired-threads"): return + # cpu_thread_policy "require" implies that compute node must have an STM architecture - vcpus = numa["paired-threads"] * 2 + threads = numa["paired-threads"] * 2 extra_specs["hw:cpu_thread_policy"] = "require" extra_specs["hw:cpu_policy"] = "dedicated" - return vcpus + return threads @staticmethod def process_numa_cores(numa: dict, extra_specs: dict) -> Optional[int]: @@ -1306,17 +1307,17 @@ class vimconnector(vimconn.VimConnector): extra_specs (dict): To be filled. Returns: - vcpus (int) Number of virtual cpus + cores (int) Number of virtual cpus """ # cpu_thread_policy "isolate" implies that the host must not have an SMT # architecture, or a non-SMT architecture will be emulated if not numa.get("cores"): return - vcpus = numa["cores"] + cores = numa["cores"] extra_specs["hw:cpu_thread_policy"] = "isolate" extra_specs["hw:cpu_policy"] = "dedicated" - return vcpus + return cores @staticmethod def process_numa_threads(numa: dict, extra_specs: dict) -> Optional[int]: @@ -1326,37 +1327,33 @@ class vimconnector(vimconn.VimConnector): extra_specs (dict): To be filled. Returns: - vcpus (int) Number of virtual cpus + threads (int) Number of virtual cpus """ # cpu_thread_policy "prefer" implies that the host may or may not have an SMT architecture if not numa.get("threads"): return - vcpus = numa["threads"] + threads = numa["threads"] extra_specs["hw:cpu_thread_policy"] = "prefer" extra_specs["hw:cpu_policy"] = "dedicated" - return vcpus + return threads def _process_numa_parameters_of_flavor( - self, numas: List, extra_specs: Dict, vcpus: Optional[int] - ) -> int: + self, numas: List, extra_specs: Dict + ) -> None: """Process numa parameters and fill up extra_specs. Args: numas (list): List of dictionary which includes numa information extra_specs (dict): To be filled. - vcpus (int) Number of virtual cpus - - Returns: - vcpus (int) Number of virtual cpus """ numa_nodes = len(numas) extra_specs["hw:numa_nodes"] = str(numa_nodes) + cpu_cores, cpu_threads = 0, 0 if self.vim_type == "VIO": - extra_specs["vmware:extra_config"] = '{"numa.nodeAffinity":"0"}' - extra_specs["vmware:latency_sensitivity_level"] = "high" + self.process_vio_numa_nodes(numa_nodes, extra_specs) for numa in numas: if "id" in numa: @@ -1370,15 +1367,34 @@ class vimconnector(vimconn.VimConnector): extra_specs["hw:cpu_sockets"] = str(numa_nodes) if "paired-threads" in numa: - vcpus = self.process_numa_paired_threads(numa, extra_specs) + threads = self.process_numa_paired_threads(numa, extra_specs) + cpu_threads += threads elif "cores" in numa: - vcpus = self.process_numa_cores(numa, extra_specs) + cores = self.process_numa_cores(numa, extra_specs) + cpu_cores += cores elif "threads" in numa: - vcpus = self.process_numa_threads(numa, extra_specs) + threads = self.process_numa_threads(numa, extra_specs) + cpu_threads += threads + + if cpu_cores: + extra_specs["hw:cpu_cores"] = str(cpu_cores) + if cpu_threads: + extra_specs["hw:cpu_threads"] = str(cpu_threads) - return vcpus + @staticmethod + def process_vio_numa_nodes(numa_nodes: int, extra_specs: Dict) -> None: + """According to number of numa nodes, updates the extra_specs for VIO. + + Args: + + numa_nodes (int): List keeps the numa node numbers + extra_specs (dict): Extra specs dict to be updated + + """ + # If there are several numas, we do not define specific affinity. + extra_specs["vmware:latency_sensitivity_level"] = "high" def _change_flavor_name( self, name: str, name_suffix: int, flavor_data: dict @@ -1405,17 +1421,13 @@ class vimconnector(vimconn.VimConnector): return name def _process_extended_config_of_flavor( - self, extended: dict, extra_specs: dict, vcpus: Optional[int] - ) -> int: + self, extended: dict, extra_specs: dict + ) -> None: """Process the extended dict to fill up extra_specs. Args: - extended (dict): Keeping the extra specification of flavor - extra_specs (dict) Dict to be filled to be used during flavor creation - vcpus (int) Number of virtual cpus - - Returns: - vcpus (int) Number of virtual cpus + extended (dict): Keeping the extra specification of flavor + extra_specs (dict) Dict to be filled to be used during flavor creation """ quotas = { @@ -1441,7 +1453,7 @@ class vimconnector(vimconn.VimConnector): numas = extended.get("numas") if numas: - vcpus = self._process_numa_parameters_of_flavor(numas, extra_specs, vcpus) + self._process_numa_parameters_of_flavor(numas, extra_specs) for quota, item in quotas.items(): if quota in extended.keys(): @@ -1462,8 +1474,6 @@ class vimconnector(vimconn.VimConnector): if extended.get(policy): extra_specs[hw_policy] = extended[policy].lower() - return vcpus - @staticmethod def _get_flavor_details(flavor_data: dict) -> Tuple: """Returns the details of flavor @@ -1513,9 +1523,7 @@ class vimconnector(vimconn.VimConnector): flavor_data ) if extended: - vcpus = self._process_extended_config_of_flavor( - extended, extra_specs, vcpus - ) + self._process_extended_config_of_flavor(extended, extra_specs) # Create flavor @@ -2186,6 +2194,7 @@ class vimconnector(vimconn.VimConnector): existing_vim_volumes: list, created_items: dict, vm_av_zone: list, + block_device_mapping: dict, disk_list: list = None, ) -> None: """Prepare all volumes for new VM instance. @@ -2195,6 +2204,7 @@ class vimconnector(vimconn.VimConnector): existing_vim_volumes (list): List of existing volumes created_items (dict): All created items belongs to VM vm_av_zone (list): VM availability zone + block_device_mapping (dict): Block devices to be attached to VM disk_list (list): List of disks """ @@ -2203,7 +2213,6 @@ class vimconnector(vimconn.VimConnector): boot_volume_id = None elapsed_time = 0 - block_device_mapping = {} for disk in disk_list: if "image_id" in disk: # Root persistent volume @@ -2612,7 +2621,7 @@ class vimconnector(vimconn.VimConnector): external_network = [] # List of ports with port-security disabled no_secured_ports = [] - block_device_mapping = None + block_device_mapping = {} existing_vim_volumes = [] server_group_id = None scheduller_hints = {} @@ -2645,6 +2654,7 @@ class vimconnector(vimconn.VimConnector): existing_vim_volumes=existing_vim_volumes, created_items=created_items, vm_av_zone=vm_av_zone, + block_device_mapping=block_device_mapping, disk_list=disk_list, )