10-15-2020 12:58 AM
Hi All,
I am exploring the power of NSO and hit some kind of fundamental question about the service structure in Python. I have the following YANG file
container devices { tailf:info "Main Container"; list device { tailf:info "Device List"; key name; leaf name { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } leaf location { type leafref { path "../../../locations/location/name"; } } leaf mgmt-host { type tailf:ipv4-address-and-prefix-length; } container addon { tailf:info "Extra Container"; leaf qos { type leafref { path "../../../../qos-policy/qos/name"; } } leaf policy-name { type string; } leaf milliseconds { type uint8; } list fake { key name; leaf name { type string; } } } uses ncs:service-data; ncs:servicepoint l3vpn-servicepoint; }
I can access the element from the devices list & attributes as well as qos leaf
device = root.vpn__vpn.vpn__sites.vpn__devices.vpn__device[service.name] self.log.info(device.name) self.log.info(device.location) qos = service.addon.qos self.log.info(qos)
However I cannot accces the fake list element, I tried a lot of combinations however it does not work
fake_container = device.addon.fake[service.name]
fake_container = device.addon.fake[service.qos.name]
Can anyone tell me what I am doing here wrong?
Thanks!
10-15-2020 07:14 AM
Hard to know without the error messages. I would recommend you to iterate the list using a for loop and print the available keys in the log file and compare with the value you are trying to access.
10-16-2020 04:46 AM - edited 10-16-2020 11:40 AM
Try to iterate within your list like this:
fake_list = service.addon.fake for i in fake_list: fake_name = i.name
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