Junos Automation (Scripting)
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 83
Registered: ‎10-01-2013
0 Kudos
Accepted Solution

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

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?

 

Juniper Employee
Posts: 16
Registered: ‎10-18-2012
0 Kudos

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

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
Super Contributor
Posts: 155
Registered: ‎04-27-2010

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

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
Contributor
Posts: 83
Registered: ‎10-01-2013
0 Kudos

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

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

Highlighted
Super Contributor
Posts: 155
Registered: ‎04-27-2010
0 Kudos

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

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