问题
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