cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
800
Views
5
Helpful
3
Replies

Get the parent of a maagic object

sfloresk
Cisco Employee
Cisco Employee

Hello,

Is there a way to obtain the parent container/list of an specific python maagic object?

Thanks

-- Santiago

1 Accepted Solution

Accepted Solutions

vleijon
Cisco Employee
Cisco Employee

Use the _parent member, here is an example from ncs_pycli:

In [1]: d = root.devices.device['router0']

In [2]: dp = d._parent

In [3]: d
Out[3]: ListElement name=device tag=617911018 keys={router0}

In [4]: dp
Out[4]: List name=device tag=617911018

In [5]: dp._path
Out[5]: '/ncs:devices/device'

In [6]: d._path
Out[6]: '/ncs:devices/device{router0}'

View solution in original post

3 Replies 3

vleijon
Cisco Employee
Cisco Employee

Use the _parent member, here is an example from ncs_pycli:

In [1]: d = root.devices.device['router0']

In [2]: dp = d._parent

In [3]: d
Out[3]: ListElement name=device tag=617911018 keys={router0}

In [4]: dp
Out[4]: List name=device tag=617911018

In [5]: dp._path
Out[5]: '/ncs:devices/device'

In [6]: d._path
Out[6]: '/ncs:devices/device{router0}'

Hi Viktor
where is ncs_pycli?  Is it downloadable tool of NSO.  After sourcing ncsrc, and checking path of NSO, I do not see ncs_pycli.
Thanks.

TK

Hello,

It’s available Here