Task Name | example of merging data from a loop into one varaible |
Description | |
Prerequisites | vCenter |
Category | Workflow |
Components | UCSD 6.6 |
User Inputs | |
Output | |
Instructions for Regular Workflow Use:
- Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
- Unzip the file on your computer. Should end up with a .WFD file.
- Log in to UCS Director as a user that has "system-admin" privileges.
- Navigate to "Policies-->Orchestration" and click on "Import".
- Click "Browse" and navigate to the location on your computer where the .WFDX file resides. Choose the .WFDX file and click "Open".
- Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
- Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
- Click "Submit".
- A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.
A massive Thank You goes out to:
Andrews Bob for contributing this.
This is an example of merging output from a task that is in a loop into one variable.
The workflow:
E-mail output:
Workflow run:
Workflow input:
Log output:
Custom task input:
Output of custom task fed into input:
E-mail:
Custom task code:
function buildName(userInput, inputLength, prefix, suffix)
{
// Trim Length
if (inputLength > 0 && userInput.length() > inputLength)
{
userInput = userInput.slice(0,inputLength);
}
// Add prefix
if (prefix)
{
userInput = prefix + "\n" + userInput;
}
// Add suffix
if (suffix)
{
userInput = userInput + "\n" + suffix;
}
userInput = userInput + "\n";
return userInput;
}
// -- Begin --
var userInput = input.userInput;
var inputLength = input.inputLength;
var prefix = input.prefix;
var suffix = input.suffix;
logger.addInfo("userInput: " + userInput);
logger.addInfo("inputLength: " + inputLength);
logger.addInfo("prefix: " + prefix);
logger.addInfo("suffix: " + suffix);
if ( prefix.contains("${")) {
logger.addInfo("setting prefix to null since ${var} is not resolved")
prefix = "";
}
var mergedData = buildName(userInput, inputLength, prefix, suffix);
logger.addInfo("Merged Output: " + mergedData);
ctxt.setTaskStatusMessage("Merged Output: " + mergedData);
output.mergedOutput = mergedData;