Here is a simple event script version:
Verification that the metric isn't present.
> show configuration protocols ospf
area 0.0.0.0 {
interface ge-0/0/0.0;
}
The event policy configuration, based on just a single time-event for simplicity of testing.
> show configuration event-options
generate-event {
myEventTrigger time-of-day "10:30:00 +0000";
}
policy myEventTrigger {
events myEventTrigger;
then {
event-script myEvent.slax;
}
}
event-script {
file myEvent.slax;
}
The event script itself:
% cat /var/db/scripts/event/myEvent.slax
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";
match / {
<event-script-results> {
var $configuration-change = <configuration>{
< protocols> {
<ospf> {
<area> {
<name> "0.0.0.0";
<interface> {
<name> "ge-0/0/0";
<metric> "10";
}
}
}
}
}
var $connection = jcs:open();
var $results := { call jcs:load-configuration( $connection, $configuration = $configuration-change ); }
if( $results//xnm:error ) {
for-each( $results//xnm:error ) {
<output> message;
}
}
var $close-results = jcs:close($connection);
}
}
Finally, the results once the script has executed:
> show system uptime
Current time: 2016-01-11 10:24:53 UTC
> show configuration protocols ospf
area 0.0.0.0 {
interface ge-0/0/0.0;
}
show system uptime
Current time: 2016-01-11 10:31:10 UTC
> show configuration protocols ospf
area 0.0.0.0 {
interface ge-0/0/0.0 {
metric 10;
}
}
> show log escript.log
.
.
.
Jan 11 10:30:01 event script processing begins
Jan 11 10:30:01 reading event details
Jan 11 10:30:01 testing event details
Jan 11 10:30:01 running event script 'myEvent.slax'
Jan 11 10:30:01 opening event script '/var/db/scripts/event/myEvent.slax'
Jan 11 10:30:01 reading event script 'myEvent.slax'
Jan 11 10:30:56 event script output
Jan 11 10:30:56 begin dump
<?xml version="1.0"?>
<event-script-results xmlns:junos="http://xml.juniper.net/junos/*/junos" xmlns:xnm="http://xml.juniper.net/xnm/1.1/xnm" xmlns:jcs="http://xml.juniper.net/junos/commit-scripts/1.0"/>
Jan 11 10:30:56 end dump
Jan 11 10:30:56 inspecting event output 'myEvent.slax'
Jan 11 10:30:56 finished event script 'myEvent.slax'
Jan 11 10:30:56 event script processing ends
Regards,
Andy