Discovery Pattern Looping

garylfry
Tera Contributor

Is it possible to perform a loop within a pattern?  We have a EMC Isilon Storage device that has multiple zones.  File shares can be assigned to any of those zones.  I can call a RestAPI to retrieve all zones but need to loop through the results and make another call to the RestAPI call to retrieve the smb and nfs shares within that zone.  Is that possible or is there another way to handle it?

10 REPLIES 10

johnnyjava
Kilo Guru

You would put all the zones in a table and then Transform the table and call that API using EVAL() on each row putting the shares into a new column in each row.

 

for example in the EVAL() you could put this:

 

var rtrn = '';
 
var command =  "show lb vserver " + ${vserversTable[].vsvrName};
var rule_def = CTX.getCommandManager().shellCommand(command, false, null, null, CTX);
rtrn = rule_def; 

Which would run the command for each vsvrName in the vserversTable and store the output into whichever column name the Transform table operation was set to hold that output in.

Excellent advice, thanks I appreciate the quick reply

Surely - so, with table variables, the "tableName[].column" means this particular row being processed. the "tableName[*].column" means all the values for the columns at once. Be careful to notice that the autocomplete will usually put the * in there.

daniel_badyan
ServiceNow Employee
ServiceNow Employee

excellent advice from john, just wanted to point out Isilon discovery was released(if i'm not mistaken) in the October content shipping package available in the ITOM store. have you tried it out? it might fit your devices configuration. 

here is the official documentation:

https://docs.servicenow.com/bundle/store-it-operations-management/page/product/itom/concept/emc-isilon-discovery.html