pyATS Topology

26.3 · active · verified Thu Apr 16

pyATS Topology is a core component of the Cisco pyATS framework, providing robust objects and parsing capabilities for network testbed YAML definitions. It allows users to define network devices, links, and connections, enabling automated interaction with the network infrastructure for testing and operational tasks. The library is actively maintained and typically updated in sync with major pyATS framework releases, which occur quarterly or as needed.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates loading a testbed YAML file and accessing a defined device and its connection details. This is the fundamental way to interact with network topology in pyATS.

from pyats.topology import loader
import os

# Create a dummy testbed YAML file for demonstration
testbed_yaml_content = """
name: MyTestbed
devices:
  router1:
    type: iosxe
    os: iosxe
    connections:
      cli:
        protocol: ssh
        ip: 10.0.0.1
        port: 22
      rest:
        protocol: rest
        port: 443
"""

testbed_file_path = 'my_testbed.yaml'
with open(testbed_file_path, 'w') as f:
    f.write(testbed_yaml_content)

# Load the testbed
testbed = loader.load(testbed_file_path)

# Access devices and connections
device = testbed.devices['router1']
print(f"Testbed Name: {testbed.name}")
print(f"Device Name: {device.name}, Type: {device.type}, OS: {device.os}")
print(f"CLI Connection IP: {device.connections['cli'].ip}")

# Clean up the dummy file
os.remove(testbed_file_path)

view raw JSON →