VMware {code} Community
GNice141
Contributor
Contributor

Capacity and size of virtual disk (C#)

Is there any to retrieve the capacity of a virtual disk which is not associated with a virtual machine.

Trying to implement in C# code.

P.S.

I am able to retrieve the data for disks associated with a virtual machine but not for independent disks.

0 Kudos
2 Replies
admin
Immortal
Immortal

Hi,

There's no direct API or any property for which you can fetch the capacity of the independent disks just like the way you do for vmdks associated with VM, but what you can try is invoke SearchDatastoreSubFolders_Task API, which will retrieve all the files on a particular datastore, in a HostDatastoreBrowserSearchResults object. You can then filter out HostDatastoreBrowserSearchResults.FileInfo.fileSize property of the vmdk files which you wish to search.

I hope it helps you!

admin
Immortal
Immortal

You might also consider VirtualDiskManager - query geometry (so the capacity will not be exact).

Note that it is experimental, so use it at your own risk.

http://vmware.in/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.VirtualDiskManager.html

-Sudarsan