Junos Automation (Scripting)
Reply
Trusted Contributor
BuckWeet
Posts: 159
Registered: ‎08-29-2008
0

Centralized scripts and copying to both routing-engines

I have a question, hopefully someone has an answer..

 

I have setup centralized stored commit scripts, however I'm running into issues with devices (EX and MX) that have redundant routing-engines. The files have to be on both RE's to successfully commit as I use commit sync. How do I get the files on both RE's when using a central server??

 

The documentation says this: "If a platform has dual Routing Engines, you need to refresh the commit scripts on both Routing Engines. The commit synchronize command does not refresh the commit scripts between Routing Engines."

 

That is a very vague statement and gives no options on how to do it.. Also the backup RE has no connectivity to the network, only the primary does.. So how am I supposed to copy the files over?

 

Thanks

 

Chris

Recognized Expert
ccall
Posts: 230
Registered: ‎06-18-2008
0

Re: Centralized scripts and copying to both routing-engines

The first step of a commit sync should be a commit check on the current routing-engine, so you could always include code within the commit script itself to check for its presence on the other routing-engines and to copy itself if appropriate. That action should occur before the other REs realize they don't have the script.

Trusted Contributor
BuckWeet
Posts: 159
Registered: ‎08-29-2008
0

Re: Centralized scripts and copying to both routing-engines

Thanks that's a start, now the next question is how do I get the file to the other RE.. I don't want to have to manually mange the distribution of these scripts..

 

Thoughts?

Recognized Expert
ccall
Posts: 230
Registered: ‎06-18-2008
0

Re: Centralized scripts and copying to both routing-engines

Use the <file-copy> RPC:

 

http://www.juniper.net/techpubs/software/junos/junos93/junos-xml-ref-oper/html/summary-oper-request4...

 

So, your commit script would have something like:

 

var $copy-rpc = {

    <file-copy> {

        <source> "/var/db/scripts/commit/yourfilename";

        <destination> "re1:/var/db/scripts/commit/yourfilename"; /* or fpc#, or whatever */

    }

}

var $results = jcs:invoke( $copy-rpc );

 

To check if the file is there in the first place use the <file-list> rpc:

 

http://www.juniper.net/techpubs/software/junos/junos93/junos-xml-ref-oper/html/summary-oper-request5...

 

 

Trusted Contributor
BuckWeet
Posts: 159
Registered: ‎08-29-2008
0

Re: Centralized scripts and copying to both routing-engines

Okay cool! That helps.. Now the next question as I'm a total non-scripter at all..

 

I am trying to do this on M, MX, and EX devices..  MX's and M's use the 're0/1' concept to name the routing-engines. For the EX devices its fpc#.. Would there be a way to have a single script cover the process for both devices?

 

There also might be cases that there is a single RE, so the script would have to account for that. I assume we'd have to do some kind of invoke to get the hardware model and routing-engine/fpc inventory?

 

 

Thanks for the help so far, its much appreciated!

Recognized Expert
ccall
Posts: 230
Registered: ‎06-18-2008
0

Re: Centralized scripts and copying to both routing-engines

Scripts are all provided a default $product parameter that gives their model. So you can do something like:

 

if( starts-with( $product, "ex" ) )

 

(But I forgot if the ex is capitalized or not).

 

With Junos 10.1 and beyond you can append | display xml rpc to any command to see its rpc equivalent:

 

jnpr@R2D2-M320-RE0> show chassis routing-engine | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.3I0/junos">
    <rpc>
        <get-route-engine-information>
        </get-route-engine-information>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

Otherwise, you can search for the relevant rpc in the docs:

http://www.juniper.net/techpubs/software/junos/junos93/junos-xml-ref-oper/html/junos-xml-ref-operTOC...

Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.