cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1263
Views
10
Helpful
4
Replies

Python runtime Error while implementing netdevops-demo (NSO and Ansible)

ZAhmad04890
Level 1
Level 1

Hi ,

I am trying to implement NSO and Ansible netdevops-demo located at (https://github.com/NSO-developer/netdevops-demo),While running python, I am getting error is shown below , I am also attaching the python code which is used to generate Ansible configuration in this demo. if anyone has known to solve these errors please reply , the operation system I am using is ubuntu 16.04 LTS.  Thanks.

 

Error while running code on python2 ..........

 

user@eve-ng:~/ncs-run/netdevops-demo$ python generate_ansible.py
Syncing Configuration from Devices
Traceback (most recent call last):
File "generate_ansible.py", line 57, in <module>
main()
File "generate_ansible.py", line 27, in main
nso.sync_from()
File "/home/user/ncs-run/netdevops-demo/helpers/nso.py", line 69, in sync_from
resp = self.post(url)
File "/home/user/ncs-run/netdevops-demo/helpers/nso.py", line 62, in post
response.raise_for_status()
File "/home/user/.local/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8080/api/config/devices/_operations/sync-from
user@eve-ng:~/ncs-run/netdevops-demo$

 

Error while running code on  python3 .............

 

user@eve-ng:~/ncs-run/netdevops-demo$ python3 generate_ansible.py
/usr/local/lib/python3.5/dist-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
from cryptography import x509
Syncing Configuration from Devices
Traceback (most recent call last):
File "generate_ansible.py", line 57, in <module>
main()
File "generate_ansible.py", line 27, in main
nso.sync_from()
File "/home/user/ncs-run/netdevops-demo/helpers/nso.py", line 69, in sync_from
resp = self.post(url)
File "/home/user/ncs-run/netdevops-demo/helpers/nso.py", line 62, in post
response.raise_for_status()
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8080/api/config/devices/_operations/sync-from
user@eve-ng:~/ncs-run/netdevops-demo$

 

 

 

 

1 Accepted Solution

Accepted Solutions

Hello

 

the communication in REST is between the script being run and the NSO instance not between NSO and the Netsim devices.

 

I have made the required modifications in this fork of the repo: https://github.com/gmuloc/netdevops-demo/tree/restconf that should allow you to run the demo with NSO 5.3. Note that it is using python 3. You can give it a go and let me know here if this works for you.

 

Best regards,

 

 

 

View solution in original post

4 Replies 4

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

the repository you are referring to has last been updated 2 years ago.

The URL that is causing you trouble is using the REST API which has been deprecated in favor of the RESTCONF API starting NSO 5.3 - what NSO version are you using?

 

This URL:

http://localhost:8080/api/config/devices/_operations/sync-from

 

should be replaced with:

http://localhost:8080/restconf/data/tailf-ncs:devices/sync-from

 

You have a couple of other occurrences of the legacy REST API in this file that would need to be replaced as well:

https://github.com/NSO-developer/netdevops-demo/blob/master/helpers/nso.py

Hi and Thanks for your reply , I am using NSO 5.3 . only NSO 5.3 is available on developer.cisco.com for free download , If NSO 5.2 was available, I would have just installed it.

I have tried to search for NSO 5.2 , but wasnt able to find any where free to download, and I do not have  a cisco account.

 

Regarding  the new NSO 5.3 RESTCONF API : does its communication with net-sim  device depend on the selection from one of the following four options , or it it in dependent of these four options , as shown below? outputs from NSO are shown as reference.Thanks.

 

1)netconf

2)generic

3)snmp

4)cli

 

admin@ncs(config-device-router0)# address 127.0.0.1 port 10022 device-type ?
Possible completions:
cli Use CLI to communicate with the device
generic Use a generic NED to talk to the device
netconf
snmp

 

 

user@eve-ng:~/nso-instance/netdevops-demo$ ncs-netsim list
ncs-netsim list for /home/user/nso-instance/netdevops-demo/netsim

name=router0 netconf=12022 snmp=11022 ipc=5010 cli=10022 dir=/home/user/nso-instance/netdevops-demo/netsim/router/router0
name=router1 netconf=12023 snmp=11023 ipc=5011 cli=10023 dir=/home/user/nso-instance/netdevops-demo/netsim/router/router1
name=router2 netconf=12024 snmp=11024 ipc=5012 cli=10024 dir=/home/user/nso-instance/netdevops-demo/netsim/router/router2
user@eve-ng:~/nso-instance/netdevops-demo$

 

 

 

Hello

 

the communication in REST is between the script being run and the NSO instance not between NSO and the Netsim devices.

 

I have made the required modifications in this fork of the repo: https://github.com/gmuloc/netdevops-demo/tree/restconf that should allow you to run the demo with NSO 5.3. Note that it is using python 3. You can give it a go and let me know here if this works for you.

 

Best regards,

 

 

 

Hi , Thanks and the code works now !!! ,

as a side note on ubutnu 18.04 while working in  python3 virtual environment, its still giving depreciation warning for ansible, which I am not sure why?. Thanks.

 

(venv3) ahmad@ahmad:~/ncs-run/netdevops-demo-restconf$ ansible-playbook -i inventory.yaml site.yaml

PLAY [Check Synchronization of Devices] ****************************************

TASK [check-sync] **************************************************************
changed: [localhost]

PLAY [Verify device configuration] *********************************************

TASK [Device configuration] ****************************************************
[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host router1 should use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility with
prior Ansible releases. A future Ansible release will default to using the
discovered platform python for this host. See https://docs.ansible.com/ansible/
2.10/reference_appendices/interpreter_discovery.html for more information. This
feature will be removed in version 2.12. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
ok: [router1]
[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host router2 should use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility with
prior Ansible releases. A future Ansible release will default to using the
discovered platform python for this host. See https://docs.ansible.com/ansible/
2.10/reference_appendices/interpreter_discovery.html for more information. This
feature will be removed in version 2.12. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
ok: [router2]
[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host router0 should use
/usr/bin/python3, but is using /usr/bin/python for backward compatibility with
prior Ansible releases. A future Ansible release will default to using the
discovered platform python for this host. See https://docs.ansible.com/ansible/
2.10/reference_appendices/interpreter_discovery.html for more information. This
feature will be removed in version 2.12. Deprecation warnings can be disabled
by setting deprecation_warnings=False in ansible.cfg.
ok: [router0]

PLAY [Push Desired Configuration to Devices] ***********************************

TASK [NSO sync-to action] ******************************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost : ok=2 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
router0 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
router1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
router2 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

(venv3) ahmad@ahmad:~/ncs-run/netdevops-demo-restconf$