04-07-2020 08:58 AM
Hi, I am trying my hands on pyats. So I have set up a basic script wherein I've a testbed file having device details in it. so when I am trying to connect to the device, it is giving me following error:
Password: Password: Password: root@10.121.12.36's password: Traceback (most recent call last): File "src/unicon/statemachine/statemachine.py", line 701, in unicon.statemachine.statemachine.StateMachine.go_to File "src/unicon/statemachine/statetransition.py", line 479, in unicon.statemachine.statetransition.AnyStateTransition.do_transitions File "src/unicon/eal/dialogs.py", line 419, in unicon.eal.dialogs.Dialog.process File "src/unicon/eal/dialog_processor.py", line 285, in unicon.eal.dialog_processor.SimpleDialogProcessor.process File "src/unicon/eal/dialog_processor.py", line 224, in unicon.eal.dialog_processor.SimpleDialogProcessor.expect_eval_statements File "/usr/local/lib/python3.6/dist-packages/unicon/plugins/generic/statements.py", line 144, in password_handler raise UniconAuthenticationError('Too many password retries') unicon.core.errors.UniconAuthenticationError: Too many password retries The above exception was the direct cause of the following exception: Traceback (most recent call last): File "src/unicon/bases/connection.py", line 532, in unicon.bases.connection.Connection.connect File "src/unicon/bases/routers/connection_provider.py", line 146, in unicon.bases.routers.connection_provider.BaseSingleRpConnectionProvider.connect File "src/unicon/bases/routers/connection_provider.py", line 169, in unicon.bases.routers.connection_provider.BaseSingleRpConnectionProvider.establish_connection File "src/unicon/statemachine/statemachine.py", line 704, in unicon.statemachine.statemachine.StateMachine.go_to unicon.core.errors.StateMachineError: Failed while bringing device to "any" state The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<console>", line 1, in <module> File "src/pyats/connections/manager.py", line 305, in pyats.connections.manager.ConnectionManager.connect File "src/unicon/bases/connection.py", line 538, in unicon.bases.connection.Connection.connect unicon.core.errors.ConnectionError: failed to connect to nexus_device
device details are correct, as I am able to login via netmiko library.
Please help!!
04-08-2020 12:41 AM
Hi
What device you are running this against?
As you can see its failing with too many password retires. I suggest you double-check the credentials in the testbed file.
You can validate the testbed file with - pyats validate testbed <testbed_file.yml>
Can you share the testbed file (remove sensitive info) and how you are executing the pyats command?
Thanks
04-13-2020 03:34 AM
Hi,
I tested my testbed file. It results following:
Testbed Name: our-testbed-file Testbed Devices: . `-- nexus_device [switch/cisco_nxos] Warning Messages ---------------- - Device 'nexus_device' missing 'platform' definition - Device 'nexus_device' has no interface definitions YAML Lint Messages ------------------
Below is the yaml file. I have a nexus device.
# a simpe testbed yaml containing a single device devices: # all device definition goes under devices block nexus_device: # start a device definition with its HOSTNAME type: switch os: cisco_nxos credentials: default: username: **** password: **** connections: # give the block on how to connect to its mgmt interface mgmt: protocol: ssh ip: ****
For execution, I am following this link:
https://developer.cisco.com/docs/pyats/#!connection-to-devices/device-connections
04-13-2020 03:47 AM - edited 04-13-2020 03:58 AM
you can ignore warning messages in pyats validation.
is there any error message or debug output you can share?
does the device prompt shows hostname as - nexus_device - as in your testbed file?
try like this -
nexus_device: os: nxos type: nxos credentials: default: username: "admin" password: "xxx" enable: "xxx" connections: defaults: class: unicon.Unicon ssh: protocol: ssh ip: "xxx"
04-13-2020 04:10 AM
04-13-2020 04:36 AM
if you login to the nexus box from putty or cli .. after successful you get the device prompt that shows the hostname of the device.
R1# or nexus_device#
try to match the hostname configured on the device to the hostname in the testbed file.
TopologyDict({'nexus_device': <Device nexus_device at 0x7f874e328ba8>})
is expected after you type testbed.devices
what happens when you do -
>>> device = testbed.devices['nexus_device'] >>> device.connect()
Do you get password error after this? Can you login to the device with the same creds via Putty or shell?
04-13-2020 04:42 AM
04-13-2020 05:07 AM
I tried your testbed file on devnet sandbox.
after the device.connect() it logs in but the connection hangs..
if I add enable password in the testbed file .. the connection works fine
have you added the enable password on the testbed file? can you plz try?
try these creds for sandbox in your testbed file -
credentials: default: username: admin password: Admin_1234! enable: Admin_1234! ip: sbx-nxos-mgmt.cisco.com port: "8181"
04-13-2020 06:19 AM
04-13-2020 06:46 AM
this is a working testbed file .. i have tested with sandbox.
--- testbed: name: testbed credentials: default: username: admin password: Admin_1234! enable: Admin_1234! devices: sbx-n9kv-ao: ## match this with hostname on device alias: nexus_device ## you can use alias here if want to call it nexus_device type: nxos os: nxos connections: mgmt: protocol: ssh ip: sbx-nxos-mgmt.cisco.com port: "8181"
04-08-2020 12:46 AM
Are you using console/SSH connection in the testbed? Netmiko will be using SSH.
# a simpe testbed yaml containing a single device devices: # all device definition goes under devices block csr1000v-1: # start a device definition with its HOSTNAME alias: node1 type: router os: iosxe # this tells the engine what type of OS its connected to credentials: default: # login credentials username: admin password: Cisco123 connections: # give the block on how to connect to its mgmt interface mgmt: protocol: ssh ip: 172.16.1.1
04-13-2020 08:14 AM
04-13-2020 08:35 AM
Do you password error with sandbox as well?
04-13-2020 08:41 AM
04-13-2020 09:50 AM - edited 04-13-2020 09:54 AM
test with sandbox and check pyats version
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide