Skip to content

Instantly share code, notes, and snippets.

@trisharia
Last active August 25, 2017 18:09
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/b4e7bad457849010c55f28a12fa4caba to your computer and use it in GitHub Desktop.
Save trisharia/b4e7bad457849010c55f28a12fa4caba to your computer and use it in GitHub Desktop.
Get the Cluster of a vCenter VM
// VMware vRealize Orchestrator action sample
//
// Returns the cluster of a given vCenter VM
//
// For vRO 7.0+/vCenter 6.0+
//
// Action Inputs:
// vm - VC:VirtualMachine - vCenter VM
//
// Return type: VC:ClusterComputeResoure - the cluster to which the VM belongs
var parent = vm.runtime.host;
while (parent !== null && ! (parent instanceof VcClusterComputeResource)) {
parent = parent.parent;
}
System.log("VcClusterComputeResource of VM: " + parent.name);
return parent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment