I'd like to know the API to use to get the provisioned space for a datastore. This is displayed in vsphere under ‘provisioned space’ in the summary tab of a ‘datastore’ in Inventory > Datastores view.
I looked around in datastore related APIs and could not find any property that can give me this value. If not a single property/API, is there a way to write some code to compute this based on available vsphere APIs?
Hello.
Note: This discussion was moved from the VMware vCenter Server community to the Automation Tools community.
Good Luck!
Hello, Ragsboss-
You should be able to use a few of the properties of a VMware.Vim.DatastoreSummary object (reference at http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.Datastore.Summary.html). There is not a "ProvisionedSpace" property, but you can calculate it from:
property | description (brief) |
---|---|
capacity | Maximum capacity of the datastore, in bytes |
freeSpace | Available space of the datastore, in bytes |
uncommitted | Total additional storage space, in bytes, potentially used by all VMs on the datastore |
Since provisioned space is sum of used space (which is capacity - freeSpace) and the uncommitted bytes, the simple math would be something like:
$longProvisionedBytes = $dstoreSummary.Capacity - $dstoreSummary.freeSpace + $dstoreSummary.uncommitted
How does that look?