Step 2: Verify pyATS Testbed FileΒΆ
Value Proposition: Ensure accurate network infrastructure mapping for seamless test automation and proactive issue mitigation.
For pyATS to work with network topology, it must know the following basic information: management interfaces, IP addresses, connection protocol, and connections between network devices.
This information is stored in the pyATS testbed file (YAML format).
The testbed YAML file for pyATS has been pre-created for this lab, and it is named pyats_testbed.yaml
.
Change to the directory that contains the lab files:
cd ~/LTRATO-2001
Open the pre-created
pyats_testbed.yaml
file in the Nano editor by entering the following command:nano pyats_testbed.yaml
The output of the command should contain the following:
testbed: name: labpyats # name of topology simulation credentials: # credentials for CLI access (stored as environment variables) default: # username/password used by default username: "%ENV{PYATS_USERNAME}" password: "%ENV{PYATS_PASSWORD}" enable: # enable password (if required) password: "%ENV{PYATS_AUTH_PASS}" line: # line (VTY/console) password (if required) password: "%ENV{PYATS_AUTH_PASS}" devices: # All necessary information to connect to devices is in this block asav-1: alias: asav-1 os: asa type: ASAv platform: ASAv connections: console: protocol: ssh ip: 198.18.1.202 port: 22 # connection to a device would be done via SSH port # ... # Output ommitted # ... topology: # All information about links between devices is in this block asav-1: interfaces: GigabitEthernet0/0: ipv4: 10.0.0.5/30 link: asav-1-to-nx-osv-1 type: ethernet GigabitEthernet0/1: ipv4: 10.0.0.9/30 link: asav-1-to-nx-osv-1#1 type: ethernet # ... # Output ommitted # ...
Now we have all the required information to start our tests with pyATS.
Note
Note that username and passwords to access devices are not stored in the YAML file:
credentials: default: username: "%ENV{PYATS_USERNAME}" password: "%ENV{PYATS_PASSWORD}" enable: password: "%ENV{PYATS_AUTH_PASS}" line: password: "%ENV{PYATS_AUTH_PASS}"
We recommend you store credentials separately as environment variables.
Exit Nano without saving by pressing Ctrl + X
In the lab environment, variables for PYATS with credentials to access all devices are preconfigured. Check these environment variables from a Bash shell:
echo $PYATS_USERNAME echo $PYATS_PASSWORD echo $PYATS_AUTH_PASS
The output of the command should contain the following:
cisco cisco cisco
Section author: Luis Rueda <lurueda@cisco.com>, Jairo Leon <jaileon@cisco.com>