cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
154
Views
0
Helpful
1
Replies
Highlighted
Rising star
Rising star

pyATS DNAC REST testbed formatting

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Rising star
Rising star

Re: pyATS DNAC REST testbed formatting

fixed with the help of Siming @pyATS team. thanks

 

pip install rest.connector --pre --upgrade 

View solution in original post

1 REPLY 1
Highlighted
Rising star
Rising star

Re: pyATS DNAC REST testbed formatting

fixed with the help of Siming @pyATS team. thanks

 

pip install rest.connector --pre --upgrade 

View solution in original post

This widget could not be displayed.