Skip to content

Instantly share code, notes, and snippets.

@trisharia
Created August 25, 2017 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trisharia/c30eb81a41d448b9974fa38aede20420 to your computer and use it in GitHub Desktop.
Save trisharia/c30eb81a41d448b9974fa38aede20420 to your computer and use it in GitHub Desktop.
Get Cluster by Name
// VMware vRealize Orchestrator action sample
//
// Returns the vCenter ClusterComputeResource with the given name
// Assumes there is only 1
// Does a case-insensitive search
//
// For vRO 7.0+/vCenter 6.0+
//
// Action Inputs:
// clustername - string - Name of the cluster to find
//
// Return type: VC:ClusterComputeResource - the cluster with the given name
var clusters = VcPlugin.getAllClusterComputeResources(null,
"xpath:matches(translate(name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), '" + clusterName.toLowerCase() + "')");
if (clusters.length > 0) {
return clusters[0];
}
System.warn("VC:ClusterComputeResource named '" + clusterName + "' not found.");
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment