CiscoTestAutomation / pyats

Cisco DevNet pyATS Test Framework Bug Tracker
Apache License 2.0
152 stars 32 forks source link

nso.connect does not work with rest #242

Closed euserb closed 2 months ago

euserb commented 4 months ago

nso.connect(via='rest') does not work.

topology.yaml

devices:
  nso-master:
    alias: nso-master
    type: NSO
    os: nso
    tacacs:
      username: admin
    passwords:
      tacacs: admin
    connections:
      defaults:
        class: unicon.Unicon
        via: cli
      cli:
        protocol: ssh
        ip: nso_test
        port: 1024
        ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
      con:
        command: ncs_cli -C
      restconf:
        protocol: http
        ip: nso_test
        port: 80
        username: admin
        password: admin
      netconf:
        protocol: ssh
        ip: nso_test
        port: 1024
        username: admin
        password: admin
      rest:
        class: rest.connector.Rest
        ip: nso_test
        port: 80
        protocol: http
        credentials:
          rest:
            username: admin
            password: admin

Error:

>>> from pyats.topology.loader import load
>>> testbed = load('topology.yaml')
>>> nso = testbed.devices['nso-master']
>>> nso.connect(alias='rest', via='rest')
Connecting to 'nso-master' with alias 'rest'
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "src/pyats/connections/manager.py", line 482, in pyats.connections.manager.ConnectionManager.connect
  File "src/pyats/async_/synchronize.py", line 117, in pyats.async_.synchronize.Lockable.locked._wrapped
  File "/venv/lib/python3.10/site-packages/rest/connector/libs/nso/implementation.py", line 142, in connect
    raise RequestException("Connection to '{ip}:{port}' has returned the "
requests.exceptions.RequestException: Connection to '10.0.1.4:80' has returned the following code '404', instead of the expected status code '200'

Fix:

sed -i 's\{f}/api\{f}/restconf\g' /venv/lib/python3.10/site-packages/rest/connector/libs/nso/implementation.py
sed -i 's\application/vnd.yang.\application/yang-\g' /venv/lib/python3.10/site-packages/rest/connector/libs/nso/implementation.py
>>> from pyats.topology.loader import load
>>> testbed = load('topology.yaml')
>>> nso = testbed.devices['nso-master']
>>> nso.connect(alias='rest', via='rest')
Connecting to 'nso-master' with alias 'rest'
Connected successfully to 'nso-master'
<Response [200]>
>>> 
euserb commented 4 months ago

pyats==24.1

Harishv01 commented 4 months ago

Thank you for bringing this to our attention. Kindly give us some time to check and fix it.

Thank you.

Harishv01 commented 4 months ago

Hi,

Please check with the latest version, i.e., 24.6, whether it works or not.

Thank you.

euserb commented 4 months ago
pyats==24.6

Tried with this. Still had to make the modification.

Harishv01 commented 4 months ago

Okay,Kindly give us some time to check and fix it.

Thank you.

euserb commented 4 months ago

hello,

To give you more context at how I came to the solution: https://developer.cisco.com/docs/nso/guides/the-restconf-api/#getting-started

you can see in example #4 where it has both modifications to be made.

Thanks!

Harishv01 commented 4 months ago

In which version was this working and from which version was this API thing changed? Can you please let me know?

euserb commented 4 months ago

Hello,

I don’t know when it was working. What I know is that my fix works for NSO 5.x and 6.x.

Eugen

On Tue, 16 Jul 2024 at 18:34, Harishv @.***> wrote:

In which version was this working and from which version was this API thing changed? Can you please let me know?

— Reply to this email directly, view it on GitHub https://github.com/CiscoTestAutomation/pyats/issues/242#issuecomment-2231362315, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXMVQTBMZSPDFJRN5RDZ2TZMVDRZAVCNFSM6AAAAABKB5OYU6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZRGM3DEMZRGU . You are receiving this because you authored the thread.Message ID: @.***>

Harishv01 commented 3 months ago

Hi,

We have fixed the issue, but we currently don't have a device to test it. Could you please send the device details to this email pyats-support-ext@cisco.com ?

Thank you,

Harishv01 commented 3 months ago

We have fixed the issue, but we currently don't have a device to test it. Could you please send the device details to this email pyats-support-ext@cisco.com ?

Thank you.

euserb commented 3 months ago

Hello, I just used a docker that I downloaded from software.cisco.com. The image I'm using is: nso-6.1.11.2.container-image-dev.linux.x86_64.signed.bin .

Harishv01 commented 3 months ago

Hi, Can you please provide more detailed steps on how to use Docker and the image to reproduce the issue? Thank you.

Harishv01 commented 3 months ago

Hi, Can you please provide more detailed steps on how to use Docker and the image to reproduce the issue?

Harishv01 commented 2 months ago

Can you please provide more detailed steps on how to use Docker and the image to reproduce the issue?

euserb commented 2 months ago

Hello, I used this tutorial to install NSO on my mac: https://developer.cisco.com/docs/nso/getting-and-installing-nso/#getting-nso . You won't need any of the neds, just have it started.

The topology.yaml that I shared in the bug is enough to test it.

For the docker image you'd need more stuff (like the ncs.conf) and I don't know how my colleagues made it work...

Harishv01 commented 2 months ago

Hi, we don't have an NSO device with us to test it. So, could you please share the topology.yaml file with all credentials and ips to this email: pyats-support-ext@cisco.com?

Harishv01 commented 2 months ago

Hi, we don't have an NSO device with us to test it. So, could you please share the topology.yaml file with all credentials and ips to this email: pyats-support-ext@cisco.com?

Harishv01 commented 2 months ago

we don't have an NSO device with us to test it. So, could you please share the topology.yaml file with all credentials and ips to this email: pyats-support-ext@cisco.com?

Harishv01 commented 2 months ago

Hi, I haven't received any updates on this. Hence, I am closing the ticket. If you are willing to share the above mentioned details, please share them and let me know here, so that I can reopen and fix it.