[英]How I can fetch CPU reservation details of a VM from VMware using pyvmomi or any other python API
https://github.com/vmware/pyvmomi-community-samples/issues/265 ? 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.
从这里可以获取内存信息,但无法获取CPU保留字段。
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 在这里我还需要获取VM的CPU预留
Please suggest. 请提出建议。
Thanks 谢谢
According to the docs , the CPU reservation in MHz should be found in summary.config.cpuReservation
. 根据文档 ,以MHz为单位的CPU预留应该在
summary.config.cpuReservation
找到。
If you want more information on the CPU allocation (eg shares), look at virtual_machine.config.cpuAllocation
( docs ). 如果需要有关CPU分配的更多信息(例如,份额),请查看
virtual_machine.config.cpuAllocation
( docs )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.