[j-nsp] Need help with event script

Alexander Shikoff minotaur at crete.org.ua
Fri Oct 23 13:13:48 EDT 2009


On Fri, Oct 23, 2009 at 08:46:34AM -0700, Curtis Call wrote:
> This is PR 436135, fixed in 9.5R2 and above.  Basically, if you are running on an unfixed version, and your event scripts are enabled via "event-options event-script" then there is a chance that your arguments will have a space appended to them.
> 
> You'll want to include workaround code like this:
> 
> var $fixed-argument = {
>     var $length = string-length( $argument );
>     if( substring( $argument, $length ) == " " ) {
>         expr substring( $argument, 1, $length - 1 );
>     }
>     else {
>         expr $argument;
>     }
> }
Thank you, Curtis!
We're using 9.5R1.8. Your workaround was helpful.
We will consider upgrading to 9.5R2.
 
> > -----Original Message-----
> > From: juniper-nsp-bounces at puck.nether.net [mailto:juniper-nsp-
> > bounces at puck.nether.net] On Behalf Of Alexander Shikoff
> > Sent: Friday, October 23, 2009 7:28 AM
> > To: juniper-nsp at puck.nether.net
> > Subject: [j-nsp] Need help with event script
> > 
> > Hello!
> > 
> > I'm trying to make changes of run-time configuration based on time of
> > day.
> > I want simple event script to change policer on interface at given
> > time.
> > Script is quite simple (see below).
> > event-options are configured as follows:
> > 
> > [edit event-options]
> > minotaur at br1-gdr.ki# show
> > generate-event {
> >     Start-Business-Time time-of-day "17:07:00 +0300";
> > }
> > policy Modify-Speeds-to-World {
> >     events Start-Business-Time;
> >     then {
> >         event-script change-policer.slax {
> >             arguments {
> >                 interface ge-0/0/0;
> >                 unit 400;
> >                 policer-in pol-50Mbit;
> >                 policer-out pol-50Mbit;
> >             }
> >         }
> >     }
> > }
> > event-script {
> >     file change-policer.slax;
> > }
> > traceoptions {
> >     file events.log;
> >     flag events;
> >     flag server;
> >     flag policy;
> > }
> > 
> > 
> > 
> > 
> > The problem is that script does not make any changes in configuration
> > and fails to work:
> > [edit event-options]
> > minotaur at br1-gdr.ki# run show log escript.log
> > [...]
> > Oct 23 17:07:05 results of event script
> > Oct 23 17:07:05 begin dump
> > <output>Changing policers on interface ge-0/0/0 .400 </output>Oct 23
> > 17:07:05 end dump
> > Oct 23 17:07:05 results of event script
> > Oct 23 17:07:05 begin dump
> > <output>
> > 
> > 
> > invalid trailing input ' ' for 'ge-0/0/0 '
> > 
> > 
> > 
> > interface
> > statement creation failed
> > 
> > 1
> > </output>Oct 23 17:07:05 end dump
> > Oct 23 17:07:05 finished event script 'change-policer.slax'
> > Oct 23 17:07:05 event script processing ends
> > Oct 23 17:07:07 escriptdefinition script processing begins
> > Oct 23 17:07:07 escriptdefinition script processing ends
> > [...]
> > 
> > I'm wondering where does trailing whitespace appear from? And is that
> > the main
> > reason of execution fault?
> > 
> > Any suggestions? Thanks a lot.
> > 
> > 
> > 
> > 
> >  My script:
> > 
> > version 1.0;
> > 
> > ns junos = "http://xml.juniper.net/junos/*/junos";
> > ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
> > ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
> > 
> > import "../import/junos.xsl";
> > 
> > param $interface;
> > param $unit;
> > param $policer-in;
> > param $policer-out;
> > 
> > match / {
> >  <event-script-results> {
> >   <output> 'Changing policers on interface ' _ $interface _ '.' _
> > $unit;
> > 
> >   var $newcfg = {
> >         <configuration> {
> >          <interfaces> {
> >           <interface> {
> >            <name> $interface;
> >            <unit> {
> >             <name> $unit;
> >             <family> {
> >              <inet> {
> >               <policer> {
> >                <input> $policer-in;
> >                <output> $policer-out;
> >               }
> >              }
> >             }
> >            }
> >           }
> >          }
> >         }
> >   } /* $newcfg */
> > 
> >   var $rpc = jcs:open();
> >   var $results := { call jcs:load-configuration($connection=$rpc,
> > $configuration=$newcfg); }
> > 
> >   <output> $results;
> > 
> >   expr jcs:close( $rpc );
> >  }
> > }
> > 
> > --
> > MINO-RIPE
> > _______________________________________________
> > juniper-nsp mailing list juniper-nsp at puck.nether.net
> > https://puck.nether.net/mailman/listinfo/juniper-nsp
> _______________________________________________
> juniper-nsp mailing list juniper-nsp at puck.nether.net
> https://puck.nether.net/mailman/listinfo/juniper-nsp

-- 
MINO-RIPE


More information about the juniper-nsp mailing list