[j-nsp] [OT] unit-level vs interface-level description

Phil Shafer phil at juniper.net
Fri May 31 13:59:42 EDT 2013


Benny Amorsen writes:
>You could publish a commit script to handle that... That way people can
>install it or not, and it should be a nice example script.

I'd rather not copy the interface description to the unit, since
that will have bigger impact than just SNMP, and there's no existing
way to set an snmp-specific description.  But if you are willing
to affect all non-snmp descriptions, the script would look like:

-----------
version 1.0;

ns jcs extension = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";

match configuration {
    for-each (interfaces/interface[description]/unit[not(description)]) {
        var $content = <description> ../description;
        call jcs:emit-change($content, $tag = "transient-change");
    }
}
-----------

So I'm finding all units without descriptions whose parent have
descriptions, and emitting a change to add the description.  I'm
doing this as a transient change, so they won't appear in the
configuration, but SNMP (and other components) will see them.

Using juise for testing against my local box, I see:

% ./juise/juise -c --output-format compare @dent ~/trash/desc.slax 
...
Results from script:
<configuration-information>
<configuration-output>
[edit interfaces fe-0/0/0 unit 0]
+    description "RLab Mgmt interface";
[edit interfaces fe-0/0/1 unit 0]
+    description "Link to SJC (10.5.10.2)";
[edit interfaces fe-0/0/2 unit 0]
+    description "Link to LAX (10.5.13.2)";
[edit interfaces fe-0/0/3 unit 0]
+    description "Link to carolina-gw";
[edit interfaces so-0/1/0 unit 0]
+    description "Link to RDU (10.5.22.2)";
[edit interfaces so-0/1/1 unit 0]
+    description "Second link to IAD (10.5.114.2)";
[edit interfaces fe-0/2/3 unit 0]
+    description "Second link to IAD (10.5.150.2)";
[edit interfaces fe-0/3/0 unit 0]
+    description "Link to IAD (10.5.14.2)";
[edit interfaces fe-0/3/1 unit 0]
+    description "Link to AUS (10.5.12.2)";
[edit interfaces fe-0/3/2 unit 0]
+    description "Link to ORD (10.5.18.2)";
[edit interfaces fe-0/3/3 unit 0]
+    description "Second link to ORD (10.5.118.2)";
</configuration-output>
</configuration-information>

Thanks,
 Phil


More information about the juniper-nsp mailing list