01-31-2024 07:43 AM - edited 01-31-2024 07:46 AM
Hello,
PyATS fails to connect to my device when device hostname = U250-s2-132-csdwan
When I changed the device hostname to ciscosdwan132, it worked
Device version: Cisco IOS XE Software, Version 17.09.03a
pyats version ==23.8
I verified my yaml file and it is correct:
(.venv) [an144a@DEVAUTOS02 sdwan]$ pyats validate testbed /opt/labs-scripts/python/pytest/nfv/suites/common_testbed/cisco/sdwan/tests/testbed_vars/devices.yaml
Loading testbed file: /opt/labs-scripts/python/pytest/nfv/suites/common_testbed/cisco/sdwan/tests/testbed_vars/devices.yaml
--------------------------------------------------------------------------------
Testbed Name:
devices
Testbed Devices:
.
|-- ga-u250-ls1-131-jdm [junos/router]
|-- ga-u250-ls1-134-jdm [junos/router]
|-- ga-u250-ls1-135-jdm [junos/router]
|-- ga-u250-ls1-136-jdm [junos/router]
|-- ga-u250-s2-129-jdm [junos/router]
|-- ga-u250-s2-132-jdm [junos/router]
|-- ga-u250-s2-133-jdm [junos/router]
|-- ga-u350-s3-16-jdm [junos/router]
|-- ga-u350-s3-17-jdm [junos/router]
|-- u250-ls1-131-csdwan [iosxe/sdwan]
|-- u250-ls1-135-csdwan [iosxe/sdwan]
|-- u250-s2-132-csdwan [iosxe/sdwan]
`-- u350-s3-16-csdwan [iosxe/sdwan]
YAML Lint Messages
------------------
15:81 warning line too long (88 > 80 characters) (line-length)
30:81 warning line too long (88 > 80 characters) (line-length)
45:81 warning line too long (88 > 80 characters) (line-length)
60:81 warning line too long (88 > 80 characters) (line-length)
Warning Messages
----------------
- Device 'ga-u250-ls1-131-jdm' has no interface definitions
- Device 'ga-u250-ls1-134-jdm' has no interface definitions
- Device 'ga-u250-ls1-135-jdm' has no interface definitions
- Device 'ga-u250-ls1-136-jdm' has no interface definitions
- Device 'ga-u250-s2-129-jdm' has no interface definitions
- Device 'ga-u250-s2-132-jdm' has no interface definitions
- Device 'ga-u250-s2-133-jdm' has no interface definitions
- Device 'ga-u350-s3-16-jdm' has no interface definitions
- Device 'ga-u350-s3-17-jdm' has no interface definitions
- Device 'u250-ls1-131-csdwan' has no interface definitions
- Device 'u250-ls1-135-csdwan' has no interface definitions
- Device 'u250-s2-132-csdwan' has no interface definitions
- Device 'u350-s3-16-csdwan' has no interface definitions
Here is the sdwan device I am trying to connect to:
u250-s2-132-csdwan:
type: router
os: iosxe
platform: sdwan
#alias: 'uut'
credentials:
default:
username: admin
password: admin
connections:
cli:
protocol: ssh
ip: u250-s2-132-csdwan
ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
Output:
(.venv) [an144a@DEVAUTOS02 sdwan]$ python3
Python 3.9.18 (main, Sep 7 2023, 00:00:00)
[GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> from pyats.topology import loader
>>> from pyats.topology import Testbed, Device
>>> testbed = loader.load('/opt/labs-scripts/python/pytest/nfv/suites/common_testbed/cisco/sdwan/tests/testbed_vars/devices.yaml')
>>> device = testbed.devices['u250-s2-132-csdwan']
>>> device.connect()
2024-01-31 10:35:22,625: %UNICON-INFO: +++ u250-s2-132-csdwan logfile /tmp/u250-s2-132-csdwan-cli-20240131T103522623.log +++
2024-01-31 10:35:22,625: %UNICON-INFO: +++ Unicon plugin iosxe/sdwan (unicon.plugins.iosxe.sdwan) +++
Warning: Permanently added 'fd:192:168:53::132:9' (RSA) to the list of known hosts.
Un authorised Logins tracked
2024-01-31 10:35:23,041: %UNICON-INFO: +++ connection to spawn: ssh -l admin fd:192:168:53::132:9 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null, id: 139977095225888 +++
2024-01-31 10:35:23,041: %UNICON-INFO: connection to u250-s2-132-csdwan
(admin@fd:192:168:53::132:9) Password:
Restricted Use
U250-s2-132-csdwan#
2024-01-31 10:35:23,387: %UNICON-WARNING: Invalid hostname detected: found U250-s2-132-csdwan, expected u250-s2-132-csdwan
2024-01-31 10:35:23,388: %UNICON-INFO: +++ initializing handle +++
U250-s2-132-csdwan#
Traceback (most recent call last):
File "src/unicon/statemachine/statemachine.py", line 737, in unicon.statemachine.statemachine.StateMachine.go_to
File "src/unicon/statemachine/statetransition.py", line 484, in unicon.statemachine.statetransition.AnyStateTransition.do_transitions
File "src/unicon/eal/dialogs.py", line 476, in unicon.eal.dialogs.Dialog.process
File "src/unicon/eal/dialog_processor.py", line 326, in unicon.eal.dialog_processor.SimpleDialogProcessor.process
File "src/unicon/eal/dialog_processor.py", line 273, in unicon.eal.dialog_processor.SimpleDialogProcessor.timeout_handler
unicon.core.errors.TimeoutError: Prompt timeout occured, please check the hostname
hostname: u250-s2-132-csdwan
timeout value: 10
last_command: '\r'
pattern: ['^.*[Pp]assword( for )?(\\S+)?: ?$', '^.*?% (Bad passwords|Access denied|Authentication failed)', '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying).*$', '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying).*$', '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying).*$', 'Uncommitted changes found, commit them\\? \\[yes\\/no\\/CANCEL\\]\\s*$', '^.*?% (Bad passwords|Access denied|Authentication failed)', '^.*Login incorrect', '^.*([Uu]sername|[Ll]ogin): ?$', '^.*User Access Verification', '^.*[Pp]assword( for )?(\\S+)?: ?$', '^(.*)Kerberos:\\s*No default realm defined for Kerberos!', 'Password OK\\s*$', '^.*Enter passphrase for key .*?:\\s*?', '^.*?(Enter|Confirm) enable secret:\\s*$', '^.*(initial|basic) configuration dialog\\s?\\??\\s*((\\[yes.*\\])|(\\(yes/no\\))|(\\(yes/no\\)\\s*(\\[y\\]))):', 'Would you like to enter basic management setup\\? \\[yes/no\\]:', '^.*?Enter your selection( \\[2])?:\\s*$', 'Escape character is .*\\n', '^.*RETURN to get started', 'Are you sure you want to continue connecting \\(yes/no(/\\[fingerprint\\])?\\)', '^.*(Connection refused|Connection reset by peer|Broken pipe|Network is down|closed by remote host)', 'Received disconnect from .*:', 'Hit Enter to proceed:', '^(.*?)Press Ctrl\\+x to Exit the session', '^(.*?)Connected.', '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying).*$', '^.*?Press any key to continue\\..*?$', '^.*[Pp]ermission denied', '^.*System config(uration)? has been modified\\.\\s*Save\\?.*$', '^.*Are you sure you want to reset the system\\s*\\(y\\/n\\)\\?', '^.*Reload node\\s*\\?\\s*\\[no,yes\\]\\s?$', '^.*Proceed( with( quick)? reload)?\\?\\s*\\[confirm\\]', '^.*User Access Verification', '^(.*)Uncommitted changes found.*?', '^.*(initial|basic) configuration dialog\\s?\\??\\s*((\\[yes.*\\])|(\\(yes/no\\))|(\\(yes/no\\)\\s*(\\[y\\]))):', '^(.*)Would you like to terminate autoinstall\\?\\s*\\[yes\\]:\\s*$', '^.*Do you want to reload the internal AP\\s?\\?\\s((\\[yes/no\\]\\??)|(\\[y/n\\]\\??)):?\\s?$', '^.*Do you want to save the configuration of the AP\\s?\\?\\s*((\\[yes/no\\]\\??)|(\\[y/n\\]\\??)):?\\s?$', '^(.*)This command will reboot the system.\\s*\\(y\\/n\\)\\?\\s*\\[n\\]\\s?$', '^.*Do you want to enforce secure password standard(\\?)?\\s*\\(yes\\/no\\)(\\s*\\[[yn]\\])?\\:\\s*', '^.*(Enter|Confirm) the password for .*admin', 'Abort( Power On)? Auto Provisioning .*:', 'Password OK\\s*$', '^.*([Uu]sername|[Ll]ogin): ?$', '^.*?(Enter|Confirm) enable secret:\\s*$', '^.*?Enter your selection( \\[2])?:\\s*$', '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying).*$', '^.*[Pp]assword( for )?(\\S+)?: ?$', '^.*Press RETURN to get started.*', 'Press RETURN to get started.*', '^(.*?)Connection.*? closed|disconnect: Broken pipe', '^(.*)Please reset', '^.*(Enter|Confirm) the password for .*admin', '^.*(initial|basic) configuration dialog.*\\s?', '^(.*)Would you like to terminate autoinstall\\? ?\\[yes\\]: $', '^.*?% (Bad passwords|Access denied|Authentication failed)', '^.*Login incorrect', '^.*([Uu]sername|[Ll]ogin): ?$', '^.*User Access Verification', '^.*[Pp]assword( for )?(\\S+)?: ?$', '^(.*)Kerberos:\\s*No default realm defined for Kerberos!', 'Password OK\\s*$', '^.*Enter passphrase for key .*?:\\s*?', '^.*?(Enter|Confirm) enable secret:\\s*$', '^.*(initial|basic) configuration dialog\\s?\\??\\s*((\\[yes.*\\])|(\\(yes/no\\))|(\\(yes/no\\)\\s*(\\[y\\]))):', 'Would you like to enter basic management setup\\? \\[yes/no\\]:', '^.*?Enter your selection( \\[2])?:\\s*$', 'Escape character is .*\\n', '^.*RETURN to get started', 'Are you sure you want to continue connecting \\(yes/no(/\\[fingerprint\\])?\\)', '^.*(Connection refused|Connection reset by peer|Broken pipe|Network is down|closed by remote host)', 'Received disconnect from .*:', 'Hit Enter to proceed:', '^(.*?)Press Ctrl\\+x to Exit the session', '^(.*?)Connected.', '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying).*$', '^.*?Press any key to continue\\..*?$', '^.*[Pp]ermission denied', '^.*Are you sure you want to continue\\? \\[y/n\\]\\s?.*$', '^(.*?)\\[(u250-s2-132-csdwan|[Ss]witch|[Rr]outer|eWLC).*?\\]\\$\\s?$', '^(.*?)(rommon[\\s\\d]*>|switch:)\\s?$', '^(.*?)(WLC|Router|RouterRP|Switch|ios|switch|u250-s2-132-csdwan)([0-9])?(\\(standby\\))?(-stby)?(-standby)?(\\(boot\\))?\\(maint-mode\\)#[\\s\\x07]*$', '^(.*?)(\\{\\.\\.\\}|then.else.fi)\\s*>\\s*$', '^(.*?)\\(tcl.*?\\)#[\\s\\x07]*$', '^(.*)\\[\\S+@guestshell\\s+.*\\][#\\$]\\s?$', '^(.*)\\(.*(con|cfg|ipsec-profile|ca-trustpoint|cs-server|ca-profile|gkm-local-server|cloud|host-list|config-gkm-group|gkm-sa-ipsec|gdoi-coop-ks-config|wsma)\\S*\\)#\\s?$', '^(.*?)(WLC|Router|RouterRP|Switch|ios|switch|u250-s2-132-csdwan)([0-9])?(\\(standby\\))?(-stby)?(-standby)?(\\(boot\\))?(\\(recovery-mode\\))?#[\\s\\x07]*$', '^(.*?)(WLC|Router|RouterRP|Switch|ios|switch|u250-s2-132-csdwan)([0-9])?(\\(standby\\))?(-stby)?(-standby)?(\\(boot\\))?(\\(recovery-mode\\))?>\\s?$', '^.*--\\s?[Mm]ore\\s?--.*$']
buffer:'\r\nU250-s2-132-csdwan#'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "src/unicon/bases/connection.py", line 792, in unicon.bases.connection.Connection.connect
File "src/unicon/bases/routers/connection_provider.py", line 231, in unicon.bases.routers.connection_provider.BaseSingleRpConnectionProvider.connect
File "src/unicon/bases/routers/connection_provider.py", line 275, in unicon.bases.routers.connection_provider.BaseSingleRpConnectionProvider.init_connection
File "src/unicon/bases/routers/connection_provider.py", line 305, in unicon.bases.routers.connection_provider.BaseSingleRpConnectionProvider.init_handle
File "src/unicon/bases/routers/connection_provider.py", line 124, in unicon.bases.routers.connection_provider.BaseCommonRpConnectionProvider.execute_init_commands
File "src/unicon/bases/routers/services.py", line 258, in unicon.bases.routers.services.BaseService.__call__
File "src/unicon/bases/routers/services.py", line 172, in unicon.bases.routers.services.BaseService.pre_service
File "src/unicon/statemachine/statemachine.py", line 810, in unicon.statemachine.statemachine.StateMachine.detect_state
File "src/unicon/statemachine/statemachine.py", line 740, 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 "<stdin>", line 1, in <module>
File "src/pyats/connections/manager.py", line 453, in pyats.connections.manager.ConnectionManager.connect
File "src/unicon/bases/connection.py", line 799, in unicon.bases.connection.Connection.connect
unicon.core.errors.ConnectionError: failed to connect to u250-s2-132-csdwan
Failed while bringing device to "any" state
>>>
When I changed the device hostname to ciscosdwan132, it worked
>>> testbed = loader.load('/opt/labs-scripts/python/pytest/nfv/suites/common_testbed/cisco/sdwan/tests/testbed_vars/devices.yaml')
>>> device = testbed.devices['ciscosdwan132']
>>> device.connect()
2024-01-31 10:39:04,656: %UNICON-INFO: +++ ciscosdwan132 logfile /tmp/ciscosdwan132-cli-20240131T103904655.log +++
2024-01-31 10:39:04,656: %UNICON-INFO: +++ Unicon plugin iosxe/sdwan (unicon.plugins.iosxe.sdwan) +++
Warning: Permanently added 'fd:192:168:53::132:9' (RSA) to the list of known hosts.
2024-01-31 10:39:05,208: %UNICON-INFO: +++ connection to spawn: ssh -l admin fd:192:168:53::132:9 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null, id: 139977092338928 +++
2024-01-31 10:39:05,208: %UNICON-INFO: connection to ciscosdwan132
(admin@fd:192:168:53::132:9) Password:
Restricted Use
ciscosdwan132#
2024-01-31 10:39:05,290: %UNICON-INFO: +++ initializing handle +++
2024-01-31 10:39:05,353: %UNICON-INFO: +++ ciscosdwan132 with via 'cli': executing command 'term length 0' +++
term length 0
ciscosdwan132#
2024-01-31 10:39:05,563: %UNICON-INFO: +++ ciscosdwan132 with via 'cli': executing command 'term width 0' +++
term width 0
ciscosdwan132#
2024-01-31 10:39:05,777: %UNICON-INFO: +++ ciscosdwan132 with via 'cli': executing command 'show sdwan software' +++
show sdwan software
VERSION ACTIVE DEFAULT PREVIOUS CONFIRMED TIMESTAMP
--------------------------------------------------------------------------------
17.09.03.0.15 true true false - 2023-09-19T01:46:24-00:00
Total Space:387M Used Space:148M Available Space:234M
ciscosdwan132#
2024-01-31 10:39:10,824: %UNICON-INFO: +++ ciscosdwan132 with via 'cli': executing command 'show sdwan version' +++
show sdwan version
17.09.03.0.15
ciscosdwan132#
2024-01-31 10:39:11,382: %UNICON-INFO: +++ ciscosdwan132 with via 'cli': executing command 'show version' +++
show version
Cisco IOS XE Software, Version 17.09.03a
Cisco IOS Software [Cupertino], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 17.9.3a, RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2023 by Cisco Systems, Inc.
Compiled Wed 29-Mar-23 00:30 by mcpre
Cisco IOS-XE software, Copyright (c) 2005-2023 by cisco Systems, Inc.
All rights reserved. Certain components of Cisco IOS-XE software are
licensed under the GNU General Public License ("GPL") Version 2.0. The
software code licensed under GPL Version 2.0 is free software that comes
with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such
GPL code under the terms of GPL Version 2.0. For more details, see the
documentation or "License Notice" file accompanying the IOS-XE software,
or the applicable URL provided on the flyer accompanying the IOS-XE
software.
ROM: IOS-XE ROMMON
Solved! Go to Solution.
01-31-2024 10:12 AM - edited 01-31-2024 10:13 AM
Hi
Your devices hostname is ""U250-s2-132-csdwan", but in your testbed you use "u250-s2-132-csdwan" as the key:
2024-01-31 10:35:23,387: %UNICON-WARNING: Invalid hostname detected: found U250-s2-132-csdwan, expected u250-s2-132-csdwan
Regarding the working one ("ciscosdwan132") this is probably another device in your testbed.
If your testbed key does not match the hostname of the device you can use this flag in the connection method:
device = testbed.devices['u250-s2-132-csdwan']
device.connect(learn_hostname=True)
HTH
01-31-2024 09:43 AM
Thats odd! Double check that the hostname in your testbed YAML file exactly matches the configured hostname on the device. Only thing i can think of atm
Hope that helps
01-31-2024 10:12 AM - edited 01-31-2024 10:13 AM
Hi
Your devices hostname is ""U250-s2-132-csdwan", but in your testbed you use "u250-s2-132-csdwan" as the key:
2024-01-31 10:35:23,387: %UNICON-WARNING: Invalid hostname detected: found U250-s2-132-csdwan, expected u250-s2-132-csdwan
Regarding the working one ("ciscosdwan132") this is probably another device in your testbed.
If your testbed key does not match the hostname of the device you can use this flag in the connection method:
device = testbed.devices['u250-s2-132-csdwan']
device.connect(learn_hostname=True)
HTH
01-31-2024 12:28 PM
You are right, capital U vs lower case u
Thanks for your support and pointing that out
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