- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 02:46 AM
Hi All,
I wanted to as a basic question re yang leaf refs as i'm just starting with NSO
I have a very simple model, however ,the part i'm struggling to understand is this section below defining the device leaf
The module imports tailf-ncs and so naturally I went looking in that module for /devices/device/name
However when I open tailf-ncs.yang it also imports many other models and I ended up 'down a rabbit hole'
I'm trying to learn so that I understand all parts of the model so would appreciate some assistance and a 'steer' if i'm mis- understanding this and where is should look to follow and understand the leaf ref
Thanks
Rich
leaf device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } }
Model
module access { namespace "http://com/example/access"; prefix access; import ietf-inet-types { prefix inet; } import tailf-ncs { prefix ncs; } list access { key customer-name; uses ncs:service-data; ncs:servicepoint "access"; leaf customer-name { type string; } /* 1 - We import tailf-ncs.yang and give that a prefix of ncs Home@Richs-MacBook-Pro:~/Documents/Programming/nso5.7/src/ncs/yang$ grep -Ril 'list devices' ./ .//tailf-ncs-plan.yang .//tailf-ncs-webui.yang .//tailf-ncs-services.yang .//tailf-ncs-devices.yang */ leaf device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } leaf vlan { mandatory true; type uint16; } leaf access-interface { mandatory true; type string; } leaf trunk-interface { mandatory true; type string; } } }
Solved! Go to Solution.
- Labels:
-
Developer
-
DevOps
-
Other NSO Topics
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 06:38 AM
A leafref is a pointer to another part of the model. The leafref selects the set of leaf instances at the path listed at the "path" substatement. In this case, a leafref pointing to "/ncs:devices/ncs:device/ncs:name" will return the set of all devices configured within NSO. If you configure an instance of your service in NCS CLI and attempt an auto-complete after "device", you will see that the available options for the device leaf are the set of devices configured within NSO.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 06:38 AM
A leafref is a pointer to another part of the model. The leafref selects the set of leaf instances at the path listed at the "path" substatement. In this case, a leafref pointing to "/ncs:devices/ncs:device/ncs:name" will return the set of all devices configured within NSO. If you configure an instance of your service in NCS CLI and attempt an auto-complete after "device", you will see that the available options for the device leaf are the set of devices configured within NSO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 07:00 AM
Hello tcragg1,
Many thanks for the explanation
So does this actually refer to the entries in the CDB files, and I presume, that for any given service, a complete list devices would be available and not just the devices associated with that service ?
import tailf-ncs { prefix ncs; }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 07:32 AM
@rjbotham wrote:
Hello tcragg1,
Many thanks for the explanation
So does this actually refer to the entries in the CDB files, and I presume, that for any given service, a complete list devices would be available and not just the devices associated with that service ?
That's correct. If you use the same leafref in multiple services, they will each have access to the full list of devices configured in NSO.
