Skip to content

Instantly share code, notes, and snippets.

@vmwarecode
Created February 22, 2017 21:15
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 vmwarecode/7ffa693104b37caceffb40dd7b408486 to your computer and use it in GitHub Desktop.
Save vmwarecode/7ffa693104b37caceffb40dd7b408486 to your computer and use it in GitHub Desktop.
Find vCAC_VirtualMachine object for VC_VirtualMachine object
// Copyright 2017, VMware, Inc. All Rights Reserved
//
// VMware vRealize Orchestrator action sample
//
// Finds a vCAC:VirtualMachine object corresponding to a VC:VirtualMachine object.
//
//
//Action Inputs:
// vm - VC:VirtualMachine
//
//Return type: vCAC:VirtualMachine
var vCACVMs = Server.findAllForType("vCAC:VirtualMachine", "VMUniqueID eq '" + vm.config.instanceUuid + "'");
var vCACVM = null;
if (vCACVMs != null && vCACVMs.length ==1) {
vCACVM = vCACVMs[0];
} else {
if (vCACVMs == null || vCACVMs.length ==0) {
//could not find
throw("Could not find vCAC VM matching VMUniqueID of "+vm.config.instanceUuid);
} else {
//found more than one! Should never happen
throw("Found more than one vCAC VM matching VMUniqueID of "+vm.config.instanceUuid);
}
}
return vCACVM;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment