Hi All
I need to obtain the datastore name,capacity of that and free space as its gets displayed in the VI for a particular esxserver using SDK.
Thanks in Advance
The "HostSystem" managed object has a property "datastore" which is an array of MOR to the available datastores to the ESX. Accessing the "summary.name", "summary.capacity" and "summary.freeSpace" properties will give you the desired values.
<br /><br/> ManagedObjectReference[] ds = (ManagedObjectReference[])cb.getServiceUtil().getDynamicProperty(obj.hostMOR, "datastore");<br/><br/> for (int i = 0; i < ds.length; i++) {<br/><br/> DatastoreSummary dsSummary = (DatastoreSummary)cb.getServiceUtil().getDynamicProperty(ds[i], "summary");<br/><br/> System.out.println("\n Datastore Name: " + dsSummary.getName() +<br/><br/> "\n Capacity (in bytes): " + dsSummary.getCapacity() +<br/><br/> "\n Free Space (in bytes): " + dsSummary.getFreeSpace() +<br/><br/> "\n");<br/><br/> }
</p>
Thanks for the code snippet.It works perfect.
VI Java API version looks easier to read:
Datastore[] ds = host.getDatastore();
for (int i = 0; i < ds.length; i++) {
DatastoreSummary dsSummary = (DatastoreSummary)ds[i].getSummary();
System.out.println("\n Datastore Name: " + dsSummary.getName()
+ "\n Capacity (in bytes): " + dsSummary.getCapacity()
+ "\n Free Space (in bytes): " + dsSummary.getFreeSpace() + "\n");
}
Steve JIN, VMware Engineering