如何使用pyvmomi或任何其他python API从VMware获取VM的CPU预留详细信息

时间:2017-05-05 22:08:18

标签: python vmware pyvmomi

https://github.com/vmware/pyvmomi-community-samples/issues/265? 从这里我可以得到内存信息,但我无法获得CPU预留字段。

请查看以下代码

def main():
    service_instance = connect.SmartConnect(host=vcenter_host,   user=vcenter_user, pwd=vcenter_password,port=int(vcenter_port), sslContext=context)
    print("Fetched the server instance")
    atexit.register(connect.Disconnect, service_instance)
    print("Diconnect the  connections")
    content = service_instance.content

for datacenter in content.rootFolder.childEntity:
  if printVM:
        if hasattr(datacenter.vmFolder, 'childEntity'):
            vmFolder = datacenter.vmFolder
            vmList = vmFolder.childEntity
            for vm in vmList:
                print "VM name ", vm
                printVmInformation(vm)

 summary = virtual_machine.summary
 #print("Name of the VM:",summary.config.name)
#print("Path Name: ",summary.config.vmPathName)
#print("Guest Name",summary.config.guestFullName)
#print("Memory size",summary.config.memorySizeMB)#print("No of CPU used by a VM",summary.config.numCpu)

这里我还需要获取VM的CPU预留

请建议。

由于

1 个答案:

答案 0 :(得分:0)

根据the docs,以MHz为单位的CPU预留应在summary.config.cpuReservation中找到。

如果您想了解有关CPU分配的更多信息(例如分享),请查看virtual_machine.config.cpuAllocationdocs)。