簡體   English   中英

如何使用pyvmomi或任何其他python API從VMware獲取VM的CPU預留詳細信息

[英]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嗎? 從這里可以獲取內存信息,但無法獲取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預留

請提出建議。

謝謝

根據文檔 ,以MHz為單位的CPU預留應該在summary.config.cpuReservation找到。

如果需要有關CPU分配的更多信息(例如,份額),請查看virtual_machine.config.cpuAllocationdocs )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM