[135803] in North American Network Operators' Group

home help back first fref pref prev next nref lref last post

RE: Upload config to juniper

daemon@ATHENA.MIT.EDU (Mark Bassett)
Fri Jan 28 20:46:39 2011

Date: Fri, 28 Jan 2011 17:44:30 -0800
In-Reply-To: <8E80582D6651CB47BE5B9CE81D63D0480D09D5F8@exchange2.intelius1.intelius.com>
From: "Mark Bassett" <mbassett@intelius.com>
To: "Mark Bassett" <mbassett@intelius.com>, "Jimmy Hess" <mysidia@gmail.com>, 
	"Florin Veres" <florin@futurefreedom.ro>
Cc: nanog@nanog.org
Errors-To: nanog-bounces+nanog.discuss=bloom-picayune.mit.edu@nanog.org

I use the Netconf API  and send xml config snippets like so:

<configuration>
 <security>
  <zones>
   <security-zone>
    <name>Untrust</name>
     <address-book>
      <address operation=3D"delete">
       <name>auto_ip-7</name>
       <ip-prefix>67.23.7.115/32</ip-prefix>
      </address>
      <address-set>
       <name>demo_inbound_permit</name>
       <address operation=3D"delete">
       <name>auto_ip-7</name>
       </address>
      </address-set>
     </address-book>
   </security-zone>
  </zones>
 </security>
</configuration>

-----Original Message-----
From: Mark Bassett [mailto:mbassett@intelius.com]=20
Sent: Friday, January 28, 2011 5:39 PM
To: Jimmy Hess; Florin Veres
Cc: nanog@nanog.org
Subject: RE: Upload config to juniper

Actually if you use the JUNOS api and the reference scripts there are
examples to do just this.



-----Original Message-----
From: Jimmy Hess [mailto:mysidia@gmail.com]=20
Sent: Wednesday, January 26, 2011 6:31 PM
To: Florin Veres
Cc: nanog@nanog.org
Subject: Re: Upload config to juniper

On Mon, Jan 24, 2011 at 7:39 AM, Florin Veres <florin@futurefreedom.ro>
wrote:
> Hey guys,
> Do any of you have any idea if it's possible to upload configuration
from a
> script (prefix-list updates in this case) to a JunOS device (MX)?
> For Cisco devices I'm doing it using rcp.

>From config mode use  a  "load merge"  command that specifies a SCP or
FTP  URL.
You'll need to setup SSH keys in advance to do so  without an
additional password for the device to download the script.

Alternatively...  SCP the file to a temporary file on the device then
"load merge" the uploaded file,  to merge config from the script.

Net::SSH::Expect from CPAN  to connect  via  ssh  from perl.

Something like
use Net::SSH::Perl;
use Net::SSH::Expect;

my $ssh =3D Net::SSH::Expect->new(  host =3D>
'myfavoritehostname.example.com',  user =3D> 'blahblahblah', password =
=3D>
'1234',   raw_pty =3D> 1);
$ssh->login(q[blahblah@myfavoritehostname.example.com's password]);
$output1 =3D $ssh->exec("configure private");
# $blah =3D $ssh->exec("load merge
username@scriptserver.example.com:/path/to/scriptfile_to_load.txt");
print scalar $ssh->exec("show | compare");
# commit

--
-JH




home help back first fref pref prev next nref lref last post