Get or Create vRO Configuration Element
This file contains 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
// VMware vRealize Orchestrator action sample. Valid for vRA/vRO 7.0+ | |
// | |
// Get or Create a Configuration Element | |
// | |
// Action Inputs: | |
// categoryPath string Configuration Category Path (full path) | |
// configName string Name of Configuration Element | |
// | |
// Action Output: | |
// return type: ConfigurationElement | |
var configElement = null; | |
try { | |
var configCategory = Server.getConfigurationElementCategoryWithPath(categoryPath); | |
if(configCategory) { | |
System.log("Found configuration category '"+configCategory.name+"'"); | |
//Find Configuration Element | |
var configElements = configCategory.configurationElements; | |
for (var i in configElements) { | |
ce = configElements[i]; | |
if (ce.name == configName) { | |
configElement = ce; | |
break; | |
} | |
} | |
if(configElement) { | |
System.log("Found configuration '"+configElement.name+"'"); | |
} else { | |
configElement = Server.createConfigurationElement(configCategory, configName); | |
System.debug("Created configuration element '"+configElement.name+"'"); | |
} | |
} else { | |
configElement = Server.createConfigurationElement(categoryPath, configName); | |
System.debug("Created category path '"+categoryPath+"' and configuration element '"+configElement.name+"'"); | |
} | |
} catch(e) { | |
System.warn(e); | |
} | |
return configElement; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment