[j-nsp] NSM API resources with SRX

Pavel Lunin plunin at senetsy.ru
Mon Jan 23 11:31:24 EST 2012


23.01.2012 18:42, Dan Chevrie wrote:
> thanks alot Pavel.
>
> if possible, please share some example scripts which can be utilize to 
> push SRX configuration etc.?
>
Let me give you these links instead :)

http://www.juniper.net/support/products/netconf/11.4/#doc
http://www.juniper.net/us/en/community/junos/training-certification/day-one/automation-series/
http://www.juniper.net/us/en/community/junos/script-automation/library/


When you need to automate some one-time template pushing or even 
relatively simple recurring config change, especially if it does not 
rely on the current device state, you can just simply push a bunch of 
commands though ssh. All you need is to configure rsa-keys to avoid 
password auth. This approach works for any ssh CLI :)

Like this:
> user at plunin:~$
> user at plunin:~$ cat ./set-descr.txt
> conf
> set interface ge-0/0/19 descr "blah 1"
> commit
> q
> user at plunin:~$ cat ./del-descr.txt
> conf
> del interface ge-0/0/19 descr
> commit
> q
> user at plunin:~$
> user at plunin:~$
> user at plunin:~$ ssh junos-device.lab<  ./set-descr.txt
> Pseudo-terminal will not be allocated because stdin is not a terminal.
> user at junos-device.lab>  configure
> Entering configuration mode
> [edit]
> user at junos-device.lab# set interfaces ge-0/0/19 description "blah 1"
> [edit]
> user at junos-device.lab# commit
> configuration check succeeds
> commit complete
> [edit]
> user at junos-device.lab# quit
> Exiting configuration mode
> user at junos-device.lab>  
> user at plunin:~$
> user at plunin:~$ ssh junos-device.lab "show int ge-0/0/19 | match descr"
>    Description: blah 1
> user at plunin:~$
> user at plunin:~$ ssh junos-device.lab<  ./del-descr.txt
> Pseudo-terminal will not be allocated because stdin is not a terminal.
> user at junos-device.lab>  configure
> Entering configuration mode
> [edit]
> user at junos-device.lab# delete interfaces ge-0/0/19 description
> [edit]
> user at junos-device.lab# commit
> configuration check succeeds
> commit complete
> [edit]
> user at junos-device.lab# quit
> Exiting configuration mode
> user at junos-device.lab>  
> user at plunin:~$
> user at plunin:~$ ssh junos-device.lab "show int ge-0/0/19 | match descr"
> user at plunin:~$
> user at plunin:~$
Don't ask me, how to do this under Windows, I don't know :)

Sometimes it's preferable to generate a piece of JUNOS text config (with 
curly brackets, like in the show command output) or in a form of normal 
JUNOS patch (like in the 'show | compare' command output), than copy it 
as a file to the device using scp and issue (remotely with ssh as shown 
above) something like "load merge <filename>" or "load patch <terminal>".

--
Pavel


More information about the juniper-nsp mailing list