Interface ge-0/0/0 was already configured and placed in the VRF, but not ge-0/0/10
user@router# show interfaces
ge-0/0/0 {
vlan-tagging;
unit 1000 {
vlan-id 1000;
family inet {
address 100.1.1.1/24;
}
}
}
ge-0/0/10 {
vlan-tagging;
unit 1000 {
vlan-id 1000;
family inet {
address 200.1.1.1/24;
}
}
}
lo0 {
unit 0 {
family inet {
address 1.1.1.1/32;
}
}
}
{master:0}[edit]
user@router# show routing-instances VRF1000
instance-type vrf;
interface ge-0/0/0.1000;
route-distinguisher 100:100;
vrf-target target:1001:100;
vrf-table-label;
Now if a user commits it, the script will automatically correct config by adding the missing interface
{master:0}[edit]
user@router# commit
warning: warning message - found int in vrf VRF1000 ge-0/0/0.1000
warning: warning message - adding to vrf VRF1000 missing int ge-0/0/10.1000
configuration check succeeds
commit complete
{master:0}[edit]
user@router# show routing-instances VRF1000
instance-type vrf;
interface ge-0/0/0.1000;
interface ge-0/0/10.1000;
route-distinguisher 100:100;
vrf-target target:1001:100;
vrf-table-label;
{master:0}[edit]
scripts {
commit {
file vrf.slax;
}
}
Here's the code:
------------------------
user@router> file show /var/db/scripts/commit/vrf.slax
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";
var $top = .;
var $interfaces = interfaces/interface;
var $vrf = "VRF1000";
var $ifname = ../name _ "." _ name;
<xnm:warning> {
<message> "warning message - found int in vrf VRF1000 " _ $ifname;
}
}
else {
<xnm:warning> {
<message> "warning message - adding to vrf VRF1000 missing int " _ $ifname;
}
var $dot = $top/routing-instances/instance[name == $vrf];
var $content = <interface> {
<name> $ifname;
}
call jcs:emit-change($dot, $content);
}
}
}
No comments:
Post a Comment