Task Name | Netapp cli execution with variable chopping |
Description | |
Prerequisites | Minimum UCSD version: 5.4.0.1 |
Category | Custom task |
Components |
|
User Inputs | |
User Output | Netapp filer and cli command |
Instructions for Regular Workflow Use:
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 .WFD file resides. Choose the .WFD 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 thank you goes out to: Abhilash Pujari
The workflow:
Previous output is input:
Previous output is input in task:
Example of variable disassembly:
The workflow execution:
The variable name:
Other chopping options for the code (sort):
var vss1 = selection.split("online");
var vss = vss1.sort();
Custom task to extract the SR information:
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(java.util);
importPackage(java.lang);
// Auto generated to code invoke following task
// Task Label: Execute NetApp CLI
// Task Name: Execute NetApp CLI
function Execute_NetApp_CLI_()
{
var task = ctxt.createInnerTaskContext("Execute NetApp CLI ");
// Input 'Filer Identity Name', mandatory=true, mappableTo=filerIdentity
task.setInput("Filer Identity Name", input.filerName);
// Input 'CLI Command', mandatory=false, mappableTo=gen_text_input
task.setInput("CLI Command", input.inputCommand);
// Input 'Expected Output', mandatory=false, mappableTo=gen_text_input
task.setInput("Expected Output", input.expectedOutput);
// Input 'Undo CLI Command', mandatory=false, mappableTo=gen_text_input
task.setInput("Undo CLI Command", input.undoCLICommand);
// Now execute the task. If the task fails, then it will throw an exception
task.execute();
}
/////////////////////////////////////////////////
function getOutput(){
var srId = ctxt.getSrId();
//var srId = Integer.parseInt(input.SR_ID);
//var severityLevels = input.SeverityLevels;
logger.addInfo("SrId is:"+srId);
var severityLevel = 1;
var SRLogsList = getSRLogs(srId,severityLevel);
if(SRLogsList == null || SRLogsList.isEmpty()){
logger.addWarn("There is no SR LOGS.....");
}
for(var i=0;i<SRLogsList.size();i++){
var logEntry = SRLogsList.get(i);
var sr_Id = logEntry.getSrId();
var severity = logEntry.getSeverity();
var message = logEntry.getMessage();
if(message.contains("Output:")){
var taskOutput = getRequiredOutputFromLoggerMessage(message);
logger.addInfo("=========="+taskOutput);
output.taskOutput = taskOutput;
}
//logger.addInfo("SrId:"+sr_Id+" severity:"+ severity+" Message:"+message);
}
}
function getSRLogs(srId,severityLevel){
var entryList = SRLogUtil.getSRLogs(srId,severityLevel);
return entryList;
}
function getRequiredOutputFromLoggerMessage(outputFormat){
//Here we can fetch the exact info from the output.
return outputFormat;
}
function main(){
// Invoke the task
Execute_NetApp_CLI_();
Thread.sleep(3000);
getOutput();
logger.addInfo("Output of task is:"+output.taskOutput)
}
// Invoke the main function
main();