Junos Automation (Scripting)
Junos Automation (Scripting)

Running script on multiple devices with space, showing result on one page

09.29.16   |  
‎09-29-2016 11:51 AM

Say that i have this really small script used here https://forums.juniper.net/t5/Automation/Scripting-How-To-Displaying-script-results/ta-p/279245 (not nececary this scritpt, but something similar that just is supposed to display info from the device)

 

version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";
/* Junos Space annotations */
/* @CONTEXT = "/device" */
/* @NAME = "System Processes" */
/* @DESCRIPTION = "show system processes" */
/* @ISLOCAL = "true" */

var $local = jcsSmiley Surprisedpen();
match / {
<op-script-results> {
var $command = <command> "show system processes extensive";
var $results = jcs:execute( $local , $command );
copy-of $results;
var $close-results = jcs:close( $local);
<output> {
<html> {
<body> {
}
}
}
}
}

}
}

 

If i run the script on multiple devices, how do i get the result in one page?

 

4 REPLIES
Junos Automation (Scripting)

Re: Running script on multiple devices with space, showing result on one page

09.29.16   |  
‎09-29-2016 12:28 PM

If it's an op script, your best bet is to run it off box using either Juise (SLAX) or use PyEZ (python) to gather the data from all of the devices and put into the same file.  

 

Edward Arcuri
Architect - Automation & Programmability, JDI
Junos Automation (Scripting)
Solution
Accepted by topic author fisk4
‎09-29-2016 01:05 PM

Re: Running script on multiple devices with space, showing result on one page

09.29.16   |  
‎09-29-2016 01:01 PM

re:  "If i run the script on multiple devices, how do i get the result in one page?"


That script you posted has annotations indicating it's a local script, to be executed from Junos Space.   If you want to be able to repeat the same operation across multiple (selected from the Space UI) devices, AND keep the output in a single stream, then you'd need to modify your script so that it can understand it's going to need to work over a GROUP of devices -- not just one.   You do this by adding these annotations:

 

/* @EXECUTIONTYPE = "GROUPEDEXECUTION" */

/* @PASSDEVICECREDENTIALS = "true" */

 

 

Once you've done that, then Space will happily pass the id & credentials for all selected devices. Your script will be resposible for parsing out the selected device ip address, user credentials etc.

Once you have that, then you can just iterate through the list of devices, executing the commands and appending/annotating each device's output until you're done.

 

If that's something you're up for, I think there are some examples Andy did floating around here -- some of which may have even made it into the online help in Space. (not 100% sure on that second thing.)

 

/doug

 

 

 

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Junos Automation (Scripting)

Re: Running script on multiple devices with space, showing result on one page

09.29.16   |  
‎09-29-2016 01:07 PM

Thanks it was this kind of annotations and guideline i was looking for!

Highlighted
Junos Automation (Scripting)

Re: Running script on multiple devices with space, showing result on one page

09.29.16   |  
‎09-29-2016 01:13 PM

You're welcome and best of luck.

Check back in here if you get stumped.

/doug

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST