Skip to content

Instantly share code, notes, and snippets.

@trisharia
Created August 25, 2017 20:08
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/bee991415d90e0b3dfd767e4862a8177 to your computer and use it in GitHub Desktop.
Save trisharia/bee991415d90e0b3dfd767e4862a8177 to your computer and use it in GitHub Desktop.
Is the vCenter VM a template?
// VMware vRealize Orchestrator action sample
//
// Determine whether the given vCenter VM is a template
//
// For vRO 7.0+/vCenter 6.0+
//
// Action Inputs:
// vm - VC:VirtualMachine - vCenter VM
//
// Return type: boolean - true if the VM is a template
if (vm.config) {
if (vm.config.template) {
return true;
}
} else if (vm.summary) {
System.warn("Config info of VM " + vm.name + " is inaccessible. Trying config summary info ...");
if (vm.summary.config.template) {
return true;
}
} else if (!vm.config && !vm.summary) {
throw "Cannot deteremine if VM " + vm.name + " is a template because its config info and config summary info are both inaccessible";
}
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment