【问题标题】:How I can fetch CPU reservation details of a VM from VMware using pyvmomi or any other python API如何使用 pyvmomi 或任何其他 python API 从 VMware 获取 VM 的 CPU 预留详细信息
【发布时间】:2017-05-05 22:08:18
【问题描述】:

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)

这里我还需要获取虚拟机的 CPU 预留

请提出建议。

谢谢

【问题讨论】:

    标签: python vmware pyvmomi


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2020-04-22
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 2022-08-21
      • 2016-09-24
      • 2022-11-12
      • 2014-10-15
      • 1970-01-01
      相关资源
      最近更新 更多