pyats
Automate network testing and validation
TLDR
Run a pyATS subcommand
Display help
Display help about a specific subcommand
Display version
SYNOPSIS
pyats [global_options] command [command_options]
PARAMETERS
-h, --help
Displays a help message for the pyats command or a specific subcommand.
-v, --version
Shows the current version of the pyats framework and its components.
--debug
Enables verbose debug output, useful for troubleshooting issues.
--verbose
Increases the verbosity of the output, providing more detailed information during execution.
run
Executes a specified test script. Requires a test script path and often a testbed file. Example: pyats run my_script.py --testbed my_testbed.yaml
learn
Collects operational state information (e.g., routing tables, interface status) from devices defined in a testbed. Example: pyats learn bgp --testbed my_testbed.yaml
diff
Compares two sets of collected device data (e.g., from two learn operations) to identify differences. Example: pyats diff first_run.json second_run.json
clean
Performs initial device cleanup and configuration loading, often used to reset devices to a known state before testing. Example: pyats clean my_clean_script.py --testbed my_testbed.yaml
config
Manages pyats framework configuration, allowing users to set or get global settings. Example: pyats config set proxy http://proxy.example.com
docs
Opens the official pyats online documentation in a web browser.
log
Provides utilities for viewing and analyzing pyats execution logs.
DESCRIPTION
The pyATS command-line interface (CLI) provides an entry point to Cisco's Python Automated Test System, a powerful and extensible framework for automating testing and operations of network devices and services.
At its core, pyATS leverages an Abstract Everything Concept (AEC), abstracting device interaction complexities and allowing tests to be written against logical device capabilities rather than specific implementations. It comes integrated with Genie, a rich library offering parsers, learn capabilities, and device operations for various Cisco operating systems like IOS XE, NX-OS, and IOS XR.
pyATS enables engineers to define network topologies using a centralized testbed file, create robust test cases, execute them against live or simulated devices, and generate comprehensive reports. It's designed to streamline functional and regression testing, validate network configurations, and facilitate continuous integration and deployment (CI/CD) pipelines in a network environment, significantly reducing manual effort and improving test coverage.
CAVEATS
pyATS primarily targets automation and testing of Cisco network devices, although its extensible architecture allows for integration with other vendors or systems. It requires a Python environment and is typically installed via pip. Users should be aware of the learning curve associated with its comprehensive feature set, especially when utilizing advanced concepts like the Abstract Everything Concept (AEC) and custom extensions. Proper testbed definition and environment setup are crucial for effective use.
KEY COMPONENTS
pyATS is built upon several key components:
Testbed: A YAML or Python file that describes the network topology, including devices, links, and credentials, serving as the central inventory for test operations.
Genie: An open-source, highly extensive library built on top of pyATS, providing parsers, learn capabilities, and device operation APIs for various Cisco operating systems. It allows abstracting device output into structured Python objects.
Abstract Everything Concept (AEC): A core design philosophy of pyATS that promotes writing reusable tests independent of specific device implementations by abstracting away low-level device interactions.
INSTALLATION
pyATS is a Python package and is typically installed using pip. It is highly recommended to install it within a Python virtual environment to manage dependencies effectively and avoid conflicts with other Python projects.
Example:
pip install pyats pyats.contrib (for basic pyATS and common contributions including Genie)
Specific versions of Python are often recommended or required, so checking the official documentation is advised.
HISTORY
Developed internally by Cisco engineers to standardize and scale network device testing, pyATS has evolved into a robust, enterprise-grade test automation solution. It was later made available to the broader community and Cisco customers through DevNet, Cisco's developer program. Its development has focused on abstraction, reusability, and integration with modern CI/CD practices, incorporating contributions from internal teams and feedback from its growing user base. The integration of Genie has significantly expanded its capabilities for parsing and interacting with Cisco network operating systems.