Showing results for 
Search instead for 
Did you mean: 
kerim mohammed

reading configured bgp AS number from nexus device model (NED)



I was trying to read a configured bgp AS number on a cisco-nx device model. the configuration on the device is:

admin@ncs(config)# show full-configuration devices device VDM01 config nx:router bgp | display xpath


however, exception is thrown when trying to access this config from the java mapping logic. The java line of code used to access the bgp AS number on the above device is(line 77):


String spine_AS= allDevices.elem(spineName).container("config").container("nx:router").list("bgp").leaf("id").valueAsString();


the exception the above line throws is shown below. any suggestion?


<ERROR> 24-Oct-2018::22:20:04.889 DpTrans Did-150-Worker-108: - Exception in callback
com.tailf.dp.DpCallbackException: Not Leaf element
at com.example.slebgp.slebgpRFS.create(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.tailf.dp.annotations.ServiceCallbackProxy.create(
at com.tailf.dp.DpTrans.protoCallback(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: com.tailf.navu.NavuException: Not Leaf element
at com.tailf.navu.NavuNode.leaf(
at com.example.slebgp.slebgpRFS.create(
... 12 more




Cisco Employee

Hi Kerim,


What version of the cisco-nx NED are you using?




Hi Max,


here are package's version:


admin@ncs# show packages package build-info package version
YourL2VPN -
arista-dcs 3.1.25
cisco-ios 5.9.2
cisco-iosxr 5.3.1
cisco-nx 5.1
navutest -
sl-ebgp -

Hi Kerim,


I'd advise you to open a TAC case on this one as this definitely appears to be unexpected behavior.





No, I think this is expected behaviour. Look at the xpath:

You can see that bgp is a list (which is indeed correctly reflected in the python code). However, a list doesn’t contain any leafs, it contains contains list elements. You cannot use .leaf() on it, you have to use something like .keys() or just iterate over the list.


Hi Viktor,


I will have to agree with Max. a list can contain leaf nodes. the key of a list is nothing but a leaf node. I have several programs where I accessed the key leaf with leaf node name. I think it is an anomaly. Let me know if you have a better explanation. Fyi, it is java and not python.





Spoke to Viktor and it's clear he's right here. In this case there can be multiple bgp ids so it'd be the equivalent of a list inside a list. Hence the error.


Hi Viktor,


Thanks for weighing in here. I looked at the yang 1.1 RFC, and it appears to be a supported substatement:


7.8.1. The list's Substatements

                 | substatement | section | cardinality |
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | key          | 7.8.2   | 0..1        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | max-elements | 7.7.6   | 0..1        |
                 | min-elements | 7.7.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | ordered-by   | 7.7.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | unique       | 7.8.3   | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |


Lets see if I can try to explain this in a good way since it is clearly not easy.


So, there is a difference between the data model and the instance model. You are perfectly correct that a list in the data model can contain leafs. But, if you look at the instance model, you can imagine that you have multiple bgp elements (ignore the fact that the device may constrain this, the data model doesn't know):




Then when you do allDevices.elem(spineName).container("config").container("nx:router").list("bgp") you have multiple options in the bgp list. So, you have to get the right element. Now, you can do .elem(100).leaf("id"), but then you clearly have to already know the id so in practice you end up iterating over the list to find the keys.


Note that a list is essential a sequence of containers. A leaf-list is simpler and is just a sequence of primitive types.


Hopefully this is more helpful.

so in other words back to square one. nice explanation. I just couldn't find new information in it. or something that leads me to the solution. thanks for taking the time though. 

I question the NED. it assumes multiple bgp instances on a single device. there are devices that support multiple bgp instances in relation to SDN but I don't think Cisco-NX is in that category. I will what TAC got to say.


thanks guys!