Skip to content

Instantly share code, notes, and snippets.

@standit
Last active June 16, 2021 12:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save standit/5bc86ce89a887053c7316a59a8903465 to your computer and use it in GitHub Desktop.
Save standit/5bc86ce89a887053c7316a59a8903465 to your computer and use it in GitHub Desktop.
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