2

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

user2847686
  • 21
  • 1
  • 3

2 Answers2

2

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.

Karl Young
  • 21
  • 4
0

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.

Community
  • 1
  • 1
justjais
  • 344
  • 3
  • 13