Greetings,
This is my first go at a Op script, so please bear with me 🙂
I'm trying to accomplish the following: copy any lldp-remote-system-name found, into the appropriate interface description.
Example:
user@system> show lldp neighbors
ge-0/0/7.0 A0:B0:C0:D0:E0:F0 eth0 node2.foo.bar
Would result in:
ge-0/0/7 {
description "node2.foo.bar"
unit 0 {
.......
}
Currently i have a working Op script, but the script commits on every found "lldp-remote-system-name"
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 / {
<op-script-results> {
var $lldp = {
<get-lldp-neighbors-information> {
}
}
var $lldp_out = jcs:invoke($lldp);
for-each ($lldp_out/lldp-neighbor-information) {
var $interface_lldp = substring-before(lldp-local-port-id, ".");
var $interface_lldp_description = lldp-remote-system-name;
var $configuration-change = <configuration> {
<interfaces> {
<interface> {
<name>$interface_lldp;
<description>$interface_lldp_description;
}
}
}
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);
}
}
}
So the question is, how can i commit outside of the "for-each" loop and retain multiple interface configuration blocks(more than one found lldp neighbor)
Anyone have so pointers to the docs, or a example at hand?
Thanks,
Tim