def get_info(self): inv_info = self._smutclient.get_host_info() host_info = {} with zvmutils.expect_invalid_resp_data(inv_info): host_info['zcc_userid'] = inv_info['zcc_userid'] host_info['zvm_host'] = inv_info['zvm_host'] host_info['vcpus'] = int(inv_info['lpar_cpu_total']) host_info['vcpus_used'] = int(inv_info['lpar_cpu_used']) host_info['cpu_info'] = {} host_info['cpu_info'] = {'architecture': const.ARCHITECTURE, 'cec_model': inv_info['cec_model'], } mem_mb = zvmutils.convert_to_mb(inv_info['lpar_memory_total']) host_info['memory_mb'] = mem_mb mem_mb_used = zvmutils.convert_to_mb(inv_info['lpar_memory_used']) host_info['memory_mb_used'] = mem_mb_used host_info['hypervisor_type'] = const.HYPERVISOR_TYPE verl = inv_info['hypervisor_os'].split()[1].split('.') version = int(''.join(verl)) host_info['hypervisor_version'] = version host_info['hypervisor_hostname'] = inv_info['hypervisor_name'] host_info['ipl_time'] = inv_info['ipl_time'] diskpool_name = CONF.zvm.disk_pool.split(':')[1] dp_info = self.diskpool_get_info(diskpool_name) host_info.update(dp_info) return host_info
def getReservedMemSize(rh, mem, maxMem): rh.printSysLog("Enter makeVM.getReservedMemSize") gap = '0M' # Check size suffix memSuffix = mem[-1].upper() maxMemSuffix = maxMem[-1].upper() if (memSuffix not in ['M', 'G']) or (maxMemSuffix not in ['M', 'G']): # Suffix is not 'M' or 'G' msg = msgs.msg['0205'][1] % modId rh.printLn("ES", msg) rh.updateResults(msgs.msg['0205'][0]) rh.printSysLog("Exit makeVM.parseCmdLine, rc: " + str(rh.results['overallRC'])) return gap # Convert both size to 'M' memMb = int(mem[:-1]) maxMemMb = int(maxMem[:-1]) if memSuffix == 'G': memMb = memMb * 1024 if maxMemSuffix == 'G': maxMemMb = maxMemMb * 1024 # Check maxsize is greater than initial mem size if maxMemMb < memMb: msg = msgs.msg['0206'][1] % (modId, maxMem, mem) rh.printLn("ES", msg) rh.updateResults(msgs.msg['0206'][0]) rh.printSysLog("Exit makeVM.parseCmdLine, rc: " + str(rh.results['overallRC'])) return gap # The define storage command can support 1-7 digits decimal number # So we will use 'M' as suffix unless the gap size exceeds 9999999 # then convert to Gb. gapSize = maxMemMb - memMb # get make max reserved memory value MAX_STOR_RESERVED = int( zvmutils.convert_to_mb( config.CONF.zvm.user_default_max_reserved_memory)) if gapSize > MAX_STOR_RESERVED: gapSize = MAX_STOR_RESERVED if gapSize > 9999999: gapSize = gapSize / 1024 gap = "%iG" % gapSize else: gap = "%iM" % gapSize rh.printSysLog("Exit makeVM.getReservedMemSize, rc: " + str(rh.results['overallRC'])) return gap
def _get_max_memory_from_user_dict(self, dict_info): with zvmutils.expect_invalid_resp_data(): mem = dict_info[0].split(' ')[4] return zvmutils.convert_to_mb(mem) * 1024
def test_convert_to_mb(self): self.assertEqual(2355.2, zvmutils.convert_to_mb('2.3G')) self.assertEqual(20, zvmutils.convert_to_mb('20M')) self.assertEqual(1153433.6, zvmutils.convert_to_mb('1.1T'))
def _get_max_memory_from_user_dict(self, dict_info): mem = dict_info[0].split(' ')[4] return zvmutils.convert_to_mb(mem) * 1024