[Day #98 PyATS Series] Full-Scale Mock Network Simulation (pyATS + VIRL/EVE-NG) Using pyATS for Cisco [Python for Network Engineer]

[Day #98 PyATS Series] Full-Scale Mock Network Simulation (pyATS + VIRL/EVE-NG) Using pyATS for Cisco [Python for Network Engineer]


Introduction: Key Concepts of Mock Network Simulation

Welcome to Day #98 of the 101 Days of pyATS (Vendor-Agnostic) series. Today, we focus on full-scale network simulations using pyATS integrated with VIRL or EVE-NG. For network engineers, being able to replicate complex production environments in a lab is crucial for testing, validation, and automation training. This workflow allows you to simulate multi-vendor topologies, run automation jobs, and validate behaviors without touching live networks.

Using Python for Network Engineer, I will demonstrate a step-by-step workflow to spin up virtual labs, connect devices, execute CLI and API tests, and generate realistic validation reports. This Article emphasizes production-ready frameworks, GUI and CLI outputs, and full network observability.


Topology Overview

My lab topology simulates a multi-site network with core, aggregation, and access layers:

  • Core Layer: Cisco ISR routers
  • Distribution Layer: Cisco Catalyst switches, Arista switches
  • Access Layer: Virtualized hosts and firewalls (Palo Alto, FortiGate)
  • Management Node: pyATS automation server running Python scripts

Diagram:

This setup is fully reproducible in VIRL or EVE-NG, enabling engineers to spin up lab environments for testing network automation scripts.


Topology & Communications

  • Devices communicate over SSH (CLI) or REST APIs depending on vendor and device type.
  • The pyATS testbed includes:
    • Device names, IPs, OS type, credentials
    • Roles (core, distribution, access)
    • Virtual lab integration details (VIRL/EVE-NG endpoints)
  • pyATS scripts interact with:
    • Interfaces and routing tables
    • BGP/OSPF neighbors
    • VLANs, VRFs, VXLANs
    • Device health, license status
  • Outputs are collected in JSON for further parsing and reporting.

Workflow Script

My automation workflow includes:

  1. Loading the testbed.
  2. Validating device connectivity and network state.
  3. Collecting configuration and interface data.
  4. Running automated tests (ping, BGP, OSPF, VLAN validation).
  5. Generating structured outputs for documentation or reporting.

Sample Workflow

from genie.testbed import load
from genie.libs.parser.utils import get_structured_data
from pyats.async_ import pcall

# Load testbed
testbed = load('testbed.yml')

# Function to collect interface and routing info
def collect_device_info(device):
    device.connect()
    info = {}
    info['hostname'] = device.name
    info['interfaces'] = device.parse('show ip interface brief')
    info['ospf'] = device.parse('show ip ospf neighbor')
    info['bgp'] = device.parse('show bgp summary')
    device.disconnect()
    return info

# Parallel collection for efficiency
results = pcall(collect_device_info, *[dev for dev in testbed.devices.values()])

# Save to JSON for reporting
import json
with open('network_sim_results.json', 'w') as f:
    json.dump(results, f, indent=2)

print("Network simulation data collected successfully.")

Explanation by Line

  • testbed = load(‘testbed.yml’): Loads all virtual devices from the VIRL/EVE-NG lab.
  • collect_device_info(device): Connects to each device and parses interface, OSPF, and BGP information.
  • pcall(…): Executes the function on all devices in parallel, reducing collection time.
  • json.dump(…): Stores structured network data for reporting and analysis.

This script ensures full visibility of simulated networks before pushing any automation or configuration changes.


testbed.yml Example

testbed:
  name: FullScaleLab
  devices:
    core1:
      type: router
      os: iosxe
      connections:
        cli:
          protocol: ssh
          ip: 10.10.10.1
          username: admin
          password: Cisco123
    dist1:
      type: switch
      os: iosxe
      connections:
        cli:
          protocol: ssh
          ip: 10.10.20.1
          username: admin
          password: Cisco123
    arista1:
      type: switch
      os: eos
      connections:
        cli:
          protocol: ssh
          ip: 10.10.30.1
          username: admin
          password: Arista123
    palo1:
      type: firewall
      os: panos
      connections:
        cli:
          protocol: ssh
          ip: 10.10.40.1
          username: admin
          password: Palo123

This allows VIRL/EVE-NG lab simulation, making it fully reproducible and vendor-agnostic.


Post-Validation CLI (Expected Outputs)

Example: Interface Validation

core1# show ip interface brief
Interface              IP-Address      Status
GigabitEthernet0/0     10.10.10.1     up
GigabitEthernet0/1     10.10.20.1     up

Example: OSPF Neighbors

core1# show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address
10.10.20.2       1   FULL/DR         00:00:34    10.10.20.2

Example: BGP Summary

core1# show bgp summary
Neighbor      AS      State
10.10.30.2    65002   established

These outputs are captured automatically by pyATS scripts for reporting and validation.


FAQs

Q1: What is a full-scale mock network simulation using pyATS and VIRL/EVE-NG?
A1: It’s a virtual lab environment replicating production networks with multiple devices, topologies, and protocols. pyATS interacts with these virtual devices to validate configurations, perform automation tests, and simulate real-world network behavior, without impacting production.


Q2: Why combine pyATS with VIRL or EVE-NG for simulation?
A2: pyATS provides automation, testing, and validation capabilities, while VIRL/EVE-NG offers virtualized multi-vendor environments. Together, they enable safe, repeatable testing for configuration changes, feature validation, and network troubleshooting before touching production networks.


Q3: Can multi-vendor devices be included in the simulation?
A3: Yes. You can deploy Cisco, Arista, Juniper, Palo Alto, and FortiGate virtual images within VIRL/EVE-NG. pyATS can then execute vendor-agnostic scripts, leveraging Genie parsers to unify outputs, enabling consistent validation across diverse platforms.


Q4: How does the simulation handle realistic traffic and protocol behavior?
A4: Virtual devices emulate routing protocols (BGP, OSPF, EIGRP), overlay networks (VXLAN/EVPN), VPNs, ACLs, QoS, and multicast). pyATS can push test traffic, monitor convergence, and validate forwarding paths, closely mirroring production conditions.


Q5: Can this setup be used for pre-deployment validation of network changes?
A5: Absolutely. Engineers can:

  • Test configuration changes safely.
  • Validate software upgrades and feature enablement.
  • Detect potential misconfigurations before impacting live services.
  • Run end-to-end workflow validation in a controlled environment.

Q6: How scalable is the simulation environment?
A6: Highly scalable. VIRL/EVE-NG supports tens to hundreds of virtual nodes, depending on hardware. pyATS scripts can orchestrate complex multi-device workflows, including interface configurations, routing tests, and topology changes across the full simulated network.


Q7: Can results from the simulation be used to generate reports or documentation?
A7: Yes. pyATS can capture interface states, protocol tables, VLANs, LLDP/CDP neighbors, and test outcomes, and generate Markdown/PDF reports. This helps create audit-ready pre-deployment validation documentation.


Q8: How does using a virtual simulation improve training and troubleshooting skills?
A8: Engineers can:

  • Practice complex configurations safely.
  • Observe failure scenarios and recovery mechanisms.
  • Validate multi-vendor interoperability.
  • Sharpen Python automation skills using realistic, production-like networks.

YouTube Link

Watch the Complete Python for Network Engineer: Full-Scale Mock Network Simulation (pyATS + VIRL/EVE-NG) Using pyATS for Cisco [Python for Network Engineer] 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

Take your Python for Network Engineer skills to the next level! Enroll in Trainer Sagar Dhawan’s 3-month instructor-led course and gain mastery over real-world network simulations, automation, and validation workflows.

Course details here: Python, Ansible, API for Network Engineers

Build production-ready frameworks, automate complex network operations, and test multi-vendor labs safely using pyATS and VIRL/EVE-NG.

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