cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
478
Views
1
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task Name

example of merging data from a loop into one varaible

Description
Prerequisites

vCenter

CategoryWorkflow
ComponentsUCSD 6.6
User Inputs
Output

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFD file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFDX file resides. Choose the .WFDX file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. 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:

Screen Shot 2018-06-06 at 11.06.54 AM.png

E-mail output:

Screen Shot 2018-06-06 at 11.50.36 AM.png

Workflow run:

Screen Shot 2018-06-06 at 11.51.14 AM.png

Workflow input:

Screen Shot 2018-06-06 at 11.06.45 AM.png

Log output:

Screen Shot 2018-06-06 at 11.06.02 AM.png

Custom task input:

Screen Shot 2018-06-06 at 11.51.44 AM.png

Output of custom task fed into input:

Screen Shot 2018-06-06 at 11.51.53 AM.png

E-mail:

Screen Shot 2018-06-06 at 11.52.11 AM.png

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;

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links