mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 04:20:45 +08:00
Extend port discovery/sampling beyond ZTE, harden IOSv session prep, and avoid send_command_timing so Building configuration does not truncate config sync. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""Vendor → port traffic CLI command matrix (ZTE / Huawei / Cisco)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from .config_sync_commands import normalize_vendor_key
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PortTrafficCommands:
|
|
brief: str
|
|
detail_template: str # format with ifname=
|
|
vendor_key: str = "other"
|
|
|
|
|
|
def commands_for_vendor(vendor: str, device_type: str = "") -> PortTrafficCommands | None:
|
|
key = normalize_vendor_key(vendor, device_type)
|
|
if key == "zte":
|
|
return PortTrafficCommands(
|
|
brief="show interface brief",
|
|
detail_template="show interface {ifname}",
|
|
vendor_key=key,
|
|
)
|
|
if key == "huawei":
|
|
return PortTrafficCommands(
|
|
brief="display interface brief",
|
|
detail_template="display interface {ifname}",
|
|
vendor_key=key,
|
|
)
|
|
if key == "cisco":
|
|
return PortTrafficCommands(
|
|
brief="show ip interface brief",
|
|
detail_template="show interfaces {ifname}",
|
|
vendor_key=key,
|
|
)
|
|
return None
|
|
|
|
|
|
def detail_command(cmds: PortTrafficCommands, ifname: str) -> str:
|
|
return cmds.detail_template.format(ifname=ifname)
|