![]() |
News | Profile | Code | Photography | Looking Glass | Projects | System Statistics | Uncategorized |
Blog |
Well, it's official. I suck at SLAX. I managed to find myself in a small situation at work where I needed to create an op script that's called by some conditions under event-options. Anyway, I always get stuck on the most simplest of things with SLAX and today was no different.
I couldn't figure out how to activate and deactivate portions of the Junos configuration, of all things. I'm talking about stuff like this:
{master:0}[edit] prox@enterprise# show protocols bgp { group foobar { peer-as 64512; neighbor 10.0.0.2; } } {master:0}[edit] prox@enterprise# deactivate protocols bgp group foobar {master:0}[edit] prox@enterprise# show protocols bgp { inactive: group foobar { peer-as 64512; neighbor 10.0.0.2; } } {master:0}[edit] prox@enterprise# activate protocols bgp group foobar {master:0}[edit] prox@enterprise# show protocols bgp { group foobar { peer-as 64512; neighbor 10.0.0.2; } }
For some reason, this was not easily searchable on Google or Bing. I did manage to figure it out, though. To deactivate a piece of the configuration, do the following:
var $config-change = <configuration> { <protocols> { <bgp> { <group inactive="inactive"> { <name> foobar; } } } } var $connection = jcs:open(); var $results := { call jcs:load-configuration( $connection, $configuration = $config-change ); } if( $results//xnm:error ) { for-each( $results//xnm:error ) { <output> message; } } var $close-results = jcs:close($connection);
The above was easily found by just doing something like "show configuration protocols bgp | display xml" on the CLI. However, what I wasn't able to find was how to activate the section, again:
var $config-change = <configuration> { <protocols> { <bgp> { <group active="active"> { <name> foobar; } } } } var $connection = jcs:open(); var $results := { call jcs:load-configuration( $connection, $configuration = $config-change ); } if( $results//xnm:error ) { for-each( $results//xnm:error ) { <output> message; } } var $close-results = jcs:close($connection);
The active="active" piece was all that was needed.
I really would prefer to code op scripts in Perl or Python but I don't think I have much of an option when calling them from event-options. Oh well.
Speaking of Cisco.. I was going to mention here that I would rather code in TCL!
New comments are currently disabled for this entry.
![]() ![]() ![]() ![]() ![]() |
This HTML for this page was generated in 0.000 seconds. |
Clearly, the SLAX language fits the bill in ways that aren't utterly useful to the programer. But it fits a purpose. Funny, when I look at this it reminds me of the now defunct Cisco KLEM ATE language I learned years ago.