cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
677
Views
5
Helpful
4
Replies

Python runtime Error Cisco-NSO-MPLS-VPN-service-reconciliation-example

ZAhmad04890
Level 1
Level 1

Hi,

while implementing the example located at (https://github.com/NSO-developer/Cisco-NSO-MPLS-VPN-service-reconciliation-example), I am getting python runtime error shown below  on NSO 5.3 and Ubuntu 14.04 LTS.

 

admin@ncs(config)# vpn l3vpn-service-discovery dry-run
Error: Python cb_action error. name 'unicode' is not defined
admin@ncs(config)#

 

the code of this is located at (https://github.com/NSO-developer/Cisco-NSO-MPLS-VPN-service-reconciliation-example/blob/master/packages/l3vpn/python/action.py)

the specific lines of code which relate to error in this example are as below ,kindly advise if the code can be modified to support libraries in NSO-5.3. Thanks.

[.......]

 

@Action.action
def cb_action(self, uinfo, name, kp, input, output):

 

[.......]

 

for interface in cpe_device.config.ios__interface.GigabitEthernet:
     if (interface.description == "%s local network" % service_name):
         endpoint_interface = "GigabitEthernet%s" % interface.name
         int_address= interface.ip.address.primary.address
         int_mask = interface.ip.address.primary.mask
          interface = ipaddress.IPv4Interface(unicode('%s/%s' % (int_address,int_mask), "utf-8"))
         endpoint_network = str(interface.network)

 

[.......]

1 Accepted Solution

Accepted Solutions

Thanks for your reply vleijon, That link is really helpful.

 

only change i did was and it worked!!!

interface = ipaddress.IPv4Interface(('%s/%s' % (int_address,int_mask)))

View solution in original post

4 Replies 4

vleijon
Cisco Employee
Cisco Employee
This is a python2 to python3 incompatibility. I donā€™t have time to look at this case in detail but for you or anyone else, here is a discussion: https://stackoverflow.com/questions/38697037/how-to-convert-python-2-unicode-function-into-correct-python-3-x-syntax

Thanks for your reply vleijon, That link is really helpful.

 

only change i did was and it worked!!!

interface = ipaddress.IPv4Interface(('%s/%s' % (int_address,int_mask)))

That is great! If you have time to do a quick PR to the github repo thatā€™d be appreciated.

Hi, here are some points which I believe needed for  github repo.

1)The service portion using Java did not compiled on NSO 5.3, so I believe service portion of the code  needs to be updated in Java or Python for it to run on NSO 5.3.

2) Make file needs to be updated with exact NED ids , right now its using generic.

3) I was unable to find any existing policy-map section mentioned in readme.md workflow instructions, as a work around I used the command "$ncs-netsim cli-c pe0' and removed existing subinterface from XR, and then applied reconcile function . later on I also tested it with the policy-map and it worked .Thanks.