Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

Op script on MX480 - commit in private mode

‎03-18-2015 03:50 AM

Hi all,

 

I'm writing an op script that should make some configuration changes and commit them.

It works fine when using jcs:load-configuration, but the problem is that it works in exclusive mode only.

 

In production environment I would need to use private mode, because often there are multiple users making changes simultaneously.

 

Is it possible?

 

Thank you,

 

 

 

4 REPLIES 4
Highlighted
Junos Automation (Scripting)
Solution
Accepted by topic author makurek
‎08-26-2015 01:27 AM

Re: Op script on MX480 - commit in private mode

‎03-18-2015 07:33 AM

Yes, you can do it yourself in private mode.  Something like this:

 

var $connection = jcs:open();

 

var $edit-private = <open-configuration> { <private>; }

 

/* adding the log message is optional, but considerate */

var $commit-config = <commit-configuration> { <log> "Changed by script: " _ $script; }

 

var $configuration = <load-configuration> {

     <configuration> {

        /* stuff goes here */

    }

 

/* please check/report on errors or warnings on each of $res1-4 */

var $res1 = jcs:execute( $connection, $edit-private );    /* open private session */

var $res2 = jcs:execute( $connection, $configuration );   /* load your config change */
var $res3 = jcs:execute( $connection, $commit-config );  /* commit your config */
var $res4  = jcs:execute( $connection, 'close-configuration' );  /* close up */


expr jcs:close( $connection );    /* may not be needed if script is exiting here */


}

 

 

 

hope that helps

/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
Highlighted
Junos Automation (Scripting)

Re: Op script on MX480 - commit in private mode

‎03-18-2015 08:36 AM

Hi Doug,

 

Thank you very much for your reply. I'll try this tomorrow and let you know if it worked for me.

 

Cheers,

Marcin

Highlighted
Junos Automation (Scripting)

Re: Op script on MX480 - commit in private mode

‎03-19-2015 07:17 AM

Hi Doug,

 

I wrote my op script today and it works fine on SRX. I will test it on MX soon, but I expect should work fine as well.

 

Thanks for your help!

 

 

Highlighted
Junos Automation (Scripting)

Re: Op script on MX480 - commit in private mode

‎03-19-2015 12:52 PM

You're quite welcome.  Glad to help!

/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
Feedback