Welcome to the Python Learning Series for Network Engineers. In this series, we will explore various ideas and tools that can be used for day-to-day network automation and monitoring tasks. The first tool we will be discussing is PyATS, which stands for Python Automated Test System, a framework introduced by Cisco. PyATS is an end-to-end DevOps automation ecosystem, which introduces DevOps culture into network automation, such as introducing a CI/CD pipeline into network configuration management.
Using this framework, you can have a centralized repository for maintaining configuration data, like Python scripts or Ansible playbooks, and test the configuration changes in a test environment before deploying them in the production environment. This results in more reliable and efficient configuration changes and provides a single-click track of configuration changes.
What is PyATS?
PyATS is a mature system for future testing, originally developed for Cisco internal engineering use, and now is open-source and the de facto test framework for internal Cisco engineers across different platforms and functions.
PyATS can be used to connect to the base and make sure they are up and running without many scripts or configuration changes. You can retrieve information about networks, monitor routing protocol state, and take before and after snapshots of the network and compare them. Even if you don’t have much knowledge of Python, you will be able to perform most of the tasks using PyATS.
The PyATS test ecosystem architecture is built on three stages:
1)The command setup stage
2)The trigger and verification stage and
3)The common cleanup stage.
Features of PyATS:
PyATS provides various features that can be used for network automation and monitoring tasks. Some of the key features of PyATS are:
Configuration Parsing Libraries:
PyATS provides various configuration parsing libraries like Genie library, which makes it easy to retrieve network information.
PyATS provides a DIF mechanism to compare the configuration of the previous date, making it easier to track configuration changes.
Integrates with Third-Party Tools:
PyATS can integrate with third-party tools like Ansible, Global Framework, Jenkins, and multiple CD pipelines, allowing network engineers to use a single tool for automation and monitoring tasks.
PyATS is based on Python, making it easy for network engineers to write scripts without extensive programming knowledge.
Installation of PyATS:
Step 1: Set up a virtual environment:
The first step in installing PyATS is to set up a virtual environment. A virtual environment is an isolated Python environment where you can install packages without affecting the system’s global Python environment. Here’s how you can set up a virtual environment:
-Create a directory to hold your PyATS-related files.
-Inside that directory, create a virtual environment using the following command:
python3.10 -m venv
-Activate the virtual environment using the following command:
Step 2: Install PyTAS:
Once you’ve set up the virtual environment, you can proceed to install PyATS. Here’s how you can install PyATS using pip:
-Ensure that you’re inside the virtual environment.
-Install PyATS using the following command:
pip3 install pyats[full]
-Wait for the installation to complete.
Step 3: Verify the Installation:
After the installation is complete, you can verify that PyATS is installed correctly. Here’s how you can verify the installation:
-Verify the PyATS version using the following command:
pyats version -h
-Verify that PyATS is working correctly by running a simple PyATS program.
In conclusion, PyATS is a powerful and flexible tool for network automation and monitoring. Its comprehensive test ecosystem architecture, flexible integration with third-party tools, and Python-based scripting make it an excellent choice for network engineers who want to improve their efficiency and productivity. If you are a network engineer looking for a tool that can simplify network automation and monitoring tasks, PyATS is a tool worth exploring.
Unlock the Power of Network Automation ! Enroll in our Comprehensive Udemy Course Today !
Topics & libraries Covered:
- PARAMIKO, NETMIKO, NAPALM, NORNIR and NCCLIENT libraries
- Cisco IOS, vIOS and NXOS SSH Automation
- Cisco CSR 1000v Netconf and RestAPI examples
- NX-API Automation (NXAPI CLI and bash)
- PyATS, Cisco Genie Parser
- NETCONF & RESTCONF API Automation
- YANG Data Models and YANG Suite demo
- IPAddress Module and requests module
- Python Core Fundamentals for Network Engineers
- Python Data Types
- Python Text & CSV File operations (read/write) device data
- Python IDE (PyCharm) Setup for Network Automation
- GNS3 Lab Setup for Network Automation
- Python Functions, Modules, Classes and Objects Tutorial
- Python Multithreading Examples (threading and concurrent futures)
- Python Logging, schedule and Email for monitoring
- Python SSH CLI Parsing Using RegEx
- How to Use JSON, YAML and XML Files for Device Config