Automation

last person joined: yesterday 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  Running script on multiple devices with space, showing result on one page

    Posted 09-29-2016 11:51

    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 = jcs:open();
    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?

     


    #Slax


  • 2.  RE: Running script on multiple devices with space, showing result on one page

    Posted 09-29-2016 12:29

    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.  

     



  • 3.  RE: Running script on multiple devices with space, showing result on one page
    Best Answer

    Posted 09-29-2016 13:01

    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

     

     

     



  • 4.  RE: Running script on multiple devices with space, showing result on one page

    Posted 09-29-2016 13:08

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



  • 5.  RE: Running script on multiple devices with space, showing result on one page

    Posted 09-29-2016 13:14

    You're welcome and best of luck.

    Check back in here if you get stumped.

    /doug