Cisco pyATS (Python Automated Test System) alongside Genie forms a powerful network automation framework that complements both CLI-based and YANG-based automation tools. In this lesson, we will explore the capabilities of pyATS and Genie to understand how they enhance network testing and automation.
pyATS & Genie: A Comprehensive Overview
Originally, pyATS (Python Automated Test System) was developed as a test automation framework that could be applied across various domains, including software, hardware, security, and IoT. However, when combined with Genie, it is primarily used in network automation.
Among these, automated test cases are the core functionality of pyATS, while the other three (parse, learn, and APIs) are the main components of the Genie framework. Genie features can be used independently or in combination with automated test cases to unlock advanced network automation capabilities.
Quick Practical Definitions of pyATS & Genie Components
๐น Parser:
When running a network command like โshow ip interface briefโ
, the output is raw text. To extract meaningful informationโsuch as identifying which interfaces are up or downโyou typically need to apply regular expressions or manual text processing. However, Genie parsers eliminate this need by converting CLI outputs into structured Python data (lists & dictionaries).
Genie supports 500+ commands across 10+ network device types & vendors.
Feature | pyATS (Core Framework) | Genie (Enhancement Layer) | Explanation |
---|---|---|---|
Primary Role | Test Automation Framework | Network Automation Toolkit | pyATS is a general-purpose testing framework, and Genie extends it for network automation. |
Parsing (Parser) | โ Not available | โ Yes | Converts raw CLI output into structured JSON/Python objects. |
Learning (Learner) | โ Not available | โ Yes | Learns device/protocol state and stores structured data for before/after comparison. |
APIs | โ Limited APIs | โ Rich APIs | Provides vendor-agnostic APIs for retrieving structured data and configurations. |
Automated Test Cases | โ Core feature | โ Enhanced with Genie | Automates network tests, such as verifying connectivity, routing, and configurations. |
Device & Vendor Support | โ Supports multiple vendors | โ 10+ vendors, 500+ commands | Works across multi-vendor environments. |
CLI-Based Automation | โ Yes | โ Yes | Can execute CLI commands via SSH/Telnet. |
YANG-Based Automation | โ Yes (via NETCONF, RESTCONF) | โ Yes (abstracted through APIs) | Supports model-driven network automation. |
Configuration Abstraction | โ No direct abstraction | โ Yes | Genie provides API-based configuration abstraction across vendors. |
Use Cases | Testing & validation | Parsing, learning, API-based automation, and validation | pyATS is more focused on test automation, while Genie expands it into full network automation. |
๐น Learner:
Genie can learn and store structured profiles of various protocols and technologies.
For example, learning the BGP profile involves running key BGP-related commands, collecting both raw and structured outputs, and storing them for analysis.
This feature enables before-and-after comparisons to detect changes in configuration, routing tables, neighbor states, or troubleshoot network issues.
๐น APIs:
Genie provides an abstraction layer for both configuration and monitoring, offering vendor-agnostic APIs.
For example, instead of manually running different routing commands across different vendors, a single API like get_route()
can retrieve structured routing table data from multiple device types without needing to know the exact command behind it.
๐น Automated Test Cases:
Perhaps the most well-known (but in practice, often underutilized) feature of pyATS is its ability to automate network test cases.
You can automate post-change verifications after network modifications, such as:
Checking BGP & OSPF neighbors
Verifying route advertisements
Ensuring connectivity via ping/traceroute
Detecting configuration drift
These tests ensure network stability after updates, reducing manual effort and human error.
Summary
To summarize the operation and differences between pyATS and Genie:
pyATS manages inventory (called testbed in pyATS, as its primary application is running test case scripst agains these devices), establishes device connections, executes test scripts, and provides comprehensive logging and reporting.
Genie enhances pyATS by enabling command parsing into structured formats, learning device profiles, and simplifying automation by providing structured data for easier processing in scripts.
Together, they form a powerful framework for network testing and automation.