paint-brush
Network Test and Automation: PyATS 101 in 5 Minutesby@verlainedevnet
681 reads
681 reads

Network Test and Automation: PyATS 101 in 5 Minutes

by Verlaine j muhunguNovember 18th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

PyATS is a powerful tool that is essential for modern networking. Originally developed by Cisco, it is used internally to conduct millions of tests each month. While some core components of the tool are proprietary, it was made publicly available in 2017. In this brief introduction, you'll discover pyATS through insightful explanations.
featured image - Network Test and Automation: PyATS 101 in 5 Minutes
Verlaine j muhungu HackerNoon profile picture


Don't spend your time doing work a well-trained monkey could do | From automate the boring stuff with python book


Automation is not a replacement for our workforce; it presents an opportunity to embrace agility in a constantly evolving digital society.


Considering network engineers' numerous tedious tasks each week, automation becomes a crucial ingredient for success.


Beyond the hype and rankings, Python has emerged as the de facto language for automation. Its elegant syntax and versatility have led to the creation of amazing tools.

What is Cisco PyATS

pyATS, which stands for Python Automated Test System, was developed by Cisco Systems to automate testing and validate networks. It is often called a "Swiss Army knife" due to its ability to perform a wide range of tasks beyond conventional expectations. In addition to automated testing, pyATS supports network configuration testing and updates,...


  • Language: Python, it is oriented for DevOps and NetDevOps

  • Typical usage: Network configuration tests, anomaly detection, connectivity validation…

  • Objective: Automating network tests and validation by providing a modular and extensible environment.

    Main modules

  • PyATS: the main framework for automated tests.

  • Genie: Collection of automation libraries for configuring, analyzing, and verifying network data.


PyATS is a big ecosystem of innovations where we can do amazing and it goes beyond Cisco environments!

How to install pyATS quickly on Windows Subsystem for Linux ( Ubuntu 24.04 LTS)

The best way to install pyATS is to create a Python virtual environment and this is the quickest way to do it by observing the capture below

Creating the python virtual env for pyATS

installing pyATS

Installing pyATS in the python virtual environment


To install Genie the process is the same!

Checking the installation

Checking pyats if it is installed


The pyats framework is installed



The genie library is installed


PyATS and Genie are installed with their packages.

Verifying PyATS versions


pyats version check


verifying pyATS version


After running the command we see the version,pyATS is properly installed and we can achieve amazing things we want.

Key concepts to know about pyATS

What makes pyATS unique is its abstraction, and to understand it better, you need to engage with these abstractions!


  • Testbed: This is the representation of network environments. A YAML file describes devices, their roles, and IP addresses, and here is how it looks when the file is written.


    # Step 0: list of devices
    devices:
      iosxr1:
        # Step 1: OS and Type
        type: iosxr-Prod
        os: iosxr
        # Step 2: credentials
        credentials:
          default:
            username: admin
            password: Hacker@204k
        # Step 3: connection parameters
        connections:
          vty:
            protocol: ssh
            ip: test-mgmt.talesoftechnology.com
            port: 8080
    


  • Test scripts: python scripts that contain all instructions for every test.
  • Parsers: with an impressive library and over 1500 parsers, Genie expertly converts raw text into structured text.
  • Triggers: they enable specific automated actions, in response to events, in other words, they are similar to webhooks.

Main features and use cases

  • States comparison: network comparison state before and after a change or update.
  • Report and journaling: it generates test reports and detailed logs for every
  • Multi-environment execution: it is compatible with physical and virtual environments.

Practical use cases

  • State validation: Compare the configuration status of a device before and after a change to ensure there is no configuration drift.
  • Anomaly detection: Automate the identification of anomalies in device configurations or states.
  • Connectivity Test: Use ping or traceroute commands to check connectivity between devices


Conclusion

Now you know how to install pyATS using the Windows Subsystem for Linux, and you don’t need a lengthy guide! You understand the basic concepts; even though pyATS can seem abstract, the best way to grasp it is through interaction with various abstractions.


Automation is essential for agility today, you don’t have to reinvent the wheel with tedious tasks.


With pyATS, you can save time and reduce stress compared to handling everything manually.


In the next article, you will learn how to create a testbed, and we will demystify pyATS, it’s not as hard as you think!