Try looking at VcHostRuntimeInfo, there will find the objects "connectionState" and "inMaintenanceMode" amongst others. An example (taking a cluster as input): for (i in Cluster.host) { ...
See more...
Try looking at VcHostRuntimeInfo, there will find the objects "connectionState" and "inMaintenanceMode" amongst others. An example (taking a cluster as input): for (i in Cluster.host) { selectedHost=Cluster.host[i]; System.log("Host: "+selectedHost.name); System.log("Power State: "+selectedHost.runtime.powerState.value); System.log("In Maintenance?: "+selectedHost.runtime.inMaintenanceMode); if (selectedHost.runtime.powerState.value == "poweredOn" && selectedHost.runtime.inMaintenanceMode == false) { //do some action based on this scenario } //If you want to find the number of runningVms on the cluster (for some reason or other) runningVms = 0; for(j in Cluster.host[i].vm){ if(Cluster.host[i].vm[j].runtime.powerState.name=="poweredOn"){ runningVms++; } } System.log("Total number of running hosts: "+runningVms); }