Abstract device-type base classes for NAPALM drivers
Project description
napalm-device-types
Abstract intermediate device-type base classes for NAPALM drivers.
Instead of inheriting directly from napalm.base.NetworkDriver, a driver can inherit from one of the device-type classes here to gain a richer, type-specific contract:
# without napalm-device-types
class OpenWrtDriver(NetworkDriver):
...
# with napalm-device-types
from napalm_device_types import AccessPointDriver
class OpenWrtDriver(AccessPointDriver):
...
Why?
NAPALM's NetworkDriver defines a common interface for all network devices. In practice, devices fall into distinct categories with very different capabilities. A switch exposes spanning-tree and PoE data; a firewall exposes NAT tables and VPN tunnels; a NAS exposes disk pools and shares. Writing these methods directly in a concrete driver mixes concerns and makes drivers harder to discover and compare.
napalm-device-types sits in between: it adds one well-typed layer of abstract methods per device category, so every driver for the same category exposes the same interface.
Installation
pip install napalm-device-types
Requires Python ≥ 3.9 and NAPALM ≥ 4.0.
Available base classes
| Class | Target devices | Example implementations |
|---|---|---|
AccessPointDriver |
Wireless access points | OpenWrt, Ubiquiti UniFi, Cisco Meraki AP |
SwitchDriver |
Ethernet switches | Cisco IOS, Arista EOS, Juniper EX |
FirewallDriver |
Firewalls & UTM appliances | pfSense, Fortinet FortiOS, Cisco ASA |
HypervisorDriver |
Hypervisors & virtualisation platforms | Proxmox VE, VMware ESXi, KVM/libvirt |
StorageDriver |
Storage appliances & NAS/SAN | TrueNAS, Synology DSM, QNAP QTS |
Usage
Access Point
from napalm_device_types import AccessPointDriver
class OpenWrtDriver(AccessPointDriver):
def get_wireless_clients(self):
# return List[WirelessClientDict]
...
def get_ssids(self):
# return Dict[str, SSIDDict]
...
Switch
from napalm_device_types import SwitchDriver
class CiscoIOSDriver(SwitchDriver):
def get_spanning_tree(self):
# return Dict[str, SpanningTreeDict]
...
def get_poe_status(self):
# return PoESummaryDict
...
Firewall
from napalm_device_types import FirewallDriver
class PfSenseDriver(FirewallDriver):
def get_nat_translations(self):
# return List[NATTranslationDict]
...
def get_vpn_tunnels(self):
# return Dict[str, VPNTunnelDict]
...
Hypervisor
from napalm_device_types import HypervisorDriver
class ProxmoxDriver(HypervisorDriver):
def get_vms(self):
# return List[VMDict]
...
def snapshot_create(self, name, snapshot, description="", include_memory=False):
...
Storage / NAS
from napalm_device_types import StorageDriver
class TrueNASDriver(StorageDriver):
def get_disks(self):
# return List[PhysicalDiskDict]
...
def get_shares(self):
# return Dict[str, NASShareDict]
...
Return types
All return types are TypedDict classes defined in napalm_device_types.models. Import them directly for type annotations in your driver:
from napalm_device_types.models import (
PhysicalDiskDict,
DiskPoolDict,
NASShareDict,
VolumeSnapshotDict,
)
Development
git clone https://github.com/chrismanivong/napalm-device-types.git
cd napalm-device-types
pip install -e ".[dev]"
Run type-checking:
mypy napalm_device_types
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/router-driver) - Implement your changes
- Open a Pull Request
License
Apache-2.0 – see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file napalm_device_types-0.1.0.tar.gz.
File metadata
- Download URL: napalm_device_types-0.1.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcf7a691032bf4e87aa9750d0330c9ffe2160ecd869d7b3244f520ca49495e26
|
|
| MD5 |
6e8b93a111a9ec9486c0444be939b5d8
|
|
| BLAKE2b-256 |
b0b6205fc59b8df5009e74a53f2b4317f8ff3d96537a0b95b76454b50ba7c741
|
File details
Details for the file napalm_device_types-0.1.0-py3-none-any.whl.
File metadata
- Download URL: napalm_device_types-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c6d0a08a8dd741ab4b288a51b98d4acd408761859f081e726416d15ac14cadc
|
|
| MD5 |
990b0161e46dfedc4e6be6d19229dba7
|
|
| BLAKE2b-256 |
61e8b09d5f08f3fef856d9ad553d35688b21dffca3245ef79e543b754cdb7cd0
|