03-20-2017 10:52 AM - edited 03-01-2019 06:46 AM
Task Name | Multi Column CSV file read and great DB entries |
Description | |
Prerequisites | Tested on UCSD 6.5 |
Category | Workflow |
Components | vSphere 5.x |
User Inputs | inputs length have been tested up to 1300 characters |
Instructions for Regular Workflow Use:
User Input:
The workflow:
Workflow run:
Log file:
Script Module:
Tabular report in multcolread:
The script:
The Code:
Note: Column A is being used for the selection process to provide the whole line of values.
//Provide import statements here if needed for your written code.
//Write your own logic at appropriate place as indicated below for populating the records.
//DO NOT EDIT OR DELETE ANYTHING IN THE AUTOGENERATED CODE.
function implementationForTabularReport(report)
{
var model = new TabularReportInternalModel();
model.addTextColumn("A","A");
model.addTextColumn("B","B");
model.addTextColumn("C","C");
model.addTextColumn("D","D");
model.completedHeader();
//You can get values from the DB and populate the model object as shown below
//which got generated based on the Column Entries.
//model.addTextValue("A");
//model.addTextValue("B");
//model.addTextValue("C");
//model.addTextValue("D");
//model.completedRow();
//START OF YOUR IMPLEMENTATION.
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(com.cloupia.service.cIM.inframgr.workflowmgr);
// importPackage(java.util);
// importPackage(java.lang);
importPackage(com.cloupia.service.cIM.inframgr.customactions);
importPackage(com.cloupia.service.cIM.inframgr.forms.wizard);
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(com.cloupia.model.cIM);
importPackage(com.cloupia.feature.customactions.lovproviders);
importPackage(java.util);
importPackage(java.io);
importPackage(com.cloupia.service.cIM.inframgr.forms.wizard);
var fileReader = new FileReader("/tmp/info.csv");
var br = new BufferedReader(fileReader);
var tokens;
var UCSDLoopCounter = new ArrayList();
while(true){
var line = br.readLine();
if(line == null)break;
logger.addInfo("Line" + line);
tokens = line.split(",");
//model.addTextValue(tokens[0]);
//Assume In the tabular report col ‘A’ is marked as management column
model.addTextValue(tokens[0]+"@"+tokens[1]+"@"+tokens[2]+"@"+tokens[3]);//We need to set the values like this to the management column of the tabular report.
model.addTextValue(tokens[1]);
model.addTextValue(tokens[2]);
model.addTextValue(tokens[3]);
model.completedRow();
//END OF YOUR IMPLEMENTATION.
model.updateReport(report);
}
Sample CSV file:
[root@localhost ~]# cat /tmp/info.csv
mgt,VW,Jetta,Silver
mgt,VW,Golf,Silver
mgt,Chevy,Truck,2500
mgt,Potiac,2Door,Blue
mgt,Chevy,Suburban,Green
mgt,Chevy,Suburban,Black_Silver
mgt,Ford,EscordGT,Black
mgt,VW,Van,Red
mgt,Chevy,Vega,red
If this is attempted on UCSD version below 6.5 this has to be disabled:
This is not recommended for a production system!
Total disable of security policies
=================================
vi /opt/infra/bin/inframgr.env
#Original
#JVM_ARGS="-DSVC=$SVC -Xms$MEMORY_MIN -Xmx$MEMORY_MAX $REMOTE_DEBUG_OPTS -Djava.security.manager -Djava.security.policy=security.policy -DpreInitSchema=true -verbose:gc -Dfile.encoding=UTF-8 $JMX_OPTS"
#Modification
JVM_ARGS="-DSVC=$SVC -Xms$MEMORY_MIN -Xmx$MEMORY_MAX $REMOTE_DEBUG_OPTS -DpreInitSchema=true -verbose:gc -Dfile.encoding=UTF-8 $JMX_OPTS"
Have you played with Input Rules in the input section? They can handle a contains.
Another option would be to look into validated input variables and these examples here. You can hit the bash shell before the workflow actually runs and make decisions. Like check if the host name is correct with a sql call, or look at some file or do some computation.
Thank you very much for the quick response.
Yes i've used input rules in my workflows, but thanks to your note, i had a look at the example folder again and found some helpful use cases.
Also these input validators look very interesting i didn't know you can actually do some computation before the workflow runs. I need to have a deeper look at it and see what i can do with it.
Do you know if there's a way to fix the following error:
I crated this "BIT_Leaf_Provisioning" Tabular Report with your example above (based on CSV input).
Here is my e-mail. ogelbric@cisco.com. Send me an e-mail and I can send you some experimental workaround.
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: