Device Connections
Because we are in the business of network test automation, pyATS is
designed around the concept of testbeds: where you describe your devices under
testing in YAML format.
This testbed YAML file provides many sections for you to describe your physical devices, and how they link together to form the topology.
# a simpe testbed yaml containing a single device
devices: # all device definition goes under devices block
csr1000v-1: # start a device definition with its HOSTNAME
type: router
os: iosxe # this tells the engine what type of OS its connected to
credentials:
default: # login credentials
username: devnetuser
password: Cisco123!
connections: # give the block on how to connect to its mgmt interface
mgmt:
protocol: ssh
ip: 172.25.192.90
You can now connect to this testbed device, and issue commands. Let's check it in shell:
bash$ pyats shell --testbed-file our-testbed-file.yaml
Welcome to pyATS Interactive Shell
==================================
Python 3.6.8 (default, Jun 19 2019, 15:21:54)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)]
>>> from pyats.topology import loader
>>> testbed = loader.load('our-testbed-file.yaml')
-------------------------------------------------------------------------------
>>> testbed
<pyats.topology.testbed.Testbed object at 0x10ef4a898>
>>> testbed.devices
TopologyDict({'csr1000v-1': <Device csr1000v-1 at 0x10fc7c080>})
>>> device = testbed.devices['csr1000v-1']
>>> device.connect()
# ... output ...
>>> device.execute('show version')
# ... output ...
>>>
For more information on how to use the various connection mechanisms delivered as part of the infrastructure, see sub-sections on the left navigation panel.