In your VSCode terminal, change directories back to the main project directory:
cd ~/workspace/ndlab/nac
You install pyATS via pip, similar to Ansible. To install the full pyATS framework, use the full keyword as below:
pip install 'pyats[full]'==26.3
Verify the pyATS installation with the pyats version checker:
pyats version check
You are currently running pyATS version: 26.3
Python: 3.11.14 [64bit]
Package Version
---------------------------- -------
genie 26.3
genie.libs.clean 26.3
genie.libs.conf 26.3
genie.libs.filetransferutils 26.3
genie.libs.health 26.3
genie.libs.ops 26.3
genie.libs.parser 26.3
genie.libs.robot 26.3
genie.libs.sdk 26.3
genie.telemetry 26.3
genie.trafficgen 26.3
pyats 26.3
pyats.aereport 26.3
pyats.aetest 26.3
pyats.async 26.3
pyats.connections 26.3
pyats.contrib 26.3
pyats.datastructures 26.3
pyats.easypy 26.3
pyats.kleenex 26.3
pyats.log 26.3
pyats.reporter 26.3
pyats.results 26.3
pyats.robot 26.3
pyats.tcl 26.3
pyats.topology 26.3
pyats.utils 26.3
rest.connector 26.3
unicon 26.3
unicon.plugins 26.3
yang.connector 26.3
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
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
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 connection name used in this lab, rest,
is arbitrary and can be anything; however, it is good practice to align it with the type of connection.
Notice the rest connection makes use of the rest.connector package that was installed with pyATS.
---
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.38
protocol: https
verify: False
custom:
abstraction:
order: [os]
Continue to the next section to define your pyATS AETest (Automation Easy Testing) structure.