Setup
pyATS

Step 1 - Ensure In Main Project Directory

In your VSCode terminal, change directories back to the main project directory:


cd ~/workspace/ndlab/nac


Step 2 - Install pyATS

You install pyATS via pip, similar to Ansible. To install the full pyATS framework, use the full keyword as below:


pip install 'pyats[full]'==25.11


Step 3 - Verify pyATS Install

Verify the pyATS installation with the pyats version checker:


pyats version check

    You are currently running pyATS version: 25.11
    Python: 3.11.14 [64bit]

    Package                      Version
    ---------------------------- -------
    genie                        25.11
    genie.libs.clean             25.11
    genie.libs.conf              25.11
    genie.libs.filetransferutils 25.11
    genie.libs.health            25.11
    genie.libs.ops               25.11
    genie.libs.parser            25.11
    genie.libs.robot             25.11
    genie.libs.sdk               25.11
    genie.telemetry              25.11
    genie.trafficgen             25.11
    pyats                        25.11
    pyats.aereport               25.11
    pyats.aetest                 25.11
    pyats.async                  25.11
    pyats.connections            25.11
    pyats.contrib                25.11
    pyats.datastructures         25.11
    pyats.easypy                 25.11
    pyats.kleenex                25.11
    pyats.log                    25.11
    pyats.reporter               25.11
    pyats.results                25.11
    pyats.robot                  25.11
    pyats.tcl                    25.11
    pyats.topology               25.11
    pyats.utils                  25.11
    rest.connector               25.11
    unicon                       25.11
    unicon.plugins               25.11
    yang.connector               25.11


Step 4 - Create Tests Directory

Create a tests directory in your project. This is a common directory name for storing tests.


mkdir tests
mkdir -p tests/results
cd ~/workspace/ndlab/nac/tests


Step 5 - pyATS Testbed YAML File

pyATS offers a topology module for interacting with devices. This is primarily done through a topology or testbed YAML file that is loaded at runtime. This file has all the device information, connection information, metadata, etc for how to interact with devices in your environment.

Create a testbed YAML file that includes only the ND, which will then be used to connect to the switches in your fabrics.


touch ~/workspace/ndlab/nac/tests/testbed.yml
code-server -r ~/workspace/ndlab/nac/tests/testbed.yml


Step 6 - Populate pyATS Testbed YAML File

Populate the testbed.yml file with the connection information for interacting with your ND. You will notice the testbed file has a name on line 3. Starting on line 5, there are default credentials defined for device access. This can be made more secure in your own environment using environment variables or pyATS secret strings. Line 10 under the devices key is where your device information is defined. Under each device, the os key set to nd and platform key set to nd are the important pieces for pyATS using the correct device connector, i.e., the connector that expects the appropriate CLI prompt type.

Lastly, you define the actual connections. The names for the connections used in this lab, rest is an arbitrary name and can be anything, however, it is good practice to align with the type of connection. Notice two things with the rest connection: it makes use of the rest connector package that was installed above, and it's set as the default connection.


---
testbed:
  name: ND
  alias: ND
  credentials:
      default:
        username: admin
        password: cisco.123
devices:
  msd-fabric-group:
    os: nd
    connections:
      rest:
        class: rest.connector.Rest
        ip: 10.15.0.98
        protocol: https
        verify: False
        custom:
          abstraction:
            order: [os]


Continue to the next section to define your pyATS AETest (Automation Easy Testing) structure.