[j-nsp] Need help with event script
Alexander Shikoff
minotaur at crete.org.ua
Fri Oct 23 10:27:31 EDT 2009
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
More information about the juniper-nsp
mailing list