Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

SLAX to clean storage on dual-routing engine MX

‎04-20-2016 09:51 AM

Hi - please could I have some assistance in executing the rpc equivalent of "request system storage cleanup" on the backup re of a dual-routing engine MX.

My SLAX script minus header is:

var $connection = jcs:open() ;

var $configuration = jcs:execute($connection, "get-configuration") ;

/* -------------------------------------------------------------- */

match / { {

  var $hostname = $configuration/system/host-name ;

  var $login_info = jcs:execute($connection, "request-login-to-other-routing-engine") ;

  var $result_info = jcs:execute($connection, "request-system-storage-cleanup") ;

  if( !result_info ) {

     "[" _ $script _ "]: " _ "[" _ $hostname _ "] " _ "Cleanup requested" ;

     expr " Success" ; }

  else {

    var $errstr = "[" _ $script _ "]: " _ "[" _ $hostname _ "] " _ "Cleanup failed: " _ $result_info ;

    expr " Failed" ;

  }

  expr jcs:close($connection) ;

} }

 

But when this executes it just cleans up the storage on re0 and never on the other routing engine. Is there a command or context I can set to execute this command on the backup routing engine? I can't find any examples in the documents about executing commands on the other routing engine. And on this router the backup routing-engine doesn't have an IP address so i can't directly ssh to the backup re.

 

I've tried setting $junos-context/re1 but can't get this to work and it's driving me nuts as it looks such a simpe thing to do. Thanks in advance for any advice Steve

4 REPLIES 4
Highlighted
Junos Automation (Scripting)

Re: SLAX to clean storage on dual-routing engine MX

‎04-20-2016 05:09 PM

See if this article I wrote a while back helps:

 

http://forums.juniper.net/t5/Automation/Scripting-How-To-Coordinate-XML-RPC-data-across-routing-engi...

`

The example code diddles the utility mib on the remote RE, but you should get the gist of it: open a connection to the other RE and invoke the RPCs over it... 

 

HTH

.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: SLAX to clean storage on dual-routing engine MX

‎04-20-2016 05:11 PM

Oh - and you can't *set* anything under $junos-context -- that's read-only.

/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: SLAX to clean storage on dual-routing engine MX

‎04-25-2016 02:06 AM

Thanks for the idea and code snippet.

Steve

Highlighted
Junos Automation (Scripting)

Re: SLAX to clean storage on dual-routing engine MX

‎04-25-2016 06:12 AM

Hope you can make it work.  Check back in if you hit a snag -- and also if it works for you, too. Closure is good.  😉

/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