Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get or Create vRO Configuration Element
// 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