10-25-2018 05:01 AM - edited 03-01-2019 04:14 AM
Hi,
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
/devices/device[name='VDM01']/config/nx:router/bgp[id='10']/address-family[proto='ipv4'][type='unicast']
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(slebgpRFS.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.tailf.dp.annotations.ServiceCallbackProxy.create(ServiceCallbackProxy.java:121)
at com.tailf.dp.DpTrans.protoCallback(DpTrans.java:1688)
at com.tailf.dp.DpTrans.read(DpTrans.java:645)
at com.tailf.dp.DpTrans.run(DpTrans.java:374)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.tailf.dp.DpThread.run(DpThread.java:41)
Caused by: com.tailf.navu.NavuException: Not Leaf element
at com.tailf.navu.NavuNode.leaf(NavuNode.java:977)
at com.example.slebgp.slebgpRFS.create(slebgpRFS.java:77)
... 12 more
thanks,
Kerim
10-25-2018 09:25 AM
Hi Kerim,
What version of the cisco-nx NED are you using?
Thanks,
Max
10-25-2018 11:04 AM
Hi Max,
here are package's version:
admin@ncs# show packages package build-info package version
NAME VERSION
----------------------
YourL2VPN -
arista-dcs 3.1.25
cisco-ios 5.9.2
cisco-iosxr 5.3.1
cisco-nx 5.1
navutest -
sl-ebgp -
10-25-2018 12:44 PM
Hi Kerim,
I'd advise you to open a TAC case on this one as this definitely appears to be unexpected behavior.
Thanks,
Max
10-25-2018 01:30 PM
10-25-2018 01:57 PM
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.
thanks,
Kerim
10-25-2018 02:01 PM - edited 10-25-2018 02:12 PM
edit:
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:
+--------------+---------+-------------+ | 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 | +--------------+---------+-------------+
10-25-2018 02:22 PM
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):
/devices/device[name='VDM01']/config/nx:router/bgp[id='10']/address-family[proto='ipv4'][type='unicast']
/devices/device[name='VDM01']/config/nx:router/bgp[id='100']/address-family[proto='ipv4'][type='unicast']
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.
10-25-2018 04:21 PM
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.
10-25-2018 04:26 PM
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!
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