[Day#3 PyATS Series] Installing pyATS & Genie (core, NX-OS, IOS-XR plugins) using pyATS for Cisco

[DAY#3 PyATS Series] Installing pyATS & Genie (core, NX-OS, IOS-XR plugins) (Ping Tests) using pyATS (Vendor-Agnostic) โ€“ Cisco, Arista, Palo Alto, Fortigate [Python for Network Engineer]

Introduction on the Key Points

In today’s Day #3 of our “101 Days of pyATS (Vendor-Agnostic)” blog series, we focus on setting up the essential components of pyATS by installing the core libraries and vendor-specific plugins such as NX-OS and IOS-XR. These tools are the foundation for network test automation and validation. Whether you’re working with Cisco IOS-XE, NX-OS, or IOS-XR platforms, having the right Genie and pyATS plugins is critical for enabling Python-based interaction with devices. This post is crafted for anyone interested in Python for Network Engineer roles and network automation.

We will guide you through installing the base pyats, genie, and relevant plugin packages inside a Python virtual environment to ensure a clean and isolated setup. By the end of this article, you’ll have a fully working environment capable of running your first platform-specific test scripts.


Topology Overview

For demonstration purposes, we will use a topology with three Cisco routers:

  • One running IOS-XE (R1)
  • One running NX-OS (NX1)
  • One running IOS-XR (XR1)

Each router will be accessed via SSH using credentials stored in a testbed.yml file.


Topology & Communications

DeviceOSIP AddressUsernamePassword
R1IOS-XE192.168.100.1admincisco123
NX1NX-OS192.168.100.2admincisco123
XR1IOS-XR192.168.100.3admincisco123

All devices should be reachable via SSH on port 22.


4. Workflow Script

Below is a Python script that sets up the environment and verifies connectivity to all devices:

# Create and activate the virtual environment
python3 -m venv pyats_env
source pyats_env/bin/activate

# Upgrade pip
pip install --upgrade pip

# Install pyATS and Genie core
pip install pyats genie

# Install platform-specific plugins
pip install genie.libs.sdk
pip install genie.libs.parser
pip install genie.libs.ops
pip install pyats[kleenex]  # For CLI cleanups

# Optional: Install NX-OS and IOS-XR support
pip install genie.libs.nxos
pip install genie.libs.xr

Explanation by Line

  • python3 -m venv pyats_env: Creates a clean Python virtual environment.
  • source pyats_env/bin/activate: Activates the environment.
  • pip install pyats genie: Installs the base pyATS and Genie packages.
  • genie.libs.sdk, parser, and ops: These are core modules to support parsing, operations, and learning features.
  • pyats[kleenex]: Useful for testbed cleanup tasks.
  • genie.libs.nxos and genie.libs.xr: Optional but needed if working with NX-OS and IOS-XR platforms.

testbed.yml Example

devices:
  R01:
    os: iosxe
    type: router
    connections:
      cli:
        protocol: ssh
        ip: 192.168.100.1
        port: 22
    credentials:
      default:
        username: admin
        password: cisco123

  NX1:
    os: nxos
    type: switch
    connections:
      cli:
        protocol: ssh
        ip: 192.168.100.2
    credentials:
      default:
        username: admin
        password: cisco123

  XR1:
    os: iosxr
    type: router
    connections:
      cli:
        protocol: ssh
        ip: 192.168.100.3
    credentials:
      default:
        username: admin
        password: cisco123

Post-validation CLI Screenshots (Expected Output)

Once setup is done, connect to each device using the pyATS shell or scripts:

(pyats_env) $ pyats shell
>> from genie.testbed import load
>> testbed = load('testbed.yml')
>> r1 = testbed.devices['R01']
>> r1.connect()
>> r1.execute('show ip interface brief')

Expected: You should see interface statuses.

Repeat the same for NX1 and XR1. Ensure that all connections succeed and execute() returns CLI output.


FAQs

Q1: What is the difference between pyATS and Genie?

Answer:

  • pyATS is Ciscoโ€™s Python testing framework that provides the core automation infrastructure, including testbed management, device connections, and test execution.
  • Genie is a library built on top of pyATS that includes parsers, models, and reusable test scripts.
  • You need both pyATS and Genie for full functionality (e.g., parsing show commands and running pre-built health checks).

Q2: How do I install pyATS and Genie in my Python environment?

Answer:
Activate your virtual environment and run:

pip install pyats[full]
pip install genie

This will install the pyATS core framework, Genie core, and essential plugins.


Q3: What are pyATS plugins, and why are they needed (NX-OS, IOS-XR, IOS-XE)?

Answer:

  • Plugins extend pyATS to support specific Cisco OS platforms.
  • Examples:
    • pyats.contrib for community additions
    • genie.libs.sdk for higher-level reusable test libraries
    • unicon.plugins.iosxr, unicon.plugins.nxos for CLI connections
  • Installing these ensures proper command execution and parsing for NX-OS, IOS-XR, IOS-XE devices.

Q4: How can I verify if pyATS and Genie are installed successfully?

Answer:
Run the following commands:

pyats version check
python -c "import genie; print(genie.__version__)"

This will display the installed versions of pyATS and Genie to confirm successful installation.


Q5: How do I install platform-specific plugins like NX-OS or IOS-XR?

Answer:
Use pip to install them individually or together:

pip install unicon.plugins.nxos unicon.plugins.iosxr unicon.plugins.iosxe
pip install genie.libs.parsers genie.libs.sdk

These plugins allow pyATS to recognize the OS type and use appropriate parsers and connection handlers.


Q6: Whatโ€™s included in the pyats[full] installation?

Answer:

  • pyats.aetest for test execution
  • pyats.topology for testbed management
  • pyats.connections for device connections
  • CLI utilities like pyats create testbed
  • Common Genie parsers and base plugins
    You can additionally install platform-specific plugins as needed.

Q7: Do I need internet access to install these packages?

Answer:
Yes. pip will download packages from PyPI. If you have an air-gapped network, you can:

  • Download .whl files separately
  • Transfer them to your environment
  • Install using pip install <filename>.whl

Q8: Can I update pyATS and Genie to the latest versions safely?

Answer:
Yes. Run:

pip install --upgrade pyats[full] genie

However:

  • Always test upgrades in a non-production environment first.
  • Check release notes for backward compatibility issues.
  • Ensure your scripts and testbeds are not broken by parser updates.

YouTube Link

Watch the Complete Python for Network Engineer: Installing pyATS & Genie (core, NX-OS, IOS-XR plugins) using pyATS for Cisco Lab Demo & Explanation on our channel:

Master Python Network Automation, Ansible, REST API & Cisco DevNet
Master Python Network Automation, Ansible, REST API & Cisco DevNet
Master Python Network Automation, Ansible, REST API & Cisco DevNet
Why Robot Framework for Network Automation?

Join Our Training: Master Python for Network Engineer with Sagar Dhawan

Want to go beyond basic pings and CLI parsing? Join our 3-Month Instructor-Led Training Program and become a Certified Automation Engineer.

  • Real-world labs across Cisco, Arista, Palo Alto, Fortigate
  • Build custom parsers, test libraries, CI/CD pipelines
  • Learn RESTCONF, NETCONF, Nornir, Ansible & more
  • Weekly projects, mentorship, and lifetime access

Course Outline & Registration

Enroll Now & Futureโ€‘Proof Your Career
Emailinfo@networkjourney.com
WhatsApp / Call: +91 97395 21088

Make the leap from CLI to APIs with our Python for Network Engineer program. This course is built by engineers, for engineers.


Trainer Sagar Dhawan

Hi all,
Good to see you here.
I'm your Trainer for CCIE, CCNP, CCNA, Firewall batches and many more courses coming up!
Stay tuned for latest updates!
Keep me posted over Whatsapp/Email about your experience learning from us.
Thanks for being part of - "Network Journey - A journey towards packet-life!!!"