cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
490
Views
0
Helpful
3
Replies

NSO 6.1 python API: how to get value of a leaf in container "global"?

JennyW
Level 1
Level 1

The existing yang module has a container named "global", from python when I tried to access the leaf (e.g. delay) using root.xxx.global.delay, the package failed to load because "global" is a keyword in python. Is there another way to access this container in python?

The yang module looks like this:

...
container global {
   ...
   leaf delay {
      type uint32;
      description "xxx";
   }
   ...
}

 

1 Accepted Solution

Accepted Solutions

Just for completeness, other solutions are

root.xxx['global'].delay

or you can use the module prefix. So if global is defined in a yang module with a prefix 'm' you can access 'delay' using

root.xxx.m__global.delay

Note: there is a double underscore

Using the module prefix is mainly to disambiguate when you have two modules both of which use the same identifier, but comes in handy for python keywords as well.

 

View solution in original post

3 Replies 3

JennyW
Level 1
Level 1

Never mind, I think I can use get_elem in Transaction.

Just for completeness, other solutions are

root.xxx['global'].delay

or you can use the module prefix. So if global is defined in a yang module with a prefix 'm' you can access 'delay' using

root.xxx.m__global.delay

Note: there is a double underscore

Using the module prefix is mainly to disambiguate when you have two modules both of which use the same identifier, but comes in handy for python keywords as well.

 

JennyW
Level 1
Level 1

Good to know that, thanks!