[Day #86 PyATS Series] Automated RMA Device Onboarding (Multi-Vendor) Using pyATS for Cisco [Python for Network Engineer]

[Day #86 PyATS Series] Automated RMA Device Onboarding (Multi-Vendor) Using pyATS for Cisco [Python for Network Engineer]


Introduction on the Key Points

In modern network operations, replacing failed devices through RMA (Return Merchandise Authorization) processes is routine but can be operationally complex, especially in multi-vendor environments. Manual device onboarding risks misconfiguration, inconsistency, and service disruption.

This Article demonstrates a production-ready automated RMA device onboarding workflow using pyATS, ensuring new or replacement devices are automatically validated, configured, and integrated into the existing fabric. As a crucial competency in your career path as a Python for Network Engineer, mastering automated onboarding guarantees speed, accuracy, and scalability in production environments.

Key objectives covered:

  • Detect new devices automatically during RMA.
  • Validate device identity and baseline configuration.
  • Automatically provision correct configurations based on vendor type.
  • Capture structured audit reports and dashboard snapshots.

Topology Overview

  • Spine and Leaf: Cisco-based core fabric switches.
  • RMA Device: Either Cisco IOS XE, Arista EOS, or Juniper Junos, newly shipped from vendor.
  • Servers: Destination endpoints.

Objective:

  • Automate onboarding of new multi-vendor devices into data center fabric without manual intervention.

Topology & Communications

Communication Flow:

  1. Detect new device boot up and connect using pyATS.
  2. Execute CLI commands to capture serial number and platform info.
  3. Cross-reference with asset management database.
  4. Apply vendor-specific configuration templates via Ansible or Python scripts.
  5. Validate configuration correctness (interfaces, VRFs, routing).
  6. Capture CLI and GUI snapshots for audit.
  7. Generate structured onboarding report.

Workflow Script

from genie.testbed import load
from pyats.aetest import Testcase, test, main
import json
import os

ASSET_DB = {
    'CISCO1234': 'cisco_iosxe',
    'ARISTA5678': 'arista_eos',
    'JUNIPER9012': 'juniper_junos'
}

CONFIG_TEMPLATES = {
    'cisco_iosxe': 'templates/cisco_base_config.cfg',
    'arista_eos': 'templates/arista_base_config.cfg',
    'juniper_junos': 'templates/juniper_base_config.cfg'
}

class RMABaseOnboarding(Testcase):

    @test
    def detect_and_identify_new_device(self, testbed):
        self.onboarding_data = {}

        for device_name, device in testbed.devices.items():
            device.connect(log_stdout=False)
            print(f"[INFO] Connected to {device_name}")

            if device.os == 'iosxe':
                serial_output = device.execute('show version | include System serial number')
                serial_number = serial_output.split(":")[1].strip()

            elif device.os == 'eos':
                serial_output = device.execute('show version | include Serial')
                serial_number = serial_output.split(":")[1].strip()

            elif device.os == 'junos':
                serial_output = device.execute('show chassis hardware | match Serial')
                serial_number = serial_output.split()[-1]

            else:
                serial_number = 'UNKNOWN'

            os_type = ASSET_DB.get(serial_number, 'unknown')
            self.onboarding_data[device_name] = {
                'serial_number': serial_number,
                'os_type': os_type
            }

            print(f"[INFO] Device {device_name} detected: Serial {serial_number}, OS {os_type}")

    @test
    def apply_base_configuration(self, testbed):
        for device_name, data in self.onboarding_data.items():
            template_path = CONFIG_TEMPLATES.get(data['os_type'])
            assert template_path and os.path.exists(template_path), f"Missing config template for {data['os_type']}"

            config_data = open(template_path).read()
            device = testbed.devices[device_name]

            device.configure(config_data)
            print(f"[INFO] Applied base config to {device_name}")

    @test
    def validate_onboarding_success(self, testbed):
        for device_name, data in self.onboarding_data.items():
            device = testbed.devices[device_name]

            interfaces_output = device.execute('show interfaces status')
            assert 'up' in interfaces_output.lower(), f"Interface not up on {device_name}"

            print(f"[PASS] {device_name} interface validation successful")

    @test
    def capture_dashboard_snapshot(self):
        snapshot_path = '/tmp/rma_onboarding_snapshot.png'
        print(f"[INFO] GUI snapshot saved at {snapshot_path}")

    @test
    def save_onboarding_report(self):
        report_file = '/tmp/rma_onboarding_report.json'
        with open(report_file, 'w') as f:
            json.dump(self.onboarding_data, f, indent=4)

        print(f"[INFO] Onboarding report saved at {report_file}")

if __name__ == '__main__':
    main()

Explanation by Line

  • ASSET_DB:
    Maps serial numbers to OS types for asset validation.
  • CONFIG_TEMPLATES:
    Stores predefined config templates for each vendor type.
  • detect_and_identify_new_device():
    • SSH connects to new device.
    • Executes platform-specific commands to capture serial number.
    • Determines OS type via asset database lookup.
  • apply_base_configuration():
    • Validates config template availability.
    • Applies configuration using pyATS’s device.configure().
  • validate_onboarding_success():
    • Ensures interfaces are up and configured properly.
  • capture_dashboard_snapshot():
    • Captures monitoring dashboard for audit (placeholder).
  • save_onboarding_report():
    • Saves onboarding data into JSON report.

testbed.yml Example

testbed:
  name: rma_onboarding_testbed
  credentials:
    default:
      username: admin
      password: Cisco123

devices:
  new_cisco_device:
    os: iosxe
    type: router
    connections:
      cli:
        protocol: ssh
        ip: 10.1.10.100

  new_arista_device:
    os: eos
    type: switch
    connections:
      cli:
        protocol: ssh
        ip: 10.1.10.101

  new_juniper_device:
    os: junos
    type: router
    connections:
      cli:
        protocol: ssh
        ip: 10.1.10.102

Post-validation CLI (Real Expected Output)

Cisco IOS XE: show version

System serial number: CISCO1234
Cisco IOS XE Software, Version 17.3.1

Arista EOS: show version

Serial Number: ARISTA5678
Software image version: 4.25.1F

Juniper Junos: show chassis hardware | match Serial

Serial Number: JUNIPER9012

Interface Status Post-Configuration

show interfaces status
Port      Name    Status  VLAN
Gi1/0/1   Uplink  connected 10
Gi1/0/2   Server  connected 20

FAQs

Q1. What is RMA device onboarding in a multi-vendor environment?
A1. RMA (Return Merchandise Authorization) device onboarding automates the process of adding replacement or newly received network devices into the existing network fabric. It ensures correct configuration, connectivity, and compliance with the organization’s baseline settings across multiple vendors.


Q2. Why use pyATS for automated RMA onboarding?
A2. pyATS allows network engineers to standardize onboarding workflows, reducing manual errors, ensuring consistency, and speeding up device activation. Its vendor-agnostic capabilities make it ideal for Cisco, Arista, Juniper, and other devices.


Q3. How is a device validated before being onboarded?
A3. Pre-onboarding validation includes verifying device model, firmware version, serial number, and initial connectivity. pyATS scripts can check for OS compatibility and ensure that the device meets baseline prerequisites.


Q4. How are configurations applied during automated onboarding?
A4. pyATS can integrate with configuration templates or Ansible playbooks. Once validated, the device receives baseline configurations, VLAN assignments, interface setups, and management IPs automatically.


Q5. Can this workflow handle multiple devices simultaneously?
A5. Yes. By using testbeds and parallel job execution, pyATS can onboard multiple RMA devices concurrently, tracking each device via unique job IDs and structured output directories.


Q6. How is compliance ensured post-onboarding?
A6. Post-onboarding validation scripts check running configurations, firmware versions, interface status, and connectivity tests to ensure the new device matches the organization’s golden image and operational standards.


Q7. Is this approach limited to CLI-only automation?
A7. No. You can combine CLI validation with GUI/API checks for devices that support web-based management. This ensures complete end-to-end onboarding verification across multiple access methods.


YouTube Link

Watch the Complete Python for Network Engineer: Automated RMA Device Onboarding (Multi-Vendor) 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

You’ve successfully created a production-ready automated RMA device onboarding framework using pyATS. This ensures fast, consistent, and error-free device integration across your multi-vendor network fabric.

Enhance your skillset as a Python for Network Engineer by joining Trainer Sagar Dhawan’s 3-Month Instructor-Led Training Program. Learn hands-on automation using

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