Skip to content

Instantly share code, notes, and snippets.

@vmwarecode
Created February 29, 2016 05:06
Show Gist options
  • Select an option

  • Save vmwarecode/7d5db5bbe93670ddf5a7 to your computer and use it in GitHub Desktop.

Select an option

Save vmwarecode/7d5db5bbe93670ddf5a7 to your computer and use it in GitHub Desktop.
Get Online Host from vSphere Cluster
//Action Inputs
// cluster - VC:ClusterComputeResource
//
//Action Result: VC:HostSystem
var hosts = cluster.host;
var host;
for (var h in hosts) {
if (hosts[h].runtime.connectionState.value == "connected" && hosts[h].runtime.inMaintenanceMode == false) {
host = hosts[h];
} else {
System.warn(hosts[h].name+": "+hosts[h].runtime.connectionState + ", inMaintenanceMode: " + hosts[h].runtime.inMaintenanceMode);
}
}
return host;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment