08-21-2025 06:17 AM
Hello,
I have the following configuration
I have read somewhere (google AI), that you can have multiple credentials in your yaml file
But PyATS always uses the default credentials, even when I specify the 'ro_credentials' to use
u350-s2-17-vcsr: type: router os: iosxe platform: c8kv #alias: 'uut' credentials: default: username: ****** password: ****** ro_credentials: username: cisco_ro password: ****** connections: cli: protocol: ssh ip: FD:192:168:53:0:9:17:4 ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
try: LOGGER.info(f">>> Connecting to {device_name}...1") device.connect(log_stdout=False, init_config_commands=[], credentials='ro_credentials') LOGGER.info(f"Successfully connected to {device_name}\n") return device except (TimeoutError, StateMachineError, ConnectionError) as e: LOGGER.error(f"Failed to connect to {device_name}: {e}\n") return None
Sometimes, I also get the error message:
TypeError: function() got multiple values for keyword argument 'credentials'
08-21-2025 06:32 AM
@assadniang looking at the error you see/posted here, looks like how pyats deals with the creds parameter in the connect() method. Try using the via parameter instead of credentials. This i think is the simple fix, try this and see how this works, if this does not work If the issue might be in the YAML structure or how the testbed is being loaded.
try:
LOGGER.info(f">>> Connecting to {device_name}...1")
device.connect(log_stdout=False, init_config_commands=[], via='ro_credentials')
LOGGER.info(f"Successfully connected to {device_name}\n")
return device
except (TimeoutError, StateMachineError, ConnectionError) as e:
LOGGER.error(f"Failed to connect to {device_name}: {e}\n")
return None
08-21-2025 07:21 AM
@bigevilbeard
I am getting this error message:
ValueError: via='ro_credentials' does not exist for device 'u350-s2-17-vcsr'
BTW, I can connect with the default credential without any issues
08-21-2025 07:26 AM
@assadniang under the connection in yaml file add
credentials: ro_credentials
Then the python stuff from before. I think this happnes due to the expectation of cli, console..
08-21-2025 07:34 AM
u350-s2-17-vcsr:
type: router
os: iosxe
platform: c8kv
#alias: 'uut'
credentials:
default:
username: ******
password: ******
ro_credentials:
username: cisco_ro
password: *****
connections:
credentials: ro_credentials
cli:
protocol: ssh
ip: FD:192:168:53:0:9:17:4
ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
This is the error message
pyats.utils.exceptions.SchemaTypeError: devices.u350-s2-17-vcsr.connections.credentials:
08-21-2025 07:40 AM
Sorry this is my bad. ro_credentials at the wrong indentation level, try
u350-s2-17-vcsr:
type: router
os: iosxe
platform: c8kv
#alias: 'uut'
credentials:
default:
username: ******
password: ******
ro_credentials:
username: cisco_ro
password: *****
connections:
cli:
protocol: ssh
ip: FD:192:168:53:0:9:17:4
ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
credentials: ro_credentials
Your credentials parameter should be specified within the individual connection definition (cli in this case)
08-21-2025 07:59 AM
Still not working...
u350-s2-17-vcsr:
type: router
os: iosxe
platform: c8kv
#alias: 'uut'
credentials:
default:
username: *****
password: *****
ro_credentials:
username: cisco_ro
password: ********
connections:
cli:
protocol: ssh
ip: FD:192:168:53:0:9:17:4
ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
credentials: ro_credentials
pyats.utils.exceptions.SchemaTypeError: devices.u350-s2-17-vcsr.connections.cli.credentials:
08-21-2025 09:17 AM
Hmmmm ... out on a limb here now .. so try
u350-s2-17-vcsr:
type: router
os: iosxe
platform: c8kv
credentials:
default:
username: *****
password: *****
ro_credentials:
username: cisco_ro
password: ********
connections:
cli:
protocol: ssh
ip: FD:192:168:53:0:9:17:4
ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
ro_cli:
protocol: ssh
ip: FD:192:168:53:0:9:17:4
ssh_options: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
via: ro_credentials
In python use
device.connect(alias='ro_cli', log_stdout=False, init_config_commands=[])
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