This repo is mainly inspired of this repo on IOS XE.
It gives an overview of pyATS possibilities. As any overview, it's not intended to be exhaustive.
We're using the always-on DevNet sandboxes in the testbed.yaml
file. More information about DevNet sandboxes here:
We will be using the IOS XR sandbox for the exercices attached. Feel free to use others.
To install the right packages, please run the command below:
pip install -r requirements.txt
In the first exercice, we will connect to the device and get an unstructued show command output (ex: show ip interface brief
).
Interface IP-Address Status Protocol Vrf-Name
Loopback100 1.1.1.100 Up Up default
Loopback200 1.1.1.200 Up Up default
Loopback999 unassigned Up Up default
MgmtEth0/RP0/CPU0/0 10.10.20.175 Up Up default
GigabitEthernet0/0/0/0 unassigned Shutdown Down default
GigabitEthernet0/0/0/1 unassigned Shutdown Down default
GigabitEthernet0/0/0/2 unassigned Shutdown Down default
GigabitEthernet0/0/0/3 unassigned Shutdown Down default
GigabitEthernet0/0/0/4 unassigned Shutdown Down default
GigabitEthernet0/0/0/5 unassigned Shutdown Down default
GigabitEthernet0/0/0/6 unassigned Shutdown Down default
Complete instructions can be found here
In the second exercice, we will leverage Genie parsers to get a parsed output (JSON). Complete list of interfaces.
Loopback333 -- 3.3.3.3
Loopback99 -- 99.99.99.99
Loopback11 -- 1.2.3.1
GigabitEthernet2 -- Unassigned
GigabitEthernet1 -- 10.10.20.48
GigabitEthernet3 -- Unassigned
Complete instructions can be found here
https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers
pyATS documentation can be found here:
https://pubhub.devnetcloud.com/media/pyats/docs/getting_started/index.html
The list of supported platforms can be found here:
https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/supported_platforms.html
Below a list of errors I encountered and the resolution. The list is not aimed to be exhaustive.
! output omitted
pyats.utils.yaml.exceptions.LoadError: Content of 'testbed.yaml' failed to load into a dict.
The name of the device in your testbed, and the hostname MUST match. It's case sensitive.
unicon.core.errors.TimeoutError: timeout occurred:
Otherwise, you can also set the learn_hostname
argument to True
.
device.connect(learn_hostname=True)
More information in the documentation below:
https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/connection.html
Don't print the show version
, show running-configuration
and the output.
device.connect(init_exec_commands=[],
init_config_commands=[],
log_stdout=False)
platform.os
has the following values for IOSXE and IOSXR:
iosxe
>> lower caseIOSXR
>> upper case
To avoid waiting ~10 seconds to disconnect from the device, you can edit your testbed.yaml
file as such:
connections:
cli:
protocol: telnet
ip: 10.1.1.1
settings:
GRACEFUL_DISCONNECT_WAIT_SEC: 0
POST_DISCONNECT_WAIT_SEC: 0
More info here:
https://pubhub.devnetcloud.com/media/unicon/docs/user_guide/connection.html