How to get sizes of VMWare VM disks using PyVMomi

独自空忆成欢 提交于 2020-01-04 05:39:28

问题


Can anyone guide me how to calculate the sizes of disks attached to VMWare VMs using PyVMomi?


回答1:


Assuming you know how to get a vm object, you can do:

for device in vm.config.hardware.device:
    if type(device).__name__ == 'vim.vm.device.VirtualDisk':
        print 'SIZE', device.deviceInfo.summary

On a 1TB disk this prints:

SIZE 1,073,741,824 KB

There are probably better ways. I'm just getting going with pyvmomi.




回答2:


For more in depth information, refer reply to the question: Getting an instance's actual used (allocated) disk space in vmware with pyvmomi

Using the following approach and code, you can get DiskPath, DiskCapacity and FreeSpace of the disk, you want to query for. Hope it helps.



来源:https://stackoverflow.com/questions/36026470/how-to-get-sizes-of-vmware-vm-disks-using-pyvmomi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!