Created
February 22, 2017 21:15
-
-
Save vmwarecode/7ffa693104b37caceffb40dd7b408486 to your computer and use it in GitHub Desktop.
Find vCAC_VirtualMachine object for VC_VirtualMachine object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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