0

https://github.com/vmware/pyvmomi-community-samples/issues/265? From here I can get the Memory info, but I am not able to get CPU reservation field.

Please find below code

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)

Here I also need to get the CPU reservation for the VM

Please suggest.

Thanks

GeekSRE
  • 3
  • 2

1 Answers1

1

According to the docs, the CPU reservation in MHz should be found in summary.config.cpuReservation.

If you want more information on the CPU allocation (e.g. shares), look at virtual_machine.config.cpuAllocation (docs).

YSK
  • 1,572
  • 10
  • 19