Hi,
I get all the hosts from a cluster with the command:
var hosts = cluster.getAllHostSystemOfCluster();
I want to pass over the array of hosts, and check if the host is available and not in maintenance mode and get all the datastore from the host.
Thanks!
Check documentation for host system object (VcHostSystem / VC:HostSystem) - it has a property named datastore which returns an array of datastores that are available in this host system.
Here is some sample code showing how to enumerate datastores for a given host system (input variable is host of type VC:HostSystem)
var all = host.datastore;
for each (var ds in all) {
System.log("datastore: " + ds);
}
ok to find out if a host is in MM the command is : vcHost.summary.runtimre.inMaintenanceMode
To get all the datastores for a host there is an action called getAllDatastoreOnVimHost that will do that for you. You can find that here: com.vmware.library.vc.datastore
As for status, depending on what you want to know you can start here: var vimStat = vcHost.overallStatus
Cheers!!
Hi,
Thank you for your answer.
But the action you provided receive for input vCenter object and not esx host.
In your case, I receive all the datastores in the vCenter.
In my case, I have several clusters in my vCenter, and I want to receive the datastores of a specific esx host.
Thanks!
any idea?
Check documentation for host system object (VcHostSystem / VC:HostSystem) - it has a property named datastore which returns an array of datastores that are available in this host system.
Here is some sample code showing how to enumerate datastores for a given host system (input variable is host of type VC:HostSystem)
var all = host.datastore;
for each (var ds in all) {
System.log("datastore: " + ds);
}