12-23-2020 03:07 AM
Hi everyone, I have the following problem:
I created a simple loopback-service to get myself familiar with NSO. I created the necessary YANG and XML files (see below). I compiled the YANG file, and reloaded the packages in the NSO CLI, so there shouldn't be a problem on that side. My device is a simple ios device which I created with netsim. However when I apply my loopback-service to that device and then do a "commit dry-run outformat native", the result is empty, which means the configuration is not going to be applied correctly. After commiting, I can't see the configured Loopback in the running-config of the device.
Here the YANG file:
module loopback-service {
namespace "http://com/example/loopbackservice";
prefix loopback-service;
import ietf-inet-types {
prefix inet;
}
import tailf-ncs {
prefix ncs;
}
list loopback-service {
key device;
uses ncs:service-data;
ncs:servicepoint "loopback-service";
leaf device {
type leafref {
path "/ncs:devices/ncs:device/ncs:name";
}
}
list Loopbacks {
key loid;
leaf loid {
type uint32;
description "Loopback Interface number";
}
leaf vrfname {
type string;
description "VRF Name";
}
leaf ipadd {
type inet:ipv4-address;
description "IP-Address";
mandatory true;
}
}
}
}
<config-template xmlns="http://tail-f.com/ns/config/1.0"
servicepoint="loopback-service">
<devices xmlns="http://tail-f.com/ns/ncs">
<device>
<!--
Select the devices from some data structure in the service
model. In this skeleton the devices are specified in a leaf-list.
Select all devices in that leaf-list:
-->
<name>{/device}</name>
<config>
<interface xmlns="urn:ios">
<Loopback>
<name>{/loid}</name>
<ip-vrf>
<ip>
<vrf>
<forwarding>{/vrfname}</forwarding>
</vrf>
</ip>
</ip-vrf>
<ip>
<address>
<primary>
<address>{/ipadd}</address>
<mask>255.255.255.255</mask>
</primary>
</address>
</ip>
</Loopback>
</interface>
</config>
</device>
</devices>
</config-template>
loopback-service c0 Loopbacks 123 ipadd 1.2.3.4 vrfname v-private
And the resulting dry-run outformat native is empty; the xml outformat looks like this:
result-xml {
local-node {
data <loopback-service xmlns="http://com/example/loopbackservice">
<device>c0</device>
<Loopbacks>
<loid>123</loid>
<vrfname>v-private</vrfname>
<ipadd>1.2.3.4</ipadd>
</Loopbacks>
</loopback-service>
}
}
What am I missing? Why is the service not applied to my device?
Any help would be greatly appreciated, thanks in advance,
Robin
Solved! Go to Solution.
01-04-2021 01:14 AM
Found already a solution, the problem was in my xml-file. The variables "loid", "ipadd" and "vrfname" are inside the list "Loopbacks" (see yang file), and when I want to reference those leafs in the xml file, I need to specify that list as well. For example, in the xml file I need to reference the leaf "loid" with /Loopbacks/loid and not only with /loid.
12-30-2020 10:46 AM
01-04-2021 01:14 AM
Found already a solution, the problem was in my xml-file. The variables "loid", "ipadd" and "vrfname" are inside the list "Loopbacks" (see yang file), and when I want to reference those leafs in the xml file, I need to specify that list as well. For example, in the xml file I need to reference the leaf "loid" with /Loopbacks/loid and not only with /loid.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide