X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=RO-VIM-openstack%2Fosm_rovim_openstack%2Fvimconn_openstack.py;h=25e58d57b31411df555edcd0baba0bd941b9e131;hb=6986244790d12f4ce734fd5cd2599e84b29c3f84;hp=7c57817c11d72eed4c5752a02c4d10530a48fe66;hpb=4415c4cc1eb8032f0d6a5f49fba297992b355c42;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 7c57817c..25e58d57 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,38 @@ 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) + + @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. - return vcpus + Args: + + numa_nodes (int): List keeps the numa node numbers + extra_specs (dict): Extra specs dict to be updated + + """ + # If there is not any numa, numas_nodes equals to 0. + if not numa_nodes: + extra_specs["vmware:extra_config"] = '{"numa.nodeAffinity":"0"}' + + # 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 +1425,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 +1457,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 +1478,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 +1527,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 @@ -1536,7 +1548,6 @@ class vimconnector(vimconn.VimConnector): return new_flavor.id except nvExceptions.Conflict as e: - if change_name_if_used and retry < max_retries: continue @@ -1880,7 +1891,6 @@ class vimconnector(vimconn.VimConnector): # For VF elif net["type"] == "VF" or net["type"] == "SR-IOV": - port_dict["binding:vnic_type"] = "direct" # VIO specific Changes @@ -2068,7 +2078,6 @@ class vimconnector(vimconn.VimConnector): key_id = "vim_volume_id" if "vim_volume_id" in disk.keys() else "vim_id" if disk.get(key_id): - block_device_mapping["vd" + chr(base_disk_index)] = disk[key_id] existing_vim_volumes.append({"id": disk[key_id]}) @@ -2148,7 +2157,6 @@ class vimconnector(vimconn.VimConnector): key_id = "vim_volume_id" if "vim_volume_id" in disk.keys() else "vim_id" if disk.get(key_id): - # Use existing persistent volume block_device_mapping["vd" + chr(base_disk_index)] = disk[key_id] existing_vim_volumes.append({"id": disk[key_id]}) @@ -2479,7 +2487,6 @@ class vimconnector(vimconn.VimConnector): # In case of RO in HA there can be conflicts, two RO trying to assign same floating IP, so retry # several times while not assigned: - free_floating_ip = self._get_free_floating_ip( server, floating_network ) @@ -2576,7 +2583,6 @@ class vimconnector(vimconn.VimConnector): self.neutron.update_port(port[0], port_update) except Exception: - raise vimconn.VimConnException( "It was not possible to disable port security for port {}".format( port[0] @@ -2883,7 +2889,6 @@ class vimconnector(vimconn.VimConnector): k_id (str): Port id in the VIM """ try: - port_dict = self.neutron.list_ports() existing_ports = [port["id"] for port in port_dict["ports"] if port_dict] @@ -2891,7 +2896,6 @@ class vimconnector(vimconn.VimConnector): self.neutron.delete_port(k_id) except Exception as e: - self.logger.error("Error deleting port: {}: {}".format(type(e).__name__, e)) def _delete_volumes_by_id_wth_cinder( @@ -2973,7 +2977,6 @@ class vimconnector(vimconn.VimConnector): k_item, k_id = self._get_item_name_id(k) if k_item == "volume": - unavailable_vol = self._delete_volumes_by_id_wth_cinder( k, k_id, volumes_to_hold, created_items ) @@ -2982,7 +2985,6 @@ class vimconnector(vimconn.VimConnector): keep_waiting = True elif k_item == "floating_ip": - self._delete_floating_ip_by_id(k, k_id, created_items) except Exception as e: @@ -3204,7 +3206,8 @@ class vimconnector(vimconn.VimConnector): def action_vminstance(self, vm_id, action_dict, created_items={}): """Send and action over a VM instance from VIM - Returns None or the console dict if the action was successfully sent to the VIM""" + Returns None or the console dict if the action was successfully sent to the VIM + """ self.logger.debug("Action over VM '%s': %s", vm_id, str(action_dict)) try: