def get(): caps = {} caps['kvmEnabled'] = \ str(config.getboolean('vars', 'fake_kvm_support') or os.path.exists('/dev/kvm')).lower() cpuInfo = CpuInfo() caps['cpuCores'] = str(cpuInfo.cores()) caps['cpuSockets'] = str(cpuInfo.sockets()) caps['cpuSpeed'] = cpuInfo.mhz() if config.getboolean('vars', 'fake_kvm_support'): caps['cpuModel'] = 'Intel(Fake) CPU' flags = set(cpuInfo.flags() + ['vmx', 'sse2', 'nx']) caps['cpuFlags'] = ','.join(flags) + 'model_486,model_pentium,' \ 'model_pentium2,model_pentium3,model_pentiumpro,model_qemu32,' \ 'model_coreduo,model_core2duo,model_n270,model_Conroe,' \ 'model_Penryn,model_Nehalem,model_Opteron_G1' else: caps['cpuModel'] = cpuInfo.model() caps['cpuFlags'] = ','.join(cpuInfo.flags() + _getCompatibleCpuModels()) caps.update(dsaversion.version_info) caps.update(netinfo.get()) try: caps['hooks'] = hooks.installed() except: logging.debug('not reporting hooks', exc_info=True) caps['operatingSystem'] = osversion() caps['uuid'] = utils.getHostUUID() caps['packages2'] = _getKeyPackages() caps['emulatedMachines'] = _getEmulatedMachines() caps['ISCSIInitiatorName'] = _getIscsiIniName() caps['HBAInventory'] = storage.hba.HBAInventory() caps['vmTypes'] = ['kvm'] caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024) caps['reservedMem'] = str( config.getint('vars', 'host_mem_reserve') + config.getint('vars', 'extra_mem_reserve')) caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead') return caps
def get(): caps = {} caps['kvmEnabled'] = \ str(config.getboolean('vars', 'fake_kvm_support') or os.path.exists('/dev/kvm')).lower() cpuInfo = CpuInfo() caps['cpuCores'] = str(cpuInfo.cores()) caps['cpuSockets'] = str(cpuInfo.sockets()) caps['cpuSpeed'] = cpuInfo.mhz() if config.getboolean('vars', 'fake_kvm_support'): caps['cpuModel'] = 'Intel(Fake) CPU' flags = set(cpuInfo.flags() + ['vmx', 'sse2', 'nx']) caps['cpuFlags'] = ','.join(flags) + 'model_486,model_pentium,' \ 'model_pentium2,model_pentium3,model_pentiumpro,model_qemu32,' \ 'model_coreduo,model_core2duo,model_n270,model_Conroe,' \ 'model_Penryn,model_Nehalem,model_Opteron_G1' else: caps['cpuModel'] = cpuInfo.model() caps['cpuFlags'] = ','.join(cpuInfo.flags() + _getCompatibleCpuModels()) caps.update(dsaversion.version_info) caps.update(netinfo.get()) try: caps['hooks'] = hooks.installed() except: logging.debug('not reporting hooks', exc_info=True) caps['operatingSystem'] = osversion() caps['uuid'] = utils.getHostUUID() caps['packages2'] = _getKeyPackages() caps['emulatedMachines'] = _getEmulatedMachines() caps['ISCSIInitiatorName'] = _getIscsiIniName() caps['HBAInventory'] = storage.hba.HBAInventory() caps['vmTypes'] = ['kvm'] caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024) caps['reservedMem'] = str( config.getint('vars', 'host_mem_reserve') + config.getint('vars', 'extra_mem_reserve') ) caps['guestOverhead'] = config.get('vars', 'guest_ram_overhead') return caps
def getHostUUID(): global __hostUUID if __hostUUID: return __hostUUID __hostUUID = 'None' try: p = subprocess.Popen( [constants.EXT_SUDO, constants.EXT_DMIDECODE, "-s", "system-uuid"], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() out = '\n'.join(line for line in out.splitlines() if not line.startswith('#')) if p.returncode == 0 and 'Not' not in out: #Avoid error string - 'Not Settable' or 'Not Present' __hostUUID = out.strip() else: logging.warning('Could not find host UUID.') nics = netinfo.get()['nics'] try: mac = sorted([v['hwaddr'] for v in nics.itervalues()])[0] except: mac = "" logging.warning('Could not find host MAC.', exc_info=True) if __hostUUID != "None": __hostUUID += "_" + mac else: __hostUUID = "_" + mac except: logging.error(traceback.format_exc()) return __hostUUID
def getHostUUID(): global __hostUUID if __hostUUID: return __hostUUID __hostUUID = 'None' try: p = subprocess.Popen([constants.EXT_SUDO, constants.EXT_DMIDECODE, "-s", "system-uuid"], close_fds=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() out = '\n'.join( line for line in out.splitlines() if not line.startswith('#') ) if p.returncode == 0 and 'Not' not in out: #Avoid error string - 'Not Settable' or 'Not Present' __hostUUID = out.strip() else: logging.warning('Could not find host UUID.') nics = netinfo.get()['nics'] try: mac = sorted([v['hwaddr'] for v in nics.itervalues()])[0] except: mac = "" logging.warning('Could not find host MAC.', exc_info=True) if __hostUUID != "None": __hostUUID += "_" + mac else: __hostUUID = "_" + mac except: logging.error(traceback.format_exc()) return __hostUUID