11-06-2017 09:52 AM - edited 08-16-2018 05:06 AM
Task Name |
|
Description |
|
Prerequisites |
|
Category | Workflow |
Components | vSphere 6.5 |
User Inputs |
Instructions for Regular Workflow Use:
The Workflow:
Workflow Input:
The Metadata button for the screen will show the different Parameter items:
There are tools to convert the API from:
To this:
An example of one of these converters can be found here:
https://ascii.cl/url-decoding.htm
Here is the custom task code:
importPackage(java.util);
importPackage(java.lang);
importPackage(java.io);
importPackage(com.cloupia.model.cEvent.notify);
importPackage(com.cloupia.model.cIM);
importPackage(com.cloupia.lib.util.mail);
importPackage(com.cloupia.fw.objstore);
importPackage(com.cloupia.lib.util.managedreports);
importPackage(com.cloupia.lib.util);
importPackage(com.cloupia.service.cIM.inframgr);
importPackage(org.apache.commons.httpclient);
importPackage(org.apache.commons.httpclient.cookie);
importPackage(org.apache.commons.httpclient.methods);
importPackage(org.apache.commons.httpclient.auth);
importPackage(com.cloupia.model.cEvent.notify);
function getTabularReport(contextName , contextValue , reportId ){
try {
var tabularReport = ctxt.getAPI().userAPIGetTabularReport(contextName, contextValue,reportId);
return tabularReport;
} catch(e){
logger.addError("Error : "+e.message);
}
}
//var contextName = "445"; //param0
//var contextValue = "1;org-root;org-root/ls-UCSD_test1"; //param1
//var reportId = "VNICS-T50";//param2
var param0 = input.PARAM0;
var param1 = input.PARAM1;
var param2 = input.PARAM2;
var SearchColumn1 = input.SearchColumn;
var SearchValue1 = input.SearchValue;
var Foundit = 0;
var report = getTabularReport(param0 , param1 , param2 );
var numRowsFound = report.getRowCount();
logger.addInfo("Number of Rows found: " + numRowsFound);
for (var i=0; i<report.getRowCount(); i++)
{
if ( Foundit === 0 ) // Looking for the first occurance of search
{
var tokens;
var array1 = new ArrayList();
var row = report.getRow(i);
var line = new String(row);
logger.addInfo("row : " + row);
var tokens = line.split(",");
if(tokens != null && tokens.length > 0){
array1.add(tokens);
}
var ListSize = array1.size();
logger.addInfo("ListSize : " + ListSize);
var details = array1.iterator();
logger.addInfo("-------------------------------------");
logger.addInfo("Iteration : " + i );
logger.addInfo("-------------------------------------");
while(details.hasNext()){
var arr = details.next();
logger.addInfo("A0 : "+arr[0]);
logger.addInfo("A1 : "+arr[1]);
logger.addInfo("A2 : "+arr[2]);
logger.addInfo("A3 : "+arr[3]);
logger.addInfo("A4 : "+arr[4]);
logger.addInfo("A5 : "+arr[5]);
logger.addInfo("A6 : "+arr[6]);
logger.addInfo("A7 : "+arr[7]);
logger.addInfo("A8 : "+arr[8]);
logger.addInfo("A9 : "+arr[9]);
logger.addInfo("A10 : "+arr[10]);
logger.addInfo("A11 : "+arr[11]);
logger.addInfo("A12 : "+arr[12]);
logger.addInfo("A13 : "+arr[13]);
logger.addInfo("A14 : "+arr[14]);
logger.addInfo("A15 : "+arr[15]);
logger.addInfo("A16 : "+arr[16]);
logger.addInfo("A17 : "+arr[17]);
}
logger.addInfo("SearchColumn...... : " + SearchColumn1);
logger.addInfo("SearchValue....... : " + SearchValue1);
// remove space
var SC1 = arr[SearchColumn1].trim();
logger.addInfo("Item...............: " + SC1);
var SC3 = SC1.split("=",2);
logger.addInfo("Left item..........: " + SC3[0]);
logger.addInfo("Right item.........: " + SC3[1].replace(/}/g,""));
// remove } on last item
var RightItem = SC3[1].replace(/}/g,"");
if ( new String(SearchValue1).valueOf() == new String(RightItem).valueOf() )
{
logger.addInfo("Looking for..........: " + SearchValue1);
logger.addInfo("Found match.........: " + RightItem);
output.c1 = arr[1];
output.c2 = arr[2];
output.c3 = arr[3];
output.c4 = arr[4];
output.c5 = arr[5];
output.c6 = arr[6];
output.c7 = arr[7];
output.c8 = arr[8];
output.c9 = arr[9];
output.c10 = arr[10];
output.c11 = arr[11];
output.c12 = RightItem;
output.ReturnStatus = 1;
Foundit = 1;
}
else
{
logger.addInfo("No match...............");
output.ReturnStatus = 0;
}
}
}
The Log file:
Service Request ID: 566
-------------------------------------
Workflow Inputs:
Param 0: 273
Param 1: 1
Param 2: FABRIC-LOGIN-T52
Search Column: 5
Search Value: 50:0a:09:83:8f:03:01:b1
Nov 06, 2017 17:42:36 UTC Request submitted
Nov 06, 2017 17:42:37 UTC Executing workflow item number 1
Nov 06, 2017 17:42:37 UTC Completed workflow item number 1, with status Completed
Nov 06, 2017 17:42:40 UTC Executing workflow item number 2
Nov 06, 2017 17:42:40 UTC Trigger context executeWorkFlowStep called
Nov 06, 2017 17:42:41 UTC Executing custom action Reports_Generic_Version_4 (custom_Generic_Report_API_ver4)
Nov 06, 2017 17:42:41 UTC Executing custom action Reports_Generic_Version_4 (custom_Generic_Report_API_ver4)
Nov 06, 2017 17:42:41 UTC Executing custom script for Generic_Report_API_ver4
Nov 06, 2017 17:42:41 UTC Number of Rows found: 4
Nov 06, 2017 17:42:41 UTC row : {Pod=GlassHouseDeployPOD1, Device_IP=172.16.50.10, FC_Port=fc1/14, VSAN=500, FC_ID=0xe50a00, WWPN=50:0a:09:83:8f:a3:10:d5, WWNN=50:0a:09:80:8f:a3:10:d5}
Nov 06, 2017 17:42:41 UTC ListSize : 1
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC Iteration : 0
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC A0 : {Pod=GlassHouseDeployPOD1
Nov 06, 2017 17:42:41 UTC A1 : Device_IP=172.16.50.10
Nov 06, 2017 17:42:41 UTC A2 : FC_Port=fc1/14
Nov 06, 2017 17:42:41 UTC A3 : VSAN=500
Nov 06, 2017 17:42:41 UTC A4 : FC_ID=0xe50a00
Nov 06, 2017 17:42:41 UTC A5 : WWPN=50:0a:09:83:8f:a3:10:d5
Nov 06, 2017 17:42:41 UTC A6 : WWNN=50:0a:09:80:8f:a3:10:d5}
Nov 06, 2017 17:42:41 UTC A7 : undefined
Nov 06, 2017 17:42:41 UTC A8 : undefined
Nov 06, 2017 17:42:41 UTC A9 : undefined
Nov 06, 2017 17:42:41 UTC A10 : undefined
Nov 06, 2017 17:42:41 UTC A11 : undefined
Nov 06, 2017 17:42:41 UTC A12 : undefined
Nov 06, 2017 17:42:41 UTC A13 : undefined
Nov 06, 2017 17:42:41 UTC A14 : undefined
Nov 06, 2017 17:42:41 UTC A15 : undefined
Nov 06, 2017 17:42:41 UTC A16 : undefined
Nov 06, 2017 17:42:41 UTC A17 : undefined
Nov 06, 2017 17:42:41 UTC SearchColumn...... : 5
Nov 06, 2017 17:42:41 UTC SearchValue....... : 50:0a:09:83:8f:03:01:b1
Nov 06, 2017 17:42:41 UTC Item...............: WWPN=50:0a:09:83:8f:a3:10:d5
Nov 06, 2017 17:42:41 UTC Left item..........: WWPN
Nov 06, 2017 17:42:41 UTC Right item.........: 50:0a:09:83:8f:a3:10:d5
Nov 06, 2017 17:42:41 UTC No match...............
Nov 06, 2017 17:42:41 UTC row : {Pod=GlassHouseDeployPOD1, Device_IP=172.16.50.10, FC_Port=fc1/14, VSAN=500, FC_ID=0xe50a01, WWPN=20:03:00:a0:98:32:df:53, WWNN=20:00:00:a0:98:32:df:53}
Nov 06, 2017 17:42:41 UTC ListSize : 1
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC Iteration : 1
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC A0 : {Pod=GlassHouseDeployPOD1
Nov 06, 2017 17:42:41 UTC A1 : Device_IP=172.16.50.10
Nov 06, 2017 17:42:41 UTC A2 : FC_Port=fc1/14
Nov 06, 2017 17:42:41 UTC A3 : VSAN=500
Nov 06, 2017 17:42:41 UTC A4 : FC_ID=0xe50a01
Nov 06, 2017 17:42:41 UTC A5 : WWPN=20:03:00:a0:98:32:df:53
Nov 06, 2017 17:42:41 UTC A6 : WWNN=20:00:00:a0:98:32:df:53}
Nov 06, 2017 17:42:41 UTC A7 : undefined
Nov 06, 2017 17:42:41 UTC A8 : undefined
Nov 06, 2017 17:42:41 UTC A9 : undefined
Nov 06, 2017 17:42:41 UTC A10 : undefined
Nov 06, 2017 17:42:41 UTC A11 : undefined
Nov 06, 2017 17:42:41 UTC A12 : undefined
Nov 06, 2017 17:42:41 UTC A13 : undefined
Nov 06, 2017 17:42:41 UTC A14 : undefined
Nov 06, 2017 17:42:41 UTC A15 : undefined
Nov 06, 2017 17:42:41 UTC A16 : undefined
Nov 06, 2017 17:42:41 UTC A17 : undefined
Nov 06, 2017 17:42:41 UTC SearchColumn...... : 5
Nov 06, 2017 17:42:41 UTC SearchValue....... : 50:0a:09:83:8f:03:01:b1
Nov 06, 2017 17:42:41 UTC Item...............: WWPN=20:03:00:a0:98:32:df:53
Nov 06, 2017 17:42:41 UTC Left item..........: WWPN
Nov 06, 2017 17:42:41 UTC Right item.........: 20:03:00:a0:98:32:df:53
Nov 06, 2017 17:42:41 UTC No match...............
Nov 06, 2017 17:42:41 UTC row : {Pod=GlassHouseDeployPOD1, Device_IP=172.16.50.10, FC_Port=fc1/25, VSAN=500, FC_ID=0xe50600, WWPN=50:0a:09:81:86:57:c9:3d, WWNN=50:0a:09:80:86:57:c9:3d}
Nov 06, 2017 17:42:41 UTC ListSize : 1
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC Iteration : 2
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC A0 : {Pod=GlassHouseDeployPOD1
Nov 06, 2017 17:42:41 UTC A1 : Device_IP=172.16.50.10
Nov 06, 2017 17:42:41 UTC A2 : FC_Port=fc1/25
Nov 06, 2017 17:42:41 UTC A3 : VSAN=500
Nov 06, 2017 17:42:41 UTC A4 : FC_ID=0xe50600
Nov 06, 2017 17:42:41 UTC A5 : WWPN=50:0a:09:81:86:57:c9:3d
Nov 06, 2017 17:42:41 UTC A6 : WWNN=50:0a:09:80:86:57:c9:3d}
Nov 06, 2017 17:42:41 UTC A7 : undefined
Nov 06, 2017 17:42:41 UTC A8 : undefined
Nov 06, 2017 17:42:41 UTC A9 : undefined
Nov 06, 2017 17:42:41 UTC A10 : undefined
Nov 06, 2017 17:42:41 UTC A11 : undefined
Nov 06, 2017 17:42:41 UTC A12 : undefined
Nov 06, 2017 17:42:41 UTC A13 : undefined
Nov 06, 2017 17:42:41 UTC A14 : undefined
Nov 06, 2017 17:42:41 UTC A15 : undefined
Nov 06, 2017 17:42:41 UTC A16 : undefined
Nov 06, 2017 17:42:41 UTC A17 : undefined
Nov 06, 2017 17:42:41 UTC SearchColumn...... : 5
Nov 06, 2017 17:42:41 UTC SearchValue....... : 50:0a:09:83:8f:03:01:b1
Nov 06, 2017 17:42:41 UTC Item...............: WWPN=50:0a:09:81:86:57:c9:3d
Nov 06, 2017 17:42:41 UTC Left item..........: WWPN
Nov 06, 2017 17:42:41 UTC Right item.........: 50:0a:09:81:86:57:c9:3d
Nov 06, 2017 17:42:41 UTC No match...............
Nov 06, 2017 17:42:41 UTC row : {Pod=GlassHouseDeployPOD1, Device_IP=172.16.50.10, FC_Port=fc1/37, VSAN=500, FC_ID=0xe50b00, WWPN=52:4a:93:78:77:2b:29:10, WWNN=52:4a:93:78:77:2b:29:10}
Nov 06, 2017 17:42:41 UTC ListSize : 1
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC Iteration : 3
Nov 06, 2017 17:42:41 UTC -------------------------------------
Nov 06, 2017 17:42:41 UTC A0 : {Pod=GlassHouseDeployPOD1
Nov 06, 2017 17:42:41 UTC A1 : Device_IP=172.16.50.10
Nov 06, 2017 17:42:41 UTC A2 : FC_Port=fc1/37
Nov 06, 2017 17:42:41 UTC A3 : VSAN=500
Nov 06, 2017 17:42:41 UTC A4 : FC_ID=0xe50b00
Nov 06, 2017 17:42:41 UTC A5 : WWPN=52:4a:93:78:77:2b:29:10
Nov 06, 2017 17:42:41 UTC A6 : WWNN=52:4a:93:78:77:2b:29:10}
Nov 06, 2017 17:42:41 UTC A7 : undefined
Nov 06, 2017 17:42:41 UTC A8 : undefined
Nov 06, 2017 17:42:41 UTC A9 : undefined
Nov 06, 2017 17:42:41 UTC A10 : undefined
Nov 06, 2017 17:42:41 UTC A11 : undefined
Nov 06, 2017 17:42:41 UTC A12 : undefined
Nov 06, 2017 17:42:41 UTC A13 : undefined
Nov 06, 2017 17:42:41 UTC A14 : undefined
Nov 06, 2017 17:42:41 UTC A15 : undefined
Nov 06, 2017 17:42:41 UTC A16 : undefined
Nov 06, 2017 17:42:41 UTC A17 : undefined
Nov 06, 2017 17:42:41 UTC SearchColumn...... : 5
Nov 06, 2017 17:42:41 UTC SearchValue....... : 50:0a:09:83:8f:03:01:b1
Nov 06, 2017 17:42:41 UTC Item...............: WWPN=52:4a:93:78:77:2b:29:10
Nov 06, 2017 17:42:41 UTC Left item..........: WWPN
Nov 06, 2017 17:42:41 UTC Right item.........: 52:4a:93:78:77:2b:29:10
Nov 06, 2017 17:42:41 UTC No match...............
Nov 06, 2017 17:42:41 UTC Processing output: ReturnStatus
Nov 06, 2017 17:42:42 UTC Processing output: c1
Nov 06, 2017 17:42:42 UTC output: c1 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c2
Nov 06, 2017 17:42:42 UTC output: c2 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c3
Nov 06, 2017 17:42:42 UTC output: c3 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c4
Nov 06, 2017 17:42:42 UTC output: c4 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c5
Nov 06, 2017 17:42:42 UTC output: c5 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c6
Nov 06, 2017 17:42:42 UTC output: c6 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c7
Nov 06, 2017 17:42:42 UTC output: c7 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c8
Nov 06, 2017 17:42:42 UTC output: c8 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c9
Nov 06, 2017 17:42:42 UTC output: c9 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c10
Nov 06, 2017 17:42:42 UTC output: c10 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c11
Nov 06, 2017 17:42:42 UTC output: c11 is not set
Nov 06, 2017 17:42:42 UTC Processing output: c12
Nov 06, 2017 17:42:42 UTC output: c12 is not set
Nov 06, 2017 17:42:42 UTC Task #2 (Reports_Generic_Version_4 (custom_Generic_Report_API_ver4)) completed successfully in 1 seconds
Nov 06, 2017 17:42:42 UTC Input/Output values for Task #2 (Reports_Generic_Version_4 (custom_Generic_Report_API_ver4)):
Nov 06, 2017 17:42:42 UTC [Mapped Input: PARAM0 = 273]
Nov 06, 2017 17:42:42 UTC [Mapped Input: PARAM1 = 1]
Nov 06, 2017 17:42:42 UTC [Mapped Input: PARAM2 = FABRIC-LOGIN-T52]
Nov 06, 2017 17:42:42 UTC [Mapped Input: SearchColumn = 5]
Nov 06, 2017 17:42:42 UTC [Mapped Input: SearchValue = 50:0a:09:83:8f:03:01:b1]
Nov 06, 2017 17:42:42 UTC [Output: ReturnStatus = 0]
Nov 06, 2017 17:42:42 UTC Completed workflow item number 2, with status Completed
Nov 06, 2017 17:42:43 UTC Executing workflow item number 3
Nov 06, 2017 17:42:43 UTC Completed workflow item number 3, with status Completed
Brilliant! Thanks Orf!
Hi Orf
This one really works , even in version 6.7 for build in reports thanks
Question: is it only showing the first "Match" not all occurrence in a column ?
yes currently it returns the first match. But you have access to the custom task and java script code and that can easly be changed.
You would have to add the results together . a=a+","+result in a comma separated list.
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: