Last active
December 29, 2021 09:33
-
-
Save imtrinity94/e746c58de81af404f58892128d1f0be9 to your computer and use it in GitHub Desktop.
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
/* WORKFLOW INPUTS | |
categoryPath | string | Category\Path of Configuration Element | |
configName | string | Name of Configuration Element | |
CSV_CONTENT | string | comman sperated content | |
---------------------------------------------- | |
- KEY TYPE VALUE - | |
- username String root - | |
- password SecureString password - | |
- useCount number 14 - | |
- valid? boolean true - | |
- logpath path /vro/log/ - | |
---------------------------------------------- | |
*/ | |
var configCategory = Server.getConfigurationElementCategoryWithPath(categoryPath); | |
var configElement = null; | |
if (configCategory) { | |
System.log("Found configuration category '" + configCategory.name + "'"); | |
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(categoryPath, configName); | |
System.log("Created configuration element '" + configElement.name + "'"); | |
} | |
} else { | |
configElement = Server.createConfigurationElement(categoryPath, configName); | |
System.log("Created category path '" + categoryPath + "' and configuration element '" + configElement.name + "'"); | |
} | |
var _lines = CSV_CONTENT.split("\n"); | |
for (var i in _lines) { | |
var _fields = _lines[i].split(","); | |
var key = _fields[0]; | |
var type = _fields[1]; | |
var allValues = _fields[2]; //if value is single (not comma seperated) | |
if (_fields.length > 3) { // if value itself has multiple comma seperated values | |
for (var j = 3; j < _fields.length; j++) | |
allValues += "," + _fields[j]; | |
} | |
configElement.setAttributeWithKey(key,allValues,type); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Creating vRO Configuration Element in Bulk using CSV file
How to create configuration elements in bulk in various dev, staging and production environments. Just create a single csv file and put its content inside this vRO workflow and you are good to go.
*This code also allows you to provide a datatype along with key and value.