Example 15-8 shows an example of a YAML file with only
one device.
Example 15-8 pyATS Testbed File
Click here to view code image
---
devices:
csr1000v-1:
type: 'router'
os: 'iosxe'
platform: asr1k
alias: 'uut'
credentials:
default:
username: vagrant
password: vagrant
connections:
cli:
protocol: ssh
port: 2222
ip: "127.0.0.1"
Most of the options, while defining devices in a testbed,
should be self-explanatory. There are just a few options
that need to be explained in more detail. First, the
hostname—which is csr1000v-1 in Example 15-8—has to
match the configured hostname of the device. Second,
the alias is used to identify the device during script
execution. The test script can be reused on a different
testbed as long as the aliases stay the same. A complete
list of values for the type, operating system, and platform
is available with the pyATS documentation. Say that you
save this file and call it testbed.yaml.
Example 15-9 shows a simple Python script that uses the
pyATS library and loads the testbed.yaml file, searches in
that file for a device with alias uut, connects to that
device, runs the show version command, and extracts