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

YANG Service over nested container

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!

 

2 Replies 2

rogaglia
Cisco Employee
Cisco Employee

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.

l00pback
Level 1
Level 1

Try to iterate within your list like this:

 

fake_list = service.addon.fake

for i in fake_list:
    fake_name = i.name