Mantra Networking Mantra Networking

Netmiko: Platform-Specific Classes

Netmiko: Platform-Specific Classes
Created By: Lauren R. Garcia


Table of Contents

  • Overview
  • Platform-Specific Submodules
  •  Supported Platforms and Classes
  • Device Type Strings
  • List of Regularly and Partially Supported Platforms
  • Customization and Extension
  • Reference: Useful Subclasses and Class Naming Convention
  • Conclusion
Platform-Specific Submodules

Netmiko structures its device support using dedicated Python submodules for each major network vendor or device family. These submodules contain custom classes that extend Netmiko's core functionality to account for the unique behaviors of each platform.

  • Cisco Submodules:
    Manages a wide range of Cisco device OS types, such as IOS, IOS-XR, NX-OS, ASA, and SG300. Each is handled with its own class for nuances in prompts, login procedures, and configuration modes.
  • Arista, Juniper, and HP:
    Separate submodules (e.g., netmiko.arista, netmiko.juniper, netmiko.hp_procurve) address command-line, prompt, and session features specific to these vendors.
  • Other Vendor Submodules:
    Support for other platforms—such as Brocade, Dell, Huawei, Linux, Palo Alto, and more—is implemented via similarly named submodules. Each provides classes customized for device shell idiosyncrasies.
  • Extensibility:
    Users can extend or override submodule classes for homegrown platforms or unique requirements by subclassing the relevant Netmiko base classes.

These platform-specific submodules form the backbone of Netmiko’s adaptability, enabling consistent automation across a broad range of network gear.

Supported Platforms and Classes

Netmiko supports a broad range of network device platforms by associating each with a vendor-specific class and device type string. These classes handle login, command execution, prompt detection, and configuration modes. Below is a reference table mapping supported vendors to their corresponding class/module and device type string used in Netmiko sessions.

Vendor / Platform Netmiko Class / Submodule Device Type String
Arista EOS netmiko.arista arista_eos
Cisco IOS / IOS-XE netmiko.cisco.cisco_ios cisco_ios, cisco_xe
Cisco NX-OS netmiko.cisco.cisco_nxos cisco_nxos
Cisco ASA netmiko.cisco.cisco_asa cisco_asa
Cisco IOS-XR netmiko.cisco.cisco_xr cisco_xr
Juniper Junos netmiko.juniper juniper_junos
HP ProCurve netmiko.hp_procurve hp_procurve
Dell OS10 / OS9 / PowerConnect netmiko.dell dell_os10, dell_os9, dell_powerconnect
Huawei netmiko.huawei huawei
Linux netmiko.linux linux
Palo Alto PAN-OS netmiko.paloalto paloalto_panos

Each platform above is mapped to a specific device type string used with ConnectHandler. This abstraction allows your automation scripts to remain clean and consistent regardless of vendor-specific CLI behavior.

Device Type Strings

Netmiko uses device type strings to determine the underlying logic and custom handling required for each platform. These strings serve as keys that map your connection to the appropriate platform-specific class, allowing Netmiko to interact with a diverse set of network devices using a unified interface.

  • Purpose:
    When you create a connection with Netmiko's ConnectHandler, you must specify the device_type. This string signals which set of login procedures, prompt handling, and command execution rules to use for that device.
  • Example Usage:
    from netmiko import ConnectHandler
    
    device = {
        'device_type': 'cisco_ios',
        'host': '192.168.100.2',
        'username': 'admin',
        'password': 'your_password', 
    }
    connection = ConnectHandler(**device)
    
  • Common Device Type Strings:
    • cisco_ios – Cisco IOS/IOS-XE
    • arista_eos – Arista EOS
    • juniper_junos – Juniper JunOS
    • hp_procurve – HP ProCurve
    • dell_os10 – Dell OS10
    • linux – Generic Linux
    • paloalto_panos – Palo Alto PAN-OS
    • brocade_netiron – Brocade NetIron
    • huawei – Huawei
    • vyatta_vyos – Vyatta VyOS

Choosing the correct device type string is essential for reliable connections and proper automation of network tasks with Netmiko.

List of Regularly and Partially Supported Platforms

Netmiko's robust library includes support for a wide variety of network device platforms, which are divided into two general categories: Regularly Supported (actively tested and maintained) and Partially Supported (devices with more limited or experimental validation). This ensures broad compatibility while keeping focus on commonly-used network operating systems.

  • Regularly Supported Platforms:
    • Arista vEOS
    • Cisco IOS
    • Cisco IOS-XE
    • Cisco IOS-XR
    • Cisco NX-OS
    • Cisco SG300
    • Cisco ASA
    • Juniper Junos
    • HP ProCurve
    • HP Comware7
    • Linux
  • Partially Supported & Limited Testing Platforms (Select Examples):
    • 6Wind
    • Adtran OS
    • Adva AOS
    • Alcatel AOS6/AOS8
    • Aruba OS Switch
    • Brocade/Extreme MLX/NetIron
    • Brocade ICX/FastIron
    • Calix B6
    • Cisco AireOS (Wireless LAN Controllers)
    • Cisco S200
    • CloudGenix ION
    • Dell OS9 (Force10)
    • Dell OS10
    • Dell PowerConnect
    • Ericsson IPOS
    • Extreme VDX, VSP, ERS, TierraOS
    • Hillstone StoneOS
    • Huawei, Huawei OLT, Huawei SmartAX
    • IP Infusion OcNOS
    • Juniper ScreenOS
    • MikroTik RouterOS, SwitchOS
    • Nokia/Alcatel SR OS, SR Linux
    • NVIDIA-Mellanox
    • Palo Alto PAN-OS
    • Pluribus
    • Ruckus ICX/FastIron
    • Ruijie Networks
    • TP-Link JetStream
    • Ubiquiti EdgeSwitch
    • Vyatta VyOS
    • Yamaha
    • ZTE ZXROS

With strong support for the most widely deployed network OSs, and functional coverage of a diverse array of others, Netmiko enables network automation across both mainstream and specialized infrastructures.

Customization and Extension

Netmiko is designed with extensibility in mind, allowing users to tailor its behavior for new platforms, unique devices, or advanced automation scenarios. By leveraging Python’s object-oriented features, you can subclass existing Netmiko classes or create your own, customizing how sessions are handled to fit your environment’s needs.

  • Extending Platform Support:
    Create a custom Python class that inherits from BaseConnection or another relevant Netmiko platform class. Override methods related to login, prompt detection, command execution, or configuration mode to account for device-specific behaviors or quirks.
  • Custom Device Type Strings:
    After implementing your subclass, register a new device type string in your Netmiko configuration. This allows you to use ConnectHandler with your custom devices, just like any built-in platform.
  • Example of Custom Class:
    from netmiko.base_connection import BaseConnection
    
    class MyCustomDeviceSSH(BaseConnection):
        def session_preparation(self):
            self._test_channel_read()
            self.set_base_prompt()
            # Add any other device-specific session prep here
    
    # Usage in Netmiko:
    device = {
        "device_type": "my_custom_device",
        "host": "192.168.1.25",
        "username": "admin",
        "password": "secret",
    }
    connection = ConnectHandler(**device)
    
  • Advantages of Customization:
    • Integrate seldom-seen or proprietary platforms into your network automation workflows.
    • Adapt to non-standard prompts, CLI responses, or authentication schemes.
    • Automate platform-specific tasks seamlessly via the familiar Netmiko interface.

By extending Netmiko in this way, you future-proof your automation scripts and open the door to fully unified network management across highly diverse infrastructure.

Reference: Useful Subclasses and Class Naming Convention

Netmiko organizes support for various platforms through specialized Python classes—known as subclasses—tailored to each device family or operating system. These subclasses inherit from a common core, allowing them to override methods to handle prompts, configuration modes, and command execution unique to each platform.

  • Class Naming Pattern:
    Most subclasses follow a naming convention: {Vendor}{Platform}SSH. For example:
    • CiscoIosSSH
    • AristaEosSSH
    • JuniperJunosSSH
    • DellOs10SSH
    Classes are located within the appropriate submodule (such as netmiko.cisco.cisco_ios).
  • Examples of Useful Subclasses:
    • CiscoIosSSH – Handles standard Cisco IOS/IOS-XE sessions
    • CiscoNxosSSH – Cisco Nexus/NX-OS family
    • CiscoAsaSSH – Cisco ASA firewalls
    • AristaEosSSH – Arista EOS switches
    • JuniperJunosSSH – Juniper Junos routers and switches
    • HpProcurveSSH – HP ProCurve switches
    • DellOs10SSH – Dell OS10 switches
    • HuaweiSSH – Huawei enterprise devices
  • Understanding the Structure:
    Each subclass customizes:
    • Login and prompt handling
    • Entering/exiting configuration mode
    • Command execution nuances
    • Error pattern detection
  • When to Reference or Create a Custom Subclass:
    If your device type isn’t directly supported, you can subclass existing Netmiko classes, follow the established naming convention, and override behavior as needed to support new platforms or unique device quirks.

This organized hierarchy and consistent naming pattern make it easy to identify or extend functionality for nearly any network device within Netmiko.

Conclusion

Throughout this blog, we explored the core building blocks that make Netmiko incredibly flexible and extensible for network automation—especially through its platform-specific classes.

🔑 Main Takeaways:

  • Netmiko uses platform-specific submodules and subclasses to handle vendor-specific behavior—such as login sequences, prompt detection, and command execution.
  • The supported platforms and device type strings provide the glue between your Python code and the CLI of routers, switches, firewalls, and more.
  • A wide variety of platforms are supported, both mainstream (like Cisco, Juniper, and Arista) and niche (like Brocade, MikroTik, or Huawei).
  • Customization and extension are straightforward, allowing you to subclass existing logic or create your own handlers for unique infrastructure needs.
  • Clear naming conventions in Netmiko's subclasses make it easy to locate and understand device-specific implementations when exploring or debugging.

Whether you're automating common tasks or building out a scalable config management engine, Netmiko gives you the power to bridge Python with terminal-based network control across a diverse range of hardware.

Thanks for following along!