cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
808
Views
0
Helpful
2
Replies

Query on using instance-identifier yang type

akumartm
Cisco Employee
Cisco Employee

How can I use the "instance-identifier" type to reference an instance of a nested list within a YANG data model? For instance, consider a YANG module where there are two lists, "a" and "b", with "b" nested inside "a". Additionally, there is a leaf "c" within "a", and I want to utilize the "instance-identifier" type for leaf "c" to reference an instance of list "b".

Here is yang structure.
list a {
  key a-key;
  leaf a-key {
    type string;
  }
  list b {
    key b-key;
    leaf b-key {
      type string;
    }
  }
  leaf c {
    type instance-identifier;
  }
}

When I try to configure it from cli, it doesnt show up the instance of list b.
admin@ncs(config)# a test b btest
admin@ncs(config-b-btest)# exit
admin@ncs(config-a-test)# c /a[a-key=test]/b?
Possible completions:
b <cr>
admin@ncs(config-a-test)# c /a[a-key=test]/b
--------------------------------------^
syntax error: The XPath /a[a-key=test]/b doesn't belong to the restricted subset.


Any pointers on this.

2 Replies 2

snovello
Cisco Employee
Cisco Employee
You used the wrong key name and did not quote.
Here are examples of how NSO behaves when you correct ithe sytax
admin@ncs(config-a-test)# c /a[a-key='test']
admin@ncs(config-a-test)# c /test:a[test:a-key='test']
admin@ncs(config-a-test)# c /test:a[test:a-key='test']/test:b
----------------------------^
syntax error: /a/b: Invalid path
admin@ncs(config-a-test)# c /test:a[test:a-key='test']/test:b[test:b-key='btest']
admin@ncs(config-a-test)#

In https://datatracker.ietf.org/doc/html/rfc7950#section-9.13
It says that you also need the preifx everywhere, but NSO accepts an instance identifier without the module prefix.

As you see if the path is to a list rather than to a list-element NSO says the path is invalid (tested on version 6.2)

The RFC mentions the path has to reference a ‘particular instance node’ but I did not find a clear defintion of what that means. I assume it means that some nodes are not allowed otherwise it would have just said ‘node’ or ‘particular node’. The examples given in the RFC do not show an instance-identifier to a list.

akumartm
Cisco Employee
Cisco Employee

Hi, 
Okay, so are we supposed to give a valid input by manually typing the xpath?
Why dont we get it in tab completion?
If I try to use tab completion, It doesn't even show up the instance of nested list.

Polls
AI-powered tools for network troubleshooting are likely to be part of everyone’s workflow sooner or later. What is the single biggest challenge or concern you see with adopting these tools in your organization?