def _assert_kernel_vs_running_config(self): """ This is a special test, that checks setup integrity through non vdsm api data. The networking configuration relies on a semi-persistent running configuration files, describing the requested configuration. This configuration is checked against the actual caps report. """ running_config = kernelconfig.normalize(self.running_config) running_config = running_config.as_unicode() netinfo = _normalize_caps(self.netinfo) kernel_config = kernelconfig.KernelConfig(netinfo) _extend_with_bridge_opts(kernel_config, running_config) kernel_config = kernel_config.as_unicode() _normalize_bonds((kernel_config, running_config)) self._assert_inclusive_nameservers(kernel_config, running_config) # Do not use KernelConfig.__eq__ to get a better exception if something # breaks. assert running_config['networks'] == kernel_config['networks'] if vdsm_config.getboolean('vars', 'net_nmstate_enabled'): self._assert_inclusive_bond_options(kernel_config, running_config) assert running_config['bonds'] == kernel_config['bonds']
def setup(networks, bondings, options, net_info, in_rollback): if vdsm_config.getboolean('vars', 'net_nmstate_enabled'): _setup_nmstate(networks, bondings, options, in_rollback) else: _setup(networks, bondings, options, in_rollback, net_info) if options.get('commitOnSuccess'): persist()
def get_dpdk_devices(): if not config.getboolean('vars', 'dpdk_enable'): return {} dpdk_devices = _get_dpdk_devices() if not _dpdk_devs_current(dpdk_devices): invalidate_dpdk_devices() dpdk_devices = _get_dpdk_devices() return dpdk_devices
def domain_cpu_models(conn, arch, cpu_mode): """ Parse libvirt domain capabilities to get cpu models known by the hypervisor along with usability status. Arguments: conn(libvirtconnection) - libvirt connection object for the hypervisor to be queried for CPU models. arch(string) - CPU architecture, one of cpuarch constants cpu_mode(string) - CPU mode, one of _CpuMode constants; _CpuMode.HOST_MODEL is used on POWER, _CpuMode.CUSTOM on other architectures Returns: {str: str} - mapping where key is CPU model and value is one of 'yes', 'no' or 'unknown', showing whether the particular model can be used on this hypervisor. Example: {'z13' : 'unknown', 'zEC12': 'no', 'z196': 'yes'} """ if config.getboolean('vars', 'fake_kvm_support'): virt_type = 'qemu' else: virt_type = 'kvm' try: domcaps = conn.getDomainCapabilities(None, arch, None, virt_type, 0) except libvirt.libvirtError: logging.exception('Error while getting domain capabilities') return {} if not domcaps: logging.error('Error while getting CPU models: ' 'no domain capabilities found') return {} xmldomcaps = ET.fromstring(domcaps) cpucaps = xmldomcaps.find('cpu') if cpucaps is None: logging.error('Error while getting CPU models: ' 'no domain CPU capabilities found') return {} dom_models = dict() for mode in cpucaps.findall('mode'): if mode.get('name') == cpu_mode and mode.get('supported') == 'yes': for model in mode.findall('model'): if cpu_mode == _CpuMode.CUSTOM: usable = model.get('usable') else: usable = 'yes' if model.text: dom_models[model.text] = usable logging.debug('Supported CPU models: %s', dom_models) return dom_models
def domain_cpu_models(conn, arch, cpu_mode): """ Parse libvirt domain capabilities to get cpu models known by the hypervisor along with usability status. Arguments: conn(libvirtconnection) - libvirt connection object for the hypervisor to be queried for CPU models. arch(string) - CPU architecture, one of cpuarch constants cpu_mode(string) - CPU mode, one of _CpuMode constants; _CpuMode.HOST_MODEL is used on POWER, _CpuMode.CUSTOM on other architectures Returns: {str: str} - mapping where key is CPU model and value is one of 'yes', 'no' or 'unknown', showing whether the particular model can be used on this hypervisor. Example: {'z13' : 'unknown', 'zEC12': 'no', 'z196': 'yes'} """ if config.getboolean('vars', 'fake_kvm_support'): virt_type = 'qemu' else: virt_type = 'kvm' domcaps = conn.getDomainCapabilities(None, arch, None, virt_type, 0) if not domcaps: logging.error('Error while getting CPU models: ' 'no domain capabilities found') return {} xmldomcaps = ET.fromstring(domcaps) cpucaps = xmldomcaps.find('cpu') if cpucaps is None: logging.error('Error while getting CPU models: ' 'no domain CPU capabilities found') return {} dom_models = dict() for mode in cpucaps.findall('mode'): if mode.get('name') == cpu_mode and mode.get('supported') == 'yes': for model in mode.findall('model'): if cpu_mode == _CpuMode.CUSTOM: usable = model.get('usable') else: usable = 'yes' if model.text: dom_models[model.text] = usable logging.debug('Supported CPU models: %s', dom_models) return dom_models
def _lldp_init(): """" Enables receiving of LLDP frames for all nics. If sending or receiving LLDP frames is already enabled on a nic, it is not modified. """ if not config.getboolean('vars', 'enable_lldp'): logging.warning('LLDP is disabled') return if Lldp.is_active(): for device in (link for link in getLinks() if link.isNIC()): if not Lldp.is_lldp_enabled_on_iface(device.name): try: Lldp.enable_lldp_on_iface(device.name) except lldp.EnableLldpError: logging.warning('Ignoring failure to enable LLDP on %s', device.name, exc_info=True) else: logging.warning('LLDP is inactive, skipping LLDP initialization')
def _get_domain_capabilities(conn, arch): """ Read libvirt domain capabilities and parse them. Arguments: conn(libvirtconnection) - libvirt connection object for the hypervisor to be queried for CPU models. arch(string) - CPU architecture, one of cpuarch constants Returns: ET.Element instance of dom capabilities or None """ if config.getboolean('vars', 'fake_kvm_support'): virt_type = 'qemu' else: virt_type = 'kvm' try: domcaps = conn.getDomainCapabilities(None, arch, None, virt_type, 0) except libvirt.libvirtError: logging.exception('Error while getting domain capabilities') return None return ET.fromstring(domcaps)
class GlusterStorageDomain(nfsSD.NfsStorageDomain): if config.getboolean("gluster", "enable_4k_storage"): supported_block_size = (sc.BLOCK_SIZE_AUTO, sc.BLOCK_SIZE_512, sc.BLOCK_SIZE_4K) @classmethod def getMountPoint(cls, mountPath): return os.path.join(sc.REPO_MOUNT_DIR, sd.GLUSTERSD_DIR, mountPath) def getVolumeClass(self): return glusterVolume.GlusterVolume @staticmethod def findDomainPath(sdUUID): glusterDomPath = os.path.join(sd.GLUSTERSD_DIR, "*") for tmpSdUUID, domainPath in fileSD.scanDomains(glusterDomPath): if tmpSdUUID == sdUUID: mountpoint = os.path.dirname(domainPath) if mount.isMounted(mountpoint): return domainPath raise se.StorageDomainDoesNotExist(sdUUID)
def is_nmstate_enabled(): return vdsm_config.getboolean('vars', 'net_nmstate_enabled')