03-24-2020 06:00 AM
Hi
Following this blog post -
https://blogs.cisco.com/developer/dna-center-pyats-genie
with testbed file -
devices: sandboxdnac2: alias: dnac type: dnac os: dnac credentials: rest: username: devnetuser password: "Cisco123!" connections: rest: class: rest.connector.Rest host: sandboxdnac2.cisco.com verify: False
I get key error for ‘ip’
$ genie dnac interface isis ospf --testbed-file dna.yaml --output initial --via dnac:rest --device:dnac -v loading yaml file /home/omerc/dev-workspace/pyats/DNAC-pyATS-Genie/dna.yaml Deriving testbed name ... Credential credentials not found, trying default ... Learning '['interface', 'isis', 'ospf']' on devices '['dnac']' Traceback (most recent call last): File "src/pyats/cli/base.py", line 202, in pyats.cli.base.Command.main File "src/genie/cli/commands/dnac.py", line 118, in genie.cli.commands.dnac.DnacCommand.run File "src/genie/cli/commands/dnac.py", line 146, in genie.cli.commands.dnac.DnacCommand._learn_feature File "src/genie/conf/base/device.py", line 597, in genie.conf.base.device.Device.connect File "src/pyats/connections/manager.py", line 334, in pyats.connections.manager.ConnectionManager.connect File "src/pyats/async_/synchronize.py", line 117, in pyats.async_.synchronize.Lockable.locked._wrapped File "/home/omerc/dev-workspace/pyats/lib/python3.6/site-packages/rest/connector/libs/dnac/implementation.py", line 77, in connect ip = self.connection_info['ip'].exploded KeyError: 'ip' 'ip'
If I replace the host: in testbed dna.yaml with ip: the key error is resolved.
But the credentials are not being read from the testbed file. I have tried placing credentials at different places within the file and can validate the file with pyats validate.
testbed:
name: myTestbed
credentials:
default:
username: devnetuser
password: "Cisco123!"
devices:
dnac:
alias: dnac
type: dnac
os: dnac
credentials:
rest:
username: devnetuser
password: "Cisco123!"
custom:
abstraction:
order: [os]
connections:
rest:
# Rest connector class
class: rest.connector.Rest
ip: sandboxdnac2.cisco.com
port: 443
username: devnetuser
password: "Cisco123!"
verify: False
$ genie dnac interface isis ospf --testbed-file dna.yaml --output initial --via dnac:rest --device:dnac -v
loading yaml file /home/omerc/dev-workspace/pyats/DNAC-pyATS-Genie/dna.yaml
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Credential credentials not found, trying default ...
Learning '['interface', 'isis', 'ospf']' on devices '['dnac']'
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Starting new HTTPS connection (1): 131.226.217.136:443
https://131.226.217.136:443 "POST /dna/system/api/v1/auth/token HTTP/1.1" 504 184
Traceback (most recent call last):
Can you please advise on how to properly format the testbed file?
I have tried to create the testbed file with create tool but it doesn’t work for rest connection .. defaults to cli.
Thank you
Solved! Go to Solution.
03-25-2020 01:43 AM - edited 03-25-2020 01:49 AM
fixed with the help of Siming @pyATS team. thanks
pip install rest.connector --pre --upgrade
03-25-2020 01:43 AM - edited 03-25-2020 01:49 AM
fixed with the help of Siming @pyATS team. thanks
pip install rest.connector --pre --upgrade
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