Your resource for web content, online publishing
and the distribution of digital products.
S M T W T F S
 
 
 
 
 
1
 
2
 
3
 
4
 
5
 
6
 
7
 
8
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
 
25
 
26
 
27
 
28
 
29
 
30
 

Running Cisco pyATS on Windows 11 Really Helped Me Brush Up My Python Fundamentals

DATE POSTED:November 22, 2024

\ \ Over recent weeks, my journey into network automation has rekindled my mastery of Python fundamentals, core principles of programmability, and diverse data architectures. As I delve into the capabilities of the pyATS framework for automation and testing, it is essential for me to set up a suitable work environment. Typically, this setup includes a Linux operating system (such as Ubuntu, Kali, or CentOS), Python version 3.6 or higher, access to various network devices (routers, firewalls, access points, and switches), along with the installation of pyATS and the Genie library.

\ In this story, I will walk you through the process I used to set up a Linux environment on Windows 11 using Windows Subsystem for Linux (WSL). I'll cover everything from installation to configuration, ensuring that you have all the tools you need to practice and excel in network automation using pyATS.

Overview of the Cisco pyATS Solution

Initially developed for internal use by Cisco, pyATS was designed for rigorous testing processes before being released to the public. Today, it stands at the core of Cisco’s Test Automation Solution, used by thousands of engineers worldwide.

According to Cisco, pyATS is the de-facto test framework for Cisco engineers across various platforms and functions. It powers millions of CI/CD, sanity, regression, scale, HA, and solution tests every month.

Additionally, pyATS has been adopted by thousands of network engineers and developers globally, further proving its versatility and reliability.

Key Facts about pyATS
  • pyATS was made available to the public in 2017.

  • pyATS is a Python-based framework (pyATS stands for Python Automated Test System).

  • pyATS has the Genie library, which specialize in network device automation and validation.

  • pyATS uses testbeds to define network devices and topologies targeted by test cases.

  • pyATS includes a web-based dashboard called XPRESSO for managing test suites, tetsbeds and test results.

  • pyATS is agnostic by its design, all OS/Platform and management protocol support is achievable through plugins, library implementations and extensions.

    \ ==The network automation market, which include tools like pyATS, is projected to grow from $4 billion in 2019 to 22.58 billion by 2027.==

Installation Options

There are several options to install pyATS on a computer, depending on your operating system and preferences. You can use pip, set up a virtual environment, install from source, or run it in a Docker container. Cisco DevNet offers resources and tutorials for setting up pyATS, including sandbox environments for hands-on practice.

Personally, I chose to install it on Windows 11, my native OS. While running it on a Linux virtual machine is an option, the convenience of using Windows made it my preferred choice.

Step 1: Enable WSL on  Windows

The Windows Subsystem for Linux (WSL) enables developers to install a Linux distribution and use Linux applications, utilities, and Bash command line tools directly on Windows. This is achieved without the need for a traditional virtual machine or dual-boot setup, providing a seamless and efficient development experience.

WSL is compatible with Windows 10 and above.

To get started, open Windows PowerShell or the Command Line Interface with elevated privileges and enter the following command:

wsl –install

The command should install WSL and the Ubuntu distribution (default option), as you can see in the code below:

\

Your environment has been set up for using Node.js 20.12.2 (x64) and npm. C:\Windows\System32>wsl --install Downloading: Windows Subsystem for Linux 2.3.26 Installing: Windows Subsystem for Linux 2.3.26 Windows Subsystem for Linux 2.3.26 has been installed. Installing Windows optional component: VirtualMachinePlatform Deployment Image Servicing and Management tool Version: 10.0.26100.1252 Image Version: 10.0.26120.1912 Enabling feature(s) [==========================100.0%==========================] The operation completed successfully. The requested operation is successful. Changes will not be effective until the system is rebooted. Installing: Ubuntu Ubuntu has been installed. The requested operation is successful. Changes will not be effective until the system is rebooted. C:\Windows\System32>

\ After this step is complete, reboot your computer.

Step 2: Install a Linux Distribution

If no distribution is installed after setting up WSL, you may need to install a distribution manually.

  • Open the Microsoft Store and search for your preferred Linux distribution. On my computer, I installed Ubuntu 24.04 LTS.
  • Once the distribution is installed, launch the Start menu and open Ubuntu.

\ \

Step 3: Set Up Your Linux Environment

During the first launch, you will need to create a username and set a password for your Ubuntu system. Follow the prompts to complete this setup.

  • \
Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: katshidev New password: Retype new password: passwd: password updated successfully Installation successful! To run a command as administrator (user "root"), use "sudo ". See "man sudo_root" for details. Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro System information as of Mon Nov 18 17:24:28 SAST 2024 System load: 0.0 Processes: 53 Usage of /: 0.1% of 1006.85GB Users logged in: 0 Memory usage: 5% IPv4 address for eth0: 172.20.249.39 Swap usage: 0% This message is shown once a day. To disable it please create the /home/katshidev/.hushlogin file. katshidev@EOC:~$

Then, run these two commands to update and upgrade your Linux packages

\

katshidev@EOC:~$ sudo apt update && sudo apt upgrade

\ This ensures that all your Linux packages are up-to-date and ready for further installations.

\

katshidev@EOC:~$ sudo apt update && sudo apt upgrade [sudo] password for katshidev: Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease Get:2 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB] Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB] Get:4 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [466 kB] Get:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB] Get:6 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [15.0 MB] Get:7 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [98.1 kB] Get:8 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [7196 B] Step 4: Create a virtual environment using venv

Some limitations of WSL restrict the direct installation of Python packages globally. The best approach to overcome this is to create a virtual environment.

A virtual environment is an isolated workspace for Python projects. It allows you to manage dependencies and packages separately from the system-wide Python installation, ensuring that each project has its own set of libraries without conflicts. This approach enables you to use different package versions for different projects seamlessly.

\

  • Create a new directory and move to it (pyats_projects in my case)
mkdir pyats_projects cd pyats_projects

\

  • Ensure the venvpackage is installed. This package will allow you to create virtual environments.
apt install python3.12-venv

\

  • Create the virtual environment:
python3 -m venv myenv

\

  • Activate the newly created environment:
source myenv/bin/activate

\

Step 5: Install Cisco PyATS

Now pyATS can be installed using the pip install pyats[full]command :smile:

\

(myenv) root@EOC:/home/katshidev/pyats_projects# pip install pyats[full] Collecting pyats[full] Downloading pyats-24.10-cp312-cp312-manylinux2014_x86_64.whl.metadata (4.6 kB) Collecting packaging>=20.0 (from pyats[full]) Downloading packaging-24.2-py3-none-any.whl.metadata (3.2 kB) ---output ommited--- Collecting pyats.log<24.11.0,>=24.10.0 (from pyats[full]) Downloading pyats.log-24.10-cp312-cp312-manylinux2014_x86_64.whl.metadata (3.4 kB) ---output ommited--- Collecting pluggy<2,>=1.5 (from pytest>=4.6->pytest-cov<5.0.0,>=4.0.0->pysnmp<6.2,>=6.1.4->genie.libs.sdk<24.11.0,>=24.10.0->genie<24.11.0,>=24.10.0->pyats[full]) Downloading pluggy-1.5.0-py3-none-any.whl.metadata (4.8 kB) Downloading genie-24.10-cp312-cp312-manylinux2014_x86_64.whl (29.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 29.2/29.2 MB 366.9 kB/s eta 0:00:00 Downloading genie.libs.robot-24.10-py3-none-any.whl (11 kB) Downloading genie.telemetry-24.10-py3-none-any.whl (70 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.2/70.2 kB 290.9 kB/s eta 0:00:00 Downloading genie.trafficgen-24.10-py3-none-any.whl (112 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 112.7/112.7 kB 417.5 kB/s eta 0:00:00 ---output ommited--- Successfully installed IxNetwork-9.30.2212.8 MarkupSafe-3.0.2 PrettyTable-3.12.0 aiofiles-24.1.0 aiohappyeyeballs-2.4.3 aiohttp-3.11.2 aiosignal-1.3.1 arrow-1.3.0 async-lru-2.0.4 attrs-24.2.0 backports.ssl-0.0.9 backports.ssl-match-hostname-3.7.0.1 bcrypt-4.2.0 binaryornot-0.4.4 certifi-2024.8.30 cffi-1.17.1 chardet-4.0.0 charset-normalizer-3.4.0 click-8.1.7 cookiecutter-2.6.0 coverage-7.6.7 cryptography-43.0.3 dict2xml-1.7.6 dill-0.3.9 distro-1.9.0 f5-icontrol-rest-1.3.13 frozenlist-1.5.0 genie-24.10 genie.libs.clean-24.10 genie.libs.conf-24.10 genie.libs.filetransferutils-24.10 genie.libs.health-24.10 genie.libs.ops-24.10 genie.libs.parser-24.10 genie.libs.robot-24.10 genie.libs.sdk-24.10 genie.telemetry-24.10 genie.trafficgen-24.10 gitdb-4.0.11 gitpython-3.1.43 grpcio-1.68.0 idna-3.10 iniconfig-2.0.0 ixnetwork-restpy-1.5.0 jinja2-3.1.4 jsonpickle-4.0.0 junit-xml-1.9 lxml-4.9.4 markdown-it-py-3.0.0 mdurl-0.1.2 multidict-6.1.0 ncclient-0.6.16 netaddr-0.10.1 packaging-24.2 paramiko-3.5.0 pathspec-0.12.1 pluggy-1.5.0 ply-3.11 propcache-0.2.0 protobuf-5.28.3 psutil-6.1.0 pyasn1-0.4.8 pyasynchat-1.0.4 pyasyncore-1.0.4 pyats-24.10 pyats.aereport-24.10 pyats.aetest-24.10 pyats.async-24.10 pyats.connections-24.10 pyats.contrib-24.10 pyats.datastructures-24.10 pyats.easypy-24.10 pyats.kleenex-24.10 pyats.log-24.10 pyats.reporter-24.10 pyats.results-24.10 pyats.robot-24.10 pyats.tcl-24.10 pyats.topology-24.10 pyats.utils-24.10 pycparser-2.22 pyftpdlib-2.0.1 pygments-2.18.0 pynacl-1.5.0 pyopenssl-24.2.1 pysmi-1.5.9 pysnmp-6.1.4 pysnmpcrypto-0.0.4 pytest-8.3.3 pytest-cov-4.1.0 python-dateutil-2.9.0.post0 python-engineio-3.14.2 python-slugify-8.0.4 python-socketio-4.6.1 pyyaml-6.0.2 requests-2.32.3 requests-toolbelt-1.0.0 rest.connector-24.10 rich-13.9.4 robotframework-7.1.1 ruamel.yaml-0.18.6 ruamel.yaml.clib-0.2.12 setuptools-75.5.0 six-1.16.0 smmap-5.0.1 text-unidecode-1.3 tftpy-0.8.0 tqdm-4.67.0 types-python-dateutil-2.9.0.20241003 unicon-24.10 unicon.plugins-24.10 urllib3-2.2.3 wcwidth-0.2.13 websocket-client-1.8.0 wheel-0.45.0 xlrd-1.2.0 xlsxwriter-3.2.0 xlwt-1.3.0 xmltodict-0.14.2 yamllint-1.35.1 yang.connector-24.10 yarl-1.17.2 (myenv) root@EOC:/home/katshidev/pyats_projects# Step 6: Verify the Installation

After the installation process is complete, you can now verify it is successfully installed using the command pyats check :upsidedownface:

(myenv) root@EOC:/home/katshidev/pyats_projects# pyats check /home/katshidev/pyats_projects/myenv/bin/pyats:5: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pyats.cli.__main__ import main Usage: pyats [options] Commands: clean runs the provided clean file create create scripts and libraries from template develop Puts desired pyATS packages into development mode diff Command to diff two snapshots saved to file or directory dnac Command to learn DNAC features and save to file (Prototype) learn Command to learn device features and save to file logs command enabling log archive viewing in local browser migrate utilities for migrating to future versions of pyATS parse Command to parse show commands run runs the provided script and output corresponding results. secret utilities for working with secret strings. shell enter Python shell, loading a pyATS testbed file and/or pickled data undevelop Removes desired pyATS packages from development mode validate utilities that help to validate input files version commands related to version display and manipulation General Options: -h, --help Show help Run 'pyats --help' for more information on a command. invalid choice: 'check' (choose from 'clean', 'create', 'develop', 'diff', 'dnac', 'learn', 'logs', 'migrate', 'parse', 'run', 'secret', 'shell', 'undevelop', 'validate', 'version') (myenv) root@EOC:/home/katshidev/pyats_projects# At the End of the Day…

The journey of mastering network automation with pyATS begins with a solid understanding of Python fundamentals and a well-structured environment. By leveraging the Windows Subsystem for Linux on Windows 11, you can seamlessly integrate a Linux environment that supports the robust capabilities of pyATS and the Genie library. This setup empowers you to perform comprehensive tests and automation on various network devices efficiently.

Cisco's pyATS, a tool once exclusive to internal use, has proven its versatility and reliability by becoming the de facto framework for network testing among thousands of engineers and developers worldwide. With multiple installation options, including pip, virtual environments, and Docker containers, setting up pyATS is accessible and adaptable to different user preferences.

As the network automation market continues to grow, embracing such powerful tools will undoubtedly enhance your ability to manage and automate complex network environments. By following the steps outlined, you are now well-equipped to explore the full potential of pyATS, ultimately advancing your skills in network automation.