cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
330
Views
5
Helpful
1
Replies

Unable to get the same results, navigate in Maagic with ncs_pycli

Hello, I am trying to access nso service attributes with ncs_pycli to write a code in python.

This works and I can navigate to all services:

In [12]: for i in root.ncs__services:
...:
...: print(i)
...:
ncs:global-settings
ncs:properties
ncs:customer-service
ncs:service
ncs:logging
ncs:commit-queue-notifications
ncs:plan-notifications
device-provisioning:device-provisioning
leaf-sw:leaf-sw
sbc-vpn:sbc-vpn
vpn:vpn
ncs:check-sync

and for vpn service works as well, I can retrieve the vrf id:

 

In [4]: for i in root.ncs__services.vpn:
...:
...: print(i.vrf)
...:
...:
...:
555

 

sbc-vpn service is not recognized and I can not access any attribute, has the same service skeleton(python):

In [5]: for i in root.ncs__services.sbc-vpn:
...:
...: print(i.vrf-id)
...:
...:
...:
...:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/site-packages/ncs_pycli/ncs_pycli.py in <module>
----> 1 for i in root.ncs__services.sbc-vpn:
2
3 print(i.vrf-id)
4
5

~/nso-5.6.1/src/ncs/pyapi/ncs/maagic.py in __getattr__(self, name)
476 return child
477 else:
--> 478 super(Node, self).__getattribute__(name)
479
480 def __setattr__(self, name, value):

AttributeError: 'Container' object has no attribute 'sbc'

In [6]:

 

 

1 Accepted Solution

Accepted Solutions

rhinst001
Level 4
Level 4

Hyphen is not a valid character in a python variable, so you need to use underscore in its place when you're using maagic:

 

for i in root.ncs__services.sbc_vpn:
    print(i)

 

View solution in original post

1 Reply 1

rhinst001
Level 4
Level 4

Hyphen is not a valid character in a python variable, so you need to use underscore in its place when you're using maagic:

 

for i in root.ncs__services.sbc_vpn:
    print(i)