diff --git a/napalm_ubiquiti/__init__.py b/napalm_ubiquiti/__init__.py new file mode 100644 index 0000000..a2de24d --- /dev/null +++ b/napalm_ubiquiti/__init__.py @@ -0,0 +1 @@ +"""NAPALM drivers for Ubiquiti UniFi.""" diff --git a/napalm_ubiquiti/parsers/__init__.py b/napalm_ubiquiti/parsers/__init__.py new file mode 100644 index 0000000..fb567e0 --- /dev/null +++ b/napalm_ubiquiti/parsers/__init__.py @@ -0,0 +1 @@ +"""Pure functions: UniFi output in, typed dicts out. No I/O.""" diff --git a/napalm_ubiquiti/parsers/device.py b/napalm_ubiquiti/parsers/device.py new file mode 100644 index 0000000..0261a42 --- /dev/null +++ b/napalm_ubiquiti/parsers/device.py @@ -0,0 +1,226 @@ +"""Facts, ports, LLDP, MAC table and PoE from one UniFi device record. + +The record is the same whether a controller reports it (``stat/device``) or the +device prints it itself (``mca-dump``): both are the device's inform payload. A +port is named ``Port `` on either path, so a port keeps its name when the +device moves from one path to the other; the label someone gave it on the +controller becomes its description. +""" + +from __future__ import annotations + +import ipaddress +import re +from typing import Any + +from napalm.base.models import FactsDict, InterfaceDict, InterfacesIPDict, MACAdressTable +from napalm_device_types.lldp import LldpNeighborRow +from napalm_device_types.models import PoEPortDict, PoESummaryDict + +VENDOR = "Ubiquiti" +#: The device's own address and MAC, which no switch port carries. +MANAGEMENT = "Management" +MTU = 1500 +JUMBO_MTU = 9216 +_MAC = re.compile(r"^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$") + +Record = dict[str, Any] + + +def port_name(index: int) -> str: + """The interface name of the switch port with *index* (1-based).""" + return f"Port {index}" + + +def _ports(record: Record) -> list[Record]: + return [p for p in record.get("port_table") or [] if isinstance(p.get("port_idx"), int)] + + +def _number(value: Any) -> float: + try: + return float(value) + except (TypeError, ValueError): + return 0.0 + + +def parse_facts(record: Record) -> FactsDict: + """NAPALM facts. The product name (``model_display``) wins over the model code.""" + hostname = str(record.get("name") or record.get("hostname") or record.get("mac") or "") + ports = [port_name(p["port_idx"]) for p in _ports(record)] + return { + "vendor": VENDOR, + "model": str(record.get("model_display") or record.get("model") or ""), + "hostname": hostname, + "fqdn": hostname, + "os_version": str(record.get("version") or ""), + "serial_number": str(record.get("serial") or "").upper(), + "uptime": _number(record.get("uptime")), + "interface_list": [*ports, MANAGEMENT], + } + + +def _description(port: Record) -> str: + label = str(port.get("name") or "") + return "" if label == port_name(port["port_idx"]) else label + + +def _port_interface(port: Record) -> InterfaceDict: + return { + "is_up": bool(port.get("up")), + "is_enabled": bool(port.get("enable", True)), + "description": _description(port), + "last_flapped": -1.0, + "mtu": JUMBO_MTU if port.get("jumbo") else MTU, + "speed": _number(port.get("speed")), + "mac_address": "", + } + + +def parse_interfaces(record: Record) -> dict[str, InterfaceDict]: + """Every switch port, plus :data:`MANAGEMENT` with the device's own MAC.""" + interfaces = {port_name(p["port_idx"]): _port_interface(p) for p in _ports(record)} + interfaces[MANAGEMENT] = { + "is_up": True, + "is_enabled": True, + "description": "", + "last_flapped": -1.0, + "mtu": MTU, + "speed": 0.0, + "mac_address": str(record.get("mac") or "").lower(), + } + return interfaces + + +def _netmask(record: Record) -> str: + uplink = record.get("uplink") + if isinstance(uplink, dict) and uplink.get("netmask"): + return str(uplink["netmask"]) + return str(record.get("netmask") or "") + + +def _prefix_length(netmask: str) -> int: + try: + length = ipaddress.IPv4Network(f"0.0.0.0/{netmask}").prefixlen + except ValueError: + return 32 + return length or 32 + + +def parse_interfaces_ip(record: Record) -> dict[str, InterfacesIPDict]: + """The management address on :data:`MANAGEMENT`; ``{}`` while the device has none.""" + address = record.get("ip") + if not address: + return {} + prefix = _prefix_length(_netmask(record)) + return {MANAGEMENT: {"ipv4": {str(address): {"prefix_length": prefix}}}} # type: ignore[typeddict-item] + + +def _lldp_row(local_port: str, chassis: str, port_id: str, system_name: str) -> LldpNeighborRow: + is_mac = bool(_MAC.match(chassis)) + return { + "local_port": local_port, + "chassis_id": chassis.lower() if is_mac else chassis, + "chassis_id_type": "mac" if is_mac else ("local" if chassis else ""), + "port_id": port_id, + "port_id_type": "mac" if _MAC.match(port_id) else ("local" if port_id else ""), + "port_description": "", + "system_name": system_name, + "system_description": "", + "management_addresses": [], + "capabilities": [], + "enabled_capabilities": [], + } + + +def _per_port_rows(record: Record) -> list[LldpNeighborRow]: + rows = [] + for port in sorted(_ports(record), key=lambda p: p["port_idx"]): + for entry in port.get("lldp_table") or []: + rows.append( + _lldp_row( + port_name(port["port_idx"]), + str(entry.get("lldp_chassis_id") or ""), + str(entry.get("lldp_port_id") or ""), + str(entry.get("lldp_system_name") or ""), + ) + ) + return rows + + +def _top_level_rows(record: Record) -> list[LldpNeighborRow]: + return [ + _lldp_row( + port_name(int(entry["local_port_idx"])), + str(entry.get("chassis_id") or ""), + str(entry.get("port_id") or ""), + str(entry.get("system_name") or ""), + ) + for entry in record.get("lldp_table") or [] + if isinstance(entry.get("local_port_idx"), int) + ] + + +def parse_lldp_rows(record: Record) -> list[LldpNeighborRow]: + """LLDP neighbours from both shapes firmware uses: per port (older) and at the top. + + A neighbour reported in both counts once; the per-port entry, which carries the + neighbour's system name, wins. + """ + rows: list[LldpNeighborRow] = [] + seen: set[tuple[str, str]] = set() + for row in [*_per_port_rows(record), *_top_level_rows(record)]: + key = (row["local_port"], row["chassis_id"].lower()) + if key not in seen: + seen.add(key) + rows.append(row) + return rows + + +def parse_mac_table(record: Record) -> list[MACAdressTable]: + """What each port has learned. A controller's ``stat/device`` carries no tables.""" + return [ + { + "mac": str(entry.get("mac") or "").lower(), + "interface": port_name(port["port_idx"]), + "vlan": int(entry.get("vlan") or 0), + "static": bool(entry.get("static")), + "active": True, + "moves": 0, + "last_move": -1.0, + } + for port in _ports(record) + for entry in port.get("mac_table") or [] + ] + + +def _poe_status(port: Record) -> str: + if port.get("poe_mode") == "off": + return "disabled" + return "delivering" if port.get("poe_good") else "searching" + + +def _poe_class(port: Record) -> str: + value = str(port.get("poe_class") or "") + return value if value.lower().startswith("class") else "unknown" + + +def _poe_port(port: Record) -> PoEPortDict: + return { + "enabled": port.get("poe_mode") != "off", + "status": _poe_status(port), + "poe_class": _poe_class(port), + "power_draw": _number(port.get("poe_power")), + "power_budget": 0.0, + "voltage": _number(port.get("poe_voltage")), + "current": _number(port.get("poe_current")), + } + + +def parse_poe(record: Record) -> PoESummaryDict: + """PoE per port that can deliver it, and the switch's budget and draw.""" + ports = {port_name(p["port_idx"]): _poe_port(p) for p in _ports(record) if p.get("port_poe")} + return { + "total_power_budget": _number(record.get("total_max_power")), + "total_power_draw": sum(p["power_draw"] for p in ports.values()), + "ports": ports, + } diff --git a/napalm_ubiquiti/py.typed b/napalm_ubiquiti/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0802d42 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,73 @@ +[build-system] +requires = ["setuptools>=77"] +build-backend = "setuptools.build_meta" + +[project] +name = "napalm-ubiquiti" +version = "0.1.0" +description = "NAPALM drivers for Ubiquiti UniFi: switches and access points (through the controller or over SSH) and the UniFi Network controller" +readme = "README.md" +license = "Apache-2.0" +requires-python = ">=3.12" +authors = [{ name = "Christian Manivong", email = "christian@manivong.de" }] +classifiers = [ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", + "Topic :: System :: Networking", +] +dependencies = [ + "napalm>=5.1", # older releases import pkg_resources, which a 3.12 venv lacks + "napalm-device-types>=4.60", # NetworkControllerDriver, VlanDetailDict + "paramiko>=5.0.0", # CVE-2026-44405 + "requests>=2.31.0", +] + +[project.optional-dependencies] +dev = ["pytest>=8", "pytest-cov>=5", "mypy>=1.11", "ruff>=0.6", "types-requests", "types-paramiko"] + +[project.urls] +Repository = "https://git.netork.io/NAPALM/napalm-ubiquiti" +Issues = "https://git.netork.io/NAPALM/napalm-ubiquiti/issues" + +[project.entry-points."napalm.drivers"] +unifi_switch = "napalm_ubiquiti:UnifiSwitchDriver" +unifi_ap = "napalm_ubiquiti:UnifiAccessPointDriver" +unifi_network = "napalm_ubiquiti:UnifiNetworkDriver" + +[tool.setuptools.packages.find] +include = ["napalm_ubiquiti*"] + +[tool.setuptools.package-data] +napalm_ubiquiti = ["py.typed"] + +[tool.ruff] +line-length = 100 +target-version = "py312" + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B"] + +[tool.ruff.lint.per-file-ignores] +# Recorded device output keeps its lines. +"tests/**" = ["E501"] + +[tool.mypy] +python_version = "3.12" +strict = true +# napalm itself is untyped, so every driver subclasses Any. +disallow_subclassing_any = false + +[[tool.mypy.overrides]] +module = ["napalm.*"] +ignore_missing_imports = true + +[tool.pytest.ini_options] +testpaths = ["tests"] +pythonpath = ["."] + +[tool.coverage.run] +source = ["napalm_ubiquiti"] + +[tool.coverage.report] +fail_under = 90 +exclude_also = ["pragma: no cover - live I/O"] diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..8c3cf6d --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,52 @@ +"""Shared fixtures: recorded UniFi output, anonymised (see tests/fixtures/README.md).""" + +from __future__ import annotations + +import json +import pathlib +from typing import Any + +import pytest + +FIXTURES = pathlib.Path(__file__).parent / "fixtures" + + +def load(name: str) -> Any: + """A fixture file: JSON parsed, anything else as text.""" + path = FIXTURES / name + text = path.read_text() + return json.loads(text) if path.suffix == ".json" else text + + +@pytest.fixture +def us16() -> dict[str, Any]: + """A US-16-150W on 4.0.66, as the controller's ``stat/device`` reports it (old LLDP shape).""" + return load("controller/us16p150-4.0.66-stat-device.json") # type: ignore[no-any-return] + + +@pytest.fixture +def us8() -> dict[str, Any]: + return load("controller/us8-4.0.66-stat-device.json") # type: ignore[no-any-return] + + +@pytest.fixture +def usmini() -> dict[str, Any]: + """A USW Flex Mini on 1.8.4: the top-level LLDP shape.""" + return load("controller/usmini-1.8.4-stat-device.json") # type: ignore[no-any-return] + + +@pytest.fixture +def uap() -> dict[str, Any]: + """A UAP-AC-Pro (U7PG2) on 4.0.69, as the controller reports it.""" + return load("controller/u7pg2-4.0.69-stat-device.json") # type: ignore[no-any-return] + + +@pytest.fixture +def us24_dump() -> dict[str, Any]: + """A US-24 (Gen1) on 7.1.26: ``mca-dump`` over SSH, no controller in between.""" + return load("ssh/us24-7.1.26-mca-dump.json") # type: ignore[no-any-return] + + +@pytest.fixture +def us24_cfg() -> str: + return load("ssh/us24-7.1.26-running.cfg") # type: ignore[no-any-return] diff --git a/tests/fixtures/controller/login-unifios.json b/tests/fixtures/controller/login-unifios.json new file mode 100644 index 0000000..adc273e --- /dev/null +++ b/tests/fixtures/controller/login-unifios.json @@ -0,0 +1,134 @@ +{ + "avatar": "", + "avatar_relative_path": "", + "cloud_access_granted": false, + "create_time": 1585163886, + "email": "", + "email_status": "UNVERIFIED", + "extras": null, + "first_name": "Testing", + "full_name": "Testing Testing", + "groups": [], + "id": "868d288b-a642-4209-a768-8425498fa928", + "isOwner": false, + "isSuperAdmin": true, + "last_name": "Testing", + "local_account_exist": true, + "nfc_display_id": "", + "nfc_token": "", + "password_revision": 1585163886, + "permissions": { + "access.management": [ + "admin" + ], + "led.management": [ + "admin" + ], + "network.management": [ + "admin" + ], + "protect.management": [ + "admin" + ], + "system.management.location": [ + "admin" + ], + "system.management.user": [ + "admin" + ], + "talk.management": [ + "admin" + ] + }, + "phone": "", + "roles": [ + { + "level": 2, + "name": "Super Administrator", + "system_key": "super_administrator", + "system_role": true, + "unique_id": "ddf31242-c4f1-4dbc-b362-d0b220cae124" + } + ], + "scopes": [ + "view:user_timezone", + "view:user", + "view:systemlog", + "view:settings", + "view:role", + "view:permission:viewer", + "view:permission:admin", + "view:notification", + "view:location_policy", + "view:location_device", + "view:location_activity", + "view:location", + "view:holiday_timezone", + "view:holiday", + "view:group", + "view:door_group", + "view:controller:talk", + "view:controller:protect", + "view:controller:network", + "view:controller:led", + "view:controller:access", + "view:cloud_access", + "view:app:users", + "view:app:settings", + "view:app:locations", + "view:access.visitor", + "view:access.systemlog", + "view:access.schedule", + "view:access.policy", + "view:access.nfc_card", + "view:access.device", + "view:access.dashboard", + "update:access.device", + "systemlog:user", + "systemlog:system", + "systemlog:location", + "systemlog:access", + "notify:user", + "notify:location", + "notify:access", + "manage:controller:talk", + "manage:controller:protect", + "manage:controller:network", + "manage:controller:led", + "manage:controller:access", + "edit:user_timezone", + "edit:user", + "edit:systemlog", + "edit:settings", + "edit:role", + "edit:permission:viewer", + "edit:permission:admin", + "edit:notification", + "edit:location_policy", + "edit:location_device", + "edit:location_activity", + "edit:location", + "edit:holiday_timezone", + "edit:holiday", + "edit:group", + "edit:feedback", + "edit:door_group", + "edit:access.visitor", + "edit:access.schedule", + "edit:access.policy", + "edit:access.nfc_card", + "edit:access.device", + "delete:access.device", + "assign:role", + "adopt:access.device" + ], + "sso_account": "", + "sso_username": "", + "sso_uuid": "", + "status": "ACTIVE", + "uid_sso_account": "", + "uid_sso_id": "", + "unique_id": "868d288b-a642-4209-a768-8425498fa928", + "update_time": 1585167486, + "username": "Testing1" +} diff --git a/tests/fixtures/controller/networkconf.json b/tests/fixtures/controller/networkconf.json new file mode 100644 index 0000000..39c51d7 --- /dev/null +++ b/tests/fixtures/controller/networkconf.json @@ -0,0 +1,52 @@ +[ + { + "_id": "678a1b2c3d4e5f6071829304", + "attr_hidden_id": "WAN", + "attr_no_delete": true, + "enabled": true, + "name": "Primary (WAN1)", + "purpose": "wan", + "site_id": "5a32aa4ee4b0412345678910", + "wan_dns_preference": "auto", + "wan_failover_priority": 1, + "wan_load_balance_type": "weighted", + "wan_load_balance_weight": 80, + "wan_networkgroup": "WAN", + "wan_type": "dhcp" + }, + { + "_id": "678a1b2c3d4e5f6071829305", + "attr_hidden_id": "WAN2", + "attr_no_delete": true, + "enabled": true, + "name": "Secondary (WAN2)", + "purpose": "wan", + "site_id": "5a32aa4ee4b0412345678910", + "wan_dns_preference": "auto", + "wan_failover_priority": 2, + "wan_load_balance_type": "weighted", + "wan_load_balance_weight": 20, + "wan_networkgroup": "WAN2", + "wan_type": "dhcp" + }, + { + "_id": "678a1b2c3d4e5f6071829306", + "enabled": true, + "name": "Backup (5G)", + "purpose": "wan", + "site_id": "5a32aa4ee4b0412345678910", + "wan_failover_priority": 3, + "wan_load_balance_type": "failover-only", + "wan_networkgroup": "WAN3" + }, + { + "_id": "678a1b2c3d4e5f6071829307", + "enabled": true, + "internet_access_enabled": true, + "ip_subnet": "192.168.1.1/24", + "name": "Default", + "purpose": "corporate", + "site_id": "5a32aa4ee4b0412345678910", + "vlan_enabled": false + } +] diff --git a/tests/fixtures/controller/self-sites.json b/tests/fixtures/controller/self-sites.json new file mode 100644 index 0000000..e2890bc --- /dev/null +++ b/tests/fixtures/controller/self-sites.json @@ -0,0 +1,15 @@ +{ + "data": [ + { + "_id": "5e231c10931eb902acf25112", + "attr_hidden_id": "default", + "attr_no_delete": true, + "desc": "Default", + "name": "default", + "role": "admin" + } + ], + "meta": { + "rc": "ok" + } +} diff --git a/tests/fixtures/controller/u7pg2-4.0.69-stat-device.json b/tests/fixtures/controller/u7pg2-4.0.69-stat-device.json new file mode 100644 index 0000000..be24d45 --- /dev/null +++ b/tests/fixtures/controller/u7pg2-4.0.69-stat-device.json @@ -0,0 +1,742 @@ +{ + "_id": "5a4c022", + "_uptime": 3971849, + "adoptable_when_upgraded": false, + "adopted": true, + "antenna_table": [ + { + "default": true, + "id": 4, + "name": "Combined", + "wifi0_gain": 3, + "wifi1_gain": 3 + } + ], + "architecture": "mips", + "board_rev": 21, + "bytes": 202573081705, + "bytes-d": 4275308, + "bytes-r": 178137, + "cfgversion": "97f3011a27fcfd5b", + "config_network": { + "ip": "192.168.1.7", + "type": "dhcp" + }, + "connect_request_ip": "192.168.0.11", + "connect_request_port": "48591", + "considered_lost_at": 1588175837, + "country_code": 0, + "countrycode_table": [], + "device_id": "235678987654345678", + "downlink_table": [], + "element_peer_mac": "", + "ethernet_table": [ + { + "mac": "80:2a:a8:00:01:02", + "name": "eth0", + "num_port": 2 + } + ], + "fw_caps": 25099583, + "gateway_mac": "192.168.0.1", + "guest-num_sta": 0, + "guest-wlan-num_sta": 0, + "guest_token": "REDACTED", + "has_eth1": false, + "has_fan": false, + "has_speaker": false, + "has_temperature": false, + "hash_id": "REDACTED", + "hide_ch_width": "none", + "hw_caps": 0, + "inform_ip": "192.168.0.5", + "inform_url": "http://192.168.0.6:8080/inform", + "ip": "192.168.0.4", + "isolated": false, + "kernel_version": "4.4.153", + "known_cfgversion": "23434545676787654", + "last_seen": 1588175726, + "last_uplink": { + "uplink_mac": "f0:9f:11:22:33:44", + "uplink_remote_port": 6 + }, + "led_override": "on", + "license_state": "registered", + "locating": false, + "mac": "80:2a:a8:00:01:02", + "manufacturer_id": 4, + "meshv3_peer_mac": "", + "model": "U7PG2", + "name": "ACCESS POINT AC PRO", + "next_heartbeat_at": 1588175763, + "next_interval": 27, + "num_sta": 12, + "outdoor_mode_override": "default", + "port_table": [ + { + "aggregated_by": false, + "attr_no_edit": true, + "autoneg": true, + "bytes-r": 177399, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 1, + "mac": "10:00:00:00:00:01", + "static": false, + "uptime": 3971792, + "vlan": 1 + } + ], + "masked": false, + "media": "GE", + "name": "Main", + "op_mode": "switch", + "poe_caps": 0, + "port_delta": { + "rx_bytes": 4136705, + "rx_packets": 2930, + "time_delta": 24, + "time_delta_activity": 24, + "tx_bytes": 120873, + "tx_packets": 824 + }, + "port_idx": 1, + "port_poe": false, + "portconf_id": "5a32aa4", + "rx_broadcast": 2323942, + "rx_bytes": 2275836363755, + "rx_bytes-r": 172362, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 5051177, + "rx_packets": 1574257888, + "speed": 1000, + "stp_pathcost": 0, + "stp_state": "forwarding", + "tx_broadcast": 218413, + "tx_bytes": 53516753422, + "tx_bytes-r": 5036, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 2935588, + "tx_packets": 333052121, + "up": true + }, + { + "aggregated_by": false, + "autoneg": false, + "bytes-r": 0, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "masked": false, + "media": "GE", + "name": "Secondary", + "op_mode": "switch", + "poe_caps": 0, + "port_delta": { + "time_delta": 24, + "time_delta_activity": 1588175726 + }, + "port_idx": 2, + "port_poe": false, + "portconf_id": "5a32aa4", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "speed": 0, + "stp_pathcost": 0, + "stp_state": "forwarding", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + } + ], + "radio_table": [ + { + "antenna_gain": 6, + "builtin_ant_gain": 3, + "builtin_antenna": true, + "channel": 1, + "current_antenna_gain": 0, + "ht": "20", + "max_txpower": 22, + "min_rssi_enabled": false, + "min_txpower": 6, + "name": "wifi0", + "nss": 3, + "radio": "ng", + "radio_caps": 16420, + "sens_level_enabled": false, + "tx_power_mode": "low", + "wlangroup_id": "5a32aa4ee4" + }, + { + "antenna_gain": 6, + "builtin_ant_gain": 3, + "builtin_antenna": true, + "channel": "auto", + "current_antenna_gain": 0, + "hard_noise_floor_enabled": false, + "has_dfs": true, + "has_fccdfs": true, + "ht": "40", + "is_11ac": true, + "max_txpower": 22, + "min_rssi_enabled": false, + "min_txpower": 6, + "name": "wifi1", + "nss": 3, + "radio": "na", + "radio_caps": 50479140, + "sens_level_enabled": false, + "tx_power_mode": "high", + "wlangroup_id": "5a32aa4ee4" + } + ], + "radio_table_stats": [ + { + "ast_be_xmit": 239, + "ast_cst": null, + "ast_txto": null, + "channel": 1, + "cu_self_rx": 20, + "cu_self_tx": 0, + "cu_total": 21, + "extchannel": 0, + "gain": 3, + "guest-num_sta": 0, + "name": "wifi0", + "num_sta": 3, + "radio": "ng", + "satisfaction": 99, + "state": "RUN", + "tx_packets": 30, + "tx_power": 6, + "tx_retries": 16, + "user-num_sta": 3 + }, + { + "ast_be_xmit": 239, + "ast_cst": null, + "ast_txto": null, + "channel": 44, + "cu_self_rx": 1, + "cu_self_tx": 1, + "cu_total": 2, + "extchannel": 1, + "gain": 3, + "guest-num_sta": 0, + "name": "wifi1", + "num_sta": 9, + "radio": "na", + "satisfaction": 97, + "state": "RUN", + "tx_packets": 2902, + "tx_power": 17, + "tx_retries": 121, + "user-num_sta": 9 + } + ], + "required_version": "3.4.1", + "rx_bytes": 4049050176, + "rx_bytes-d": 126600, + "satisfaction": 97, + "scan_radio_table": [], + "scanning": false, + "serial": "802AA8000102", + "site_id": "5a32aa4ee4b0412345678910", + "spectrum_scanning": false, + "ssh_session_table": [], + "start_connected_millis": 1587859252498, + "start_disconnected_millis": 1587859249141, + "stat": { + "ap": { + "ap": "80:2a:a8:00:01:02", + "bytes": 202573081705.0, + "datetime": "2020-04-26T00:00:00Z", + "duration": 316470000.0, + "guest-mac_filter_rejections": 0.0, + "guest-rx_bytes": 0.0, + "guest-rx_crypts": 0.0, + "guest-rx_dropped": 0.0, + "guest-rx_errors": 0.0, + "guest-rx_frags": 0.0, + "guest-rx_packets": 0.0, + "guest-tx_bytes": 0.0, + "guest-tx_dropped": 0.0, + "guest-tx_errors": 0.0, + "guest-tx_packets": 0.0, + "guest-tx_retries": 0.0, + "guest-wifi_tx_attempts": 0.0, + "guest-wifi_tx_dropped": 0.0, + "mac_filter_rejections": 0.0, + "o": "ap", + "oid": "80:2a:a8:00:01:02", + "port_1-rx_broadcast": 172074.0, + "port_1-rx_bytes": 216612809001.0, + "port_1-rx_multicast": 403649.0, + "port_1-rx_packets": 148071452.0, + "port_1-tx_broadcast": 19948.0, + "port_1-tx_bytes": 3988805922.0, + "port_1-tx_multicast": 258376.0, + "port_1-tx_packets": 26448260.0, + "rx_bytes": 4049050176.0, + "rx_crypts": 20074.0, + "rx_dropped": 41540.0, + "rx_errors": 20385.0, + "rx_frags": 0.0, + "rx_packets": 27062516.0, + "site_id": "5a32aa4ee4b0412345678910", + "time": 1587859200000, + "tx_bytes": 198524031529.0, + "tx_dropped": 0.0, + "tx_errors": 233910.0, + "tx_packets": 148794592.0, + "tx_retries": 5259147.0, + "user-mac_filter_rejections": 0.0, + "user-rx_bytes": 4049050176.0, + "user-rx_crypts": 20074.0, + "user-rx_dropped": 41540.0, + "user-rx_errors": 20385.0, + "user-rx_frags": 0.0, + "user-rx_packets": 27062516.0, + "user-tx_bytes": 198524031529.0, + "user-tx_dropped": 0.0, + "user-tx_errors": 233910.0, + "user-tx_packets": 148794592.0, + "user-tx_retries": 5259147.0, + "user-wifi0-ath0-3453453453453-rx_bytes": 543942635.0, + "user-wifi0-ath0-3453453453453-rx_crypts": 8532.0, + "user-wifi0-ath0-3453453453453-rx_dropped": 17899.0, + "user-wifi0-ath0-3453453453453-rx_errors": 8843.0, + "user-wifi0-ath0-3453453453453-rx_packets": 1286990.0, + "user-wifi0-ath0-3453453453453-tx_bytes": 1631875402.0, + "user-wifi0-ath0-3453453453453-tx_packets": 2143440.0, + "user-wifi0-ath0-3453453453453-tx_retries": 815193.0, + "user-wifi0-ath0-3453453453453-wifi_tx_attempts": 2251168.0, + "user-wifi0-ath0-3453453453453-wifi_tx_dropped": 5689.0, + "user-wifi0-mac_filter_rejections": 0.0, + "user-wifi0-rx_bytes": 543942635.0, + "user-wifi0-rx_crypts": 8532.0, + "user-wifi0-rx_dropped": 17899.0, + "user-wifi0-rx_errors": 8843.0, + "user-wifi0-rx_frags": 0.0, + "user-wifi0-rx_packets": 1286990.0, + "user-wifi0-tx_bytes": 1631875402.0, + "user-wifi0-tx_dropped": 0.0, + "user-wifi0-tx_errors": 0.0, + "user-wifi0-tx_packets": 2143440.0, + "user-wifi0-tx_retries": 815193.0, + "user-wifi0-wifi_tx_attempts": 2251168.0, + "user-wifi0-wifi_tx_dropped": 5689.0, + "user-wifi1-ath1-3453453453453-rx_bytes": 3505107541.0, + "user-wifi1-ath1-3453453453453-rx_crypts": 11542.0, + "user-wifi1-ath1-3453453453453-rx_dropped": 23641.0, + "user-wifi1-ath1-3453453453453-rx_errors": 11542.0, + "user-wifi1-ath1-3453453453453-rx_packets": 25775526.0, + "user-wifi1-ath1-3453453453453-tx_bytes": 196892156127.0, + "user-wifi1-ath1-3453453453453-tx_errors": 233910.0, + "user-wifi1-ath1-3453453453453-tx_packets": 146651152.0, + "user-wifi1-ath1-3453453453453-tx_retries": 4443954.0, + "user-wifi1-ath1-3453453453453-wifi_tx_attempts": 79575052.0, + "user-wifi1-ath1-3453453453453-wifi_tx_dropped": 512.0, + "user-wifi1-mac_filter_rejections": 0.0, + "user-wifi1-rx_bytes": 3505107541.0, + "user-wifi1-rx_crypts": 11542.0, + "user-wifi1-rx_dropped": 23641.0, + "user-wifi1-rx_errors": 11542.0, + "user-wifi1-rx_frags": 0.0, + "user-wifi1-rx_packets": 25775526.0, + "user-wifi1-tx_bytes": 196892156127.0, + "user-wifi1-tx_dropped": 0.0, + "user-wifi1-tx_errors": 233910.0, + "user-wifi1-tx_packets": 146651152.0, + "user-wifi1-tx_retries": 4443954.0, + "user-wifi1-wifi_tx_attempts": 79575052.0, + "user-wifi1-wifi_tx_dropped": 512.0, + "user-wifi_tx_attempts": 81826220.0, + "user-wifi_tx_dropped": 6201.0, + "wifi0-mac_filter_rejections": 0.0, + "wifi0-rx_bytes": 543942635.0, + "wifi0-rx_crypts": 8532.0, + "wifi0-rx_dropped": 17899.0, + "wifi0-rx_errors": 8843.0, + "wifi0-rx_frags": 0.0, + "wifi0-rx_packets": 1286990.0, + "wifi0-tx_bytes": 1631875402.0, + "wifi0-tx_dropped": 0.0, + "wifi0-tx_errors": 0.0, + "wifi0-tx_packets": 2143440.0, + "wifi0-tx_retries": 815193.0, + "wifi0-wifi_tx_attempts": 2251168.0, + "wifi0-wifi_tx_dropped": 5689.0, + "wifi1-mac_filter_rejections": 0.0, + "wifi1-rx_bytes": 3505107541.0, + "wifi1-rx_crypts": 11542.0, + "wifi1-rx_dropped": 23641.0, + "wifi1-rx_errors": 11542.0, + "wifi1-rx_frags": 0.0, + "wifi1-rx_packets": 25775526.0, + "wifi1-tx_bytes": 196892156127.0, + "wifi1-tx_dropped": 0.0, + "wifi1-tx_errors": 233910.0, + "wifi1-tx_packets": 146651152.0, + "wifi1-tx_retries": 4443954.0, + "wifi1-wifi_tx_attempts": 79575052.0, + "wifi1-wifi_tx_dropped": 512.0, + "wifi_tx_attempts": 81826220.0, + "wifi_tx_dropped": 6201.0 + } + }, + "state": 1, + "switch_caps": { + "feature_caps": 32, + "max_aggregate_sessions": 0, + "max_mirror_sessions": 0 + }, + "sys_error_caps": 0, + "sys_stats": { + "loadavg_1": "0.15", + "loadavg_15": "0.02", + "loadavg_5": "0.08", + "mem_buffer": 0, + "mem_total": 128622592, + "mem_used": 63606784 + }, + "syslog_key": "REDACTED", + "system-stats": { + "cpu": "3.1", + "mem": "27.4", + "uptime": "3971849" + }, + "two_phase_adopt": false, + "tx_bytes": 198524031529, + "tx_bytes-d": 4148708, + "type": "uap", + "unsupported": false, + "unsupported_reason": 0, + "upgradable": true, + "upgrade_state": 0, + "upgrade_to_firmware": "4.0.80.10875", + "uplink": { + "full_duplex": true, + "ip": "0.0.0.0", + "mac": "80:2a:a8:00:01:02", + "max_speed": 1000, + "max_vlan": 96, + "name": "eth0", + "netmask": "0.0.0.0", + "num_port": 2, + "rx_bytes": 1755202154, + "rx_bytes-r": 171857, + "rx_dropped": 131000, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 1574229881, + "speed": 1000, + "tx_bytes": 537697796, + "tx_bytes-r": 4916, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 333052303, + "type": "wire", + "up": true, + "uplink_mac": "f0:9f:11:22:33:44", + "uplink_remote_port": 6 + }, + "uplink_table": [], + "uptime": 3971849, + "user-num_sta": 12, + "user-wlan-num_sta": 12, + "vap_table": [ + { + "anomalies_bar_chart": { + "high_dns_latency": 0, + "high_tcp_latency": 0, + "high_tcp_packet_loss": 0, + "high_wifi_latency": 0, + "high_wifi_retries": 0, + "low_phy_rate": 0, + "poor_stream_eff": 0, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "weak_signal": 0 + }, + "anomalies_bar_chart_now": { + "high_dns_latency": 0, + "high_tcp_latency": 0, + "high_tcp_packet_loss": 0, + "high_wifi_latency": 0, + "high_wifi_retries": 0, + "low_phy_rate": 0, + "poor_stream_eff": 0, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "weak_signal": 0 + }, + "ap_mac": "80:2a:a8:00:01:02", + "avg_client_signal": -75, + "bssid": "80:2a:11:22:33:44", + "ccq": 340, + "channel": 44, + "dns_avg_latency": 6, + "essid": "PhG", + "extchannel": 1, + "id": "3453453453453", + "is_guest": false, + "is_wep": false, + "mac_filter_rejections": 0, + "map_id": null, + "name": "ath1", + "num_satisfaction_sta": 9, + "num_sta": 9, + "radio": "na", + "radio_name": "wifi1", + "reasons_bar_chart": { + "phy_rate": 0, + "signal": 3, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_latency": 0, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "stream_eff": 0, + "tcp_latency": 2, + "tcp_packet_loss": 0, + "wifi_latency": 2, + "wifi_retries": 2 + }, + "reasons_bar_chart_now": { + "phy_rate": 0, + "signal": 2, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_latency": 2, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "stream_eff": 0, + "tcp_latency": 1, + "tcp_packet_loss": 0, + "wifi_latency": 1, + "wifi_retries": 1 + }, + "rx_bytes": 2772787976, + "rx_crypts": 193706, + "rx_dropped": 377847, + "rx_errors": 193706, + "rx_frags": 0, + "rx_nwids": 244037, + "rx_packets": 253573604, + "rx_tcp_stats": { + "goodbytes": 16307156809, + "lat_avg": 26, + "lat_max": 180, + "lat_min": 10, + "stalls": 0 + }, + "satisfaction": 97, + "site_id": "5a32aa4ee4b0412345678910", + "state": "RUN", + "t": "vap", + "tx_bytes": 2122358914, + "tx_combined_retries": 3708330, + "tx_data_mpdu_bytes": 181801507822, + "tx_dropped": 0, + "tx_errors": 1710454, + "tx_packets": 1282805591, + "tx_power": 17, + "tx_retries": 3708330, + "tx_rts_retries": 0, + "tx_success": 64435416, + "tx_tcp_stats": { + "goodbytes": 298206899, + "lat_avg": 21, + "lat_max": 110, + "lat_min": 10, + "stalls": 0 + }, + "tx_total": 64435427, + "up": true, + "usage": "user", + "wifi_tx_attempts": 68143757, + "wifi_tx_dropped": 11, + "wifi_tx_latency_mov": { + "avg": 968, + "max": 3985, + "min": 97, + "total": 888421, + "total_count": 917 + }, + "wlanconf_id": "3453453453453" + }, + { + "anomalies_bar_chart": { + "high_dns_latency": 0, + "high_tcp_latency": 0, + "high_tcp_packet_loss": 0, + "high_wifi_latency": 0, + "high_wifi_retries": 0, + "low_phy_rate": 0, + "poor_stream_eff": 0, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "weak_signal": 0 + }, + "anomalies_bar_chart_now": { + "high_dns_latency": 0, + "high_tcp_latency": 0, + "high_tcp_packet_loss": 0, + "high_wifi_latency": 0, + "high_wifi_retries": 0, + "low_phy_rate": 0, + "poor_stream_eff": 0, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "weak_signal": 0 + }, + "ap_mac": "80:2a:a8:00:01:02", + "avg_client_signal": -70, + "bssid": "80:2a:22:33:44:55:66", + "ccq": 633, + "channel": 1, + "dns_avg_latency": 5, + "essid": "PhG", + "id": "3453453453453", + "is_guest": false, + "is_wep": false, + "mac_filter_rejections": 0, + "map_id": null, + "name": "ath0", + "num_satisfaction_sta": 3, + "num_sta": 3, + "radio": "ng", + "radio_name": "wifi0", + "reasons_bar_chart": { + "phy_rate": 0, + "signal": 0, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_latency": 1, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "stream_eff": 0, + "tcp_latency": 0, + "tcp_packet_loss": 0, + "wifi_latency": 2, + "wifi_retries": 0 + }, + "reasons_bar_chart_now": { + "phy_rate": 0, + "signal": 0, + "sleepy_client": 0, + "sta_arp_timeout": 0, + "sta_dns_latency": 1, + "sta_dns_timeout": 0, + "sta_ip_timeout": 0, + "stream_eff": 0, + "tcp_latency": 0, + "tcp_packet_loss": 0, + "wifi_latency": 2, + "wifi_retries": 0 + }, + "rx_bytes": 1680489730, + "rx_crypts": 111491, + "rx_dropped": 140008, + "rx_errors": 112587, + "rx_frags": 0, + "rx_nwids": 3448793, + "rx_packets": 23062297, + "rx_tcp_stats": { + "goodbytes": 22571928, + "lat_avg": 3, + "lat_max": 10, + "lat_min": 10, + "stalls": 0 + }, + "satisfaction": 99, + "site_id": "5a32aa4ee4b0412345678910", + "state": "RUN", + "t": "vap", + "tx_bytes": 2405174619, + "tx_combined_retries": 198754, + "tx_data_mpdu_bytes": 65829188, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 59362177, + "tx_power": 6, + "tx_retries": 144922, + "tx_rts_retries": 53832, + "tx_success": 411226, + "tx_tcp_stats": { + "goodbytes": 51240971, + "lat_avg": 3, + "lat_max": 10, + "lat_min": 10, + "stalls": 0 + }, + "tx_total": 411704, + "up": true, + "usage": "user", + "wifi_tx_attempts": 556148, + "wifi_tx_dropped": 478, + "wifi_tx_latency_mov": { + "avg": 516, + "max": 12117, + "min": 0, + "total": 20141, + "total_count": 39 + }, + "wlanconf_id": "3453453453453" + } + ], + "version": "4.0.69.10871", + "vwireEnabled": false, + "vwire_table": [], + "vwire_vap_table": [], + "wifi_caps": 573429, + "wlan_overrides": [ + { + "name": "My5GHzSSID1", + "radio": "na", + "radio_name": "wifi1", + "wlan_id": "012345678910111213141516" + } + ], + "wlangroup_id_na": "5a32aa4ee4123", + "wlangroup_id_ng": "5a32aa4ee4123", + "x_aes_gcm": "REDACTED", + "x_authkey": "REDACTED", + "x_fingerprint": "REDACTED", + "x_has_ssh_hostkey": "REDACTED", + "x_inform_authkey": "REDACTED", + "x_ssh_hostkey_fingerprint": "REDACTED", + "x_vwirekey": "REDACTED" +} diff --git a/tests/fixtures/controller/ugw3-4.4.44-stat-device.json b/tests/fixtures/controller/ugw3-4.4.44-stat-device.json new file mode 100644 index 0000000..c0e1b68 --- /dev/null +++ b/tests/fixtures/controller/ugw3-4.4.44-stat-device.json @@ -0,0 +1,439 @@ +{ + "_id": "5a4c0cc1e4b0f3665471969a", + "_uptime": 3971869, + "adoptable_when_upgraded": false, + "adopted": true, + "board_rev": 16, + "bytes": 1204107284393, + "cfgversion": "464ab1e08b5bd1a2", + "config_network": { + "ip": "192.168.0.1", + "type": "dhcp" + }, + "connect_request_ip": "192.168.0.1", + "connect_request_port": "48714", + "considered_lost_at": 1588175842, + "device_id": "235678987654345678", + "ethernet_overrides": [ + { + "ifname": "eth1", + "networkgroup": "LAN" + }, + { + "ifname": "eth0", + "networkgroup": "WAN" + } + ], + "ethernet_table": [ + { + "mac": "78:8a:20:33:44:55", + "name": "eth0", + "num_port": 1 + }, + { + "mac": "192.168.0.1", + "name": "eth1", + "num_port": 1 + }, + { + "mac": "78:8a:20:33:44:56", + "name": "eth2", + "num_port": 1 + } + ], + "fw_caps": 184323, + "guest-num_sta": 0, + "guest_token": "REDACTED", + "hw_caps": 0, + "inform_ip": "192.168.0.5", + "inform_url": "http://192.168.0.7:8080/inform", + "ip": "1.2.3.4", + "known_cfgversion": "23434545676787654", + "last_seen": 1588175740, + "last_wan_ip": "1.2.3.4", + "last_wan_status": { + "WAN": "online", + "WAN2": "online" + }, + "led_override": "on", + "license_state": "registered", + "locating": false, + "mac": "78:8a:20:33:44:55", + "model": "UGW3", + "name": "USG", + "network_table": [ + { + "_id": "5a32aa4ee4b3456542345678765", + "attr_hidden_id": "LAN", + "attr_no_delete": true, + "dhcp_relay_enabled": false, + "dhcpd_dns_1": "192.168.0.7", + "dhcpd_dns_enabled": false, + "dhcpd_enabled": true, + "dhcpd_gateway_enabled": false, + "dhcpd_leasetime": 86400, + "dhcpd_start": "192.168.0.11", + "dhcpd_stop": "192.168.0.254", + "dhcpd_time_offset_enabled": false, + "dhcpd_unifi_controller": "192.168.0.7", + "domain_name": "localdomain", + "enabled": true, + "ip": "192.168.0.1", + "ip_subnet": "192.168.0.1/24", + "is_guest": false, + "is_nat": true, + "lte_lan_enabled": true, + "mac": "192.168.0.1", + "name": "LAN", + "networkgroup": "LAN", + "num_sta": 16, + "purpose": "corporate", + "rx_bytes": 1103117408747, + "rx_packets": 805953276, + "site_id": "5a32aa4ee4b0412345678910", + "tx_bytes": 96022594996, + "tx_packets": 341451260, + "up": "true", + "vlan_enabled": false + } + ], + "next_heartbeat_at": 1588175774, + "next_interval": 24, + "num_desktop": 4, + "num_handheld": 1, + "num_mobile": 0, + "num_sta": 20, + "outdoor_mode_override": "default", + "port_table": [ + { + "dns": [ + "127.0.0.1" + ], + "enable": true, + "full_duplex": true, + "gateway": "2.3.4.5", + "ifname": "eth0", + "ip": "1.2.3.4", + "mac": "78:8a:20:33:44:55", + "name": "wan", + "netmask": "255.255.254.0", + "rx_bytes": 1107294012155, + "rx_dropped": 3929, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 807555430, + "speed": 1000, + "tx_bytes": 96813272238, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 344559427, + "up": true + }, + { + "enable": true, + "full_duplex": true, + "ifname": "eth1", + "ip": "192.168.0.1", + "mac": "192.168.0.1", + "name": "lan", + "netmask": "255.255.255.0", + "rx_bytes": 98681321728, + "rx_dropped": 1379, + "rx_errors": 0, + "rx_multicast": 247602, + "rx_packets": 349214866, + "speed": 1000, + "tx_bytes": 1105756381870, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 808015520, + "up": true + }, + { + "enable": false, + "full_duplex": false, + "ifname": "eth2", + "ip": "0.0.0.0", + "mac": "78:8a:20:33:44:56", + "name": "lan2", + "netmask": "0.0.0.0", + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "speed": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 0, + "up": false + } + ], + "required_version": "4.0.0", + "rx_bytes": 96813272238, + "serial": "788A20334455", + "site_id": "5a32aa4ee4b0412345678910", + "speedtest-status": { + "latency": 0, + "rundate": 0, + "runtime": 0, + "status_download": 0, + "status_ping": 0, + "status_summary": 0, + "status_upload": 0, + "xput_download": 0.0, + "xput_upload": 0.0 + }, + "speedtest-status-saved": true, + "start_connected_millis": 1587859256101, + "start_disconnected_millis": 1587859249149, + "stat": { + "gw": { + "datetime": "2020-04-26T00:00:00Z", + "duration": 316484000.0, + "gw": "78:8a:20:33:44:55", + "lan-rx_bytes": 5964025490.0, + "lan-rx_dropped": 10.0, + "lan-rx_packets": 24227687.0, + "lan-tx_bytes": 76685302301.0, + "lan-tx_packets": 56428312.0, + "o": "gw", + "oid": "78:8a:20:33:44:55", + "site_id": "5a32aa4ee4b0412345678910", + "time": 1587859200000, + "wan-rx_bytes": 76769209870.0, + "wan-rx_dropped": 231.0, + "wan-rx_packets": 56473855.0, + "wan-tx_bytes": 5836684857.0, + "wan-tx_packets": 23887040.0 + } + }, + "state": 1, + "storage": [ + { + "mount_point": "/persistent", + "name": "Backup", + "size": 2040373248, + "type": "eMMC", + "used": 148353024 + }, + { + "mount_point": "/tmp", + "name": "Temporary", + "size": 1073741824, + "type": "other", + "used": 90112 + } + ], + "sys_stats": { + "loadavg_1": "0.03", + "loadavg_15": "0.08", + "loadavg_5": "0.07", + "mem_buffer": 57561088, + "mem_total": 507412480, + "mem_used": 293453824 + }, + "syslog_key": "REDACTED", + "system-stats": { + "cpu": "0", + "mem": "25", + "uptime": "3971505" + }, + "temperatures": [ + { + "name": "CPU", + "type": "cpu", + "value": 66.0 + }, + { + "name": "Local", + "type": "board", + "value": 48.75 + }, + { + "name": "PHY", + "type": "board", + "value": 50.25 + } + ], + "two_phase_adopt": false, + "tx_bytes": 1107294012155, + "type": "ugw", + "unsupported": false, + "unsupported_reason": 0, + "upgradable": true, + "upgrade_state": 0, + "upgrade_to_firmware": "4.4.50.5272448", + "uplink": { + "bytes-r": 242330, + "drops": 4, + "enable": true, + "full_duplex": true, + "gateways": [ + "2.3.4.5" + ], + "ip": "1.2.3.4", + "latency": 1, + "mac": "78:8a:20:33:44:55", + "max_speed": 1000, + "name": "eth0", + "nameservers": [ + "127.0.0.1" + ], + "netmask": "255.255.254.0", + "num_port": 1, + "rx_bytes": 1107294012155, + "rx_bytes-r": 239494, + "rx_dropped": 3929, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 807555430, + "speed": 1000, + "speedtest_lastrun": 0, + "speedtest_ping": 0, + "speedtest_status": "Idle", + "tx_bytes": 96813272238, + "tx_bytes-r": 2836, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 344559427, + "type": "wire", + "up": true, + "uptime": 855760, + "xput_down": 0.0, + "xput_up": 0.0 + }, + "uptime": 3971869, + "uptime_stats": { + "WAN": { + "monitors": [ + { + "availability": 100.0, + "latency_average": 5, + "target": "www.microsoft.com", + "type": "icmp" + }, + { + "availability": 100.0, + "latency_average": 7, + "target": "google.com", + "type": "icmp" + }, + { + "availability": 100.0, + "latency_average": 5, + "target": "1.1.1.1", + "type": "icmp" + } + ] + }, + "WAN2": { + "monitors": [ + { + "availability": 0.0, + "target": "www.microsoft.com", + "type": "icmp" + }, + { + "availability": 0.0, + "target": "google.com", + "type": "icmp" + }, + { + "availability": 0.0, + "target": "1.1.1.1", + "type": "icmp" + } + ] + }, + "WAN3": { + "monitors": [ + { + "availability": 100.0, + "latency_average": 41, + "target": "www.microsoft.com", + "type": "icmp" + }, + { + "availability": 100.0, + "latency_average": 32, + "target": "google.com", + "type": "icmp" + }, + { + "availability": 100.0, + "latency_average": 16, + "target": "1.1.1.1", + "type": "icmp" + } + ] + } + }, + "user-num_sta": 20, + "usg_caps": 786431, + "version": "4.4.44.5213844", + "wan1": { + "bytes-r": 242330, + "dns": [ + "127.0.0.1" + ], + "enable": true, + "full_duplex": true, + "gateway": "2.3.4.5", + "ifname": "eth0", + "ip": "1.2.3.4", + "mac": "78:8a:20:33:44:55", + "max_speed": 1000, + "name": "wan", + "netmask": "255.255.254.0", + "rx_bytes": 1107294012155, + "rx_bytes-r": 239494, + "rx_dropped": 3929, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 807555430, + "speed": 1000, + "tx_bytes": 96813272238, + "tx_bytes-r": 2836, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 344559427, + "type": "wire", + "up": true + }, + "wan2": { + "bytes-r": 1024, + "dns": [ + "8.8.8.8" + ], + "enable": true, + "full_duplex": true, + "gateway": "10.0.0.1", + "ifname": "eth1", + "ip": "10.0.0.2", + "mac": "78:8a:20:33:44:56", + "max_speed": 1000, + "name": "wan2", + "netmask": "255.255.255.0", + "rx_bytes": 500000000, + "rx_bytes-r": 512, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 1000000, + "speed": 1000, + "tx_bytes": 200000000, + "tx_bytes-r": 512, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 500000, + "type": "wire", + "up": true + }, + "x_aes_gcm": "REDACTED", + "x_authkey": "REDACTED", + "x_has_ssh_hostkey": "REDACTED", + "x_inform_authkey": "REDACTED", + "x_ssh_hostkey_fingerprint": "REDACTED" +} diff --git a/tests/fixtures/controller/us16p150-4.0.66-stat-device.json b/tests/fixtures/controller/us16p150-4.0.66-stat-device.json new file mode 100644 index 0000000..ca4b861 --- /dev/null +++ b/tests/fixtures/controller/us16p150-4.0.66-stat-device.json @@ -0,0 +1,1111 @@ +{ + "_id": "5b8457a9e4b01dd29e9f1578", + "_uptime": 3971865, + "adoptable_when_upgraded": false, + "adopted": true, + "architecture": "armv7l", + "board_rev": 9, + "bytes": 3859971623, + "cfgversion": "6381f86fdd573e1e", + "config_network": { + "ip": "192.168.0.57", + "type": "dhcp" + }, + "connect_request_ip": "192.168.0.57", + "connect_request_port": "58628", + "considered_lost_at": 1588175821, + "device_id": "235678987654345678", + "dhcp_server_table": [], + "dot1x_portctrl_enabled": false, + "downlink_table": [], + "ethernet_table": [ + { + "mac": "fc:ec:da:11:22:33", + "name": "eth0", + "num_port": 18 + }, + { + "mac": "fc:ec:da:11:22:34", + "name": "srv0" + } + ], + "fan_level": 0, + "flowctrl_enabled": false, + "fw_caps": 21683749, + "gateway_mac": "192.168.0.1", + "general_temperature": 56, + "guest-num_sta": 0, + "has_fan": true, + "has_temperature": true, + "hash_id": "REDACTED", + "hw_caps": 0, + "inform_ip": "192.168.0.5", + "inform_url": "http://192.168.0.7:8080/inform", + "internet": true, + "ip": "192.168.0.57", + "jumboframe_enabled": false, + "kernel_version": "3.6.5", + "known_cfgversion": "23434545676787654", + "last_seen": 1588175722, + "last_uplink": { + "uplink_mac": "f0:9f:11:22:33:44" + }, + "led_override": "on", + "license_state": "registered", + "locating": false, + "mac": "fc:ec:da:11:22:33", + "manufacturer_id": 2, + "model": "US16P150", + "name": "Switch 16", + "next_heartbeat_at": 1588175755, + "next_interval": 23, + "num_sta": 4, + "outdoor_mode_override": "default", + "overheating": false, + "port_overrides": [ + { + "autoneg": true, + "poe_mode": "auto", + "port_security_mac_address": [], + "portconf_id": "5e1b309714bd614afd3d11a7", + "stp_port_mode": true + }, + { + "poe_mode": "off", + "port_idx": 3, + "portconf_id": "5a32aa4ee4babd4452422ddd22222" + }, + { + "poe_mode": "auto", + "port_idx": 4, + "portconf_id": "5a32aa4ee4babd4452422ddd22222" + }, + { + "poe_mode": "auto", + "port_idx": 16, + "portconf_id": "5a32aa4ee4babd4452422ddd22222" + } + ], + "port_table": [ + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 1042, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": true, + "jumbo": false, + "lldp_table": [ + { + "lldp_chassis_id": "F0:9F:C2:1A:2B:3C:4E", + "lldp_port_id": "0/5", + "lldp_system_name": "Switch8" + } + ], + "masked": false, + "media": "GE", + "name": "Port 1", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 1, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 2422847, + "rx_bytes": 2027844548, + "rx_bytes-r": 712, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 7707714, + "rx_packets": 12170261, + "satisfaction": 100, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 119481, + "tx_bytes": 1832127075, + "tx_bytes-r": 330, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 277595, + "tx_packets": 4364049, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 2, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 670, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 3", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Class 3", + "poe_current": "60.18", + "poe_enable": true, + "poe_good": true, + "poe_mode": "auto", + "poe_power": "3.24", + "poe_voltage": "53.78", + "port_idx": 3, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 218, + "rx_bytes": 478468, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 29, + "rx_packets": 6014, + "satisfaction": 100, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 2542042, + "tx_bytes": 1911509746, + "tx_bytes-r": 670, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7854039, + "tx_packets": 10408988, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 722, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 4", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Class 2", + "poe_current": "27.83", + "poe_enable": true, + "poe_good": true, + "poe_mode": "auto", + "poe_power": "1.50", + "poe_voltage": "53.85", + "port_idx": 4, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 30730, + "rx_bytes": 288074224, + "rx_bytes-r": 45, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 182131, + "rx_packets": 819789, + "satisfaction": 100, + "speed": 100, + "speed_caps": 1048623, + "stp_pathcost": 200000, + "stp_state": "forwarding", + "tx_broadcast": 2542135, + "tx_bytes": 1895681324, + "tx_bytes-r": 677, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7805864, + "tx_packets": 10458150, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 5", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 5, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 6", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 6, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 7", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 7, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 719, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 8", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Class 3", + "poe_current": "68.96", + "poe_enable": true, + "poe_good": true, + "poe_mode": "auto", + "poe_power": "3.68", + "poe_voltage": "53.40", + "port_idx": 8, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 125, + "rx_bytes": 542355491, + "rx_bytes-r": 39, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 49261, + "rx_packets": 1065798, + "satisfaction": 100, + "speed": 100, + "speed_caps": 1048623, + "stp_pathcost": 200000, + "stp_state": "forwarding", + "tx_broadcast": 2542145, + "tx_bytes": 1923949844, + "tx_bytes-r": 679, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7804784, + "tx_packets": 10760304, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 9", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 9, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 10", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 10, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 11", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 11, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 12", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 12, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 13", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 13, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 14", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 14, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 15", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Unknown", + "poe_current": "0.00", + "poe_enable": false, + "poe_good": false, + "poe_mode": "auto", + "poe_power": "0.00", + "poe_voltage": "0.00", + "port_idx": 15, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 719, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 16", + "op_mode": "switch", + "poe_caps": 7, + "poe_class": "Class 4", + "poe_current": "47.24", + "poe_enable": true, + "poe_good": true, + "poe_mode": "auto", + "poe_power": "2.52", + "poe_voltage": "53.40", + "port_idx": 16, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 118, + "rx_bytes": 266497885, + "rx_bytes-r": 39, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 49191, + "rx_packets": 668010, + "satisfaction": 100, + "speed": 100, + "speed_caps": 1048623, + "stp_pathcost": 200000, + "stp_state": "forwarding", + "tx_broadcast": 2542151, + "tx_bytes": 1895646361, + "tx_bytes-r": 680, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7804854, + "tx_packets": 10458934, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "SFP", + "name": "SFP 1", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 17, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "sfp_found": false, + "speed": 0, + "speed_caps": 1048608, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "SFP", + "name": "SFP 2", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 18, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "sfp_found": false, + "speed": 0, + "speed_caps": 1048608, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + } + ], + "prev_non_busy_state": 1, + "required_version": "3.3.13", + "rx_bytes": 1832127075, + "satisfaction": 100, + "serial": "FCECDA112233", + "site_id": "5a32aa4ee4b0412345678910", + "ssh_session_table": [], + "start_connected_millis": 1587859259119, + "start_disconnected_millis": 1587859249152, + "stat": { + "sw": { + "bytes": 996934123.0, + "datetime": "2020-04-26T00:00:00Z", + "duration": 316434000.0, + "o": "sw", + "oid": "fc:ec:da:11:22:33", + "port_1-rx_broadcast": 182515.0, + "port_1-rx_bytes": 163842984.0, + "port_1-rx_multicast": 639543.0, + "port_1-rx_packets": 975984.0, + "port_1-tx_broadcast": 9483.0, + "port_1-tx_bytes": 136854988.0, + "port_1-tx_multicast": 22235.0, + "port_1-tx_packets": 356769.0, + "port_16-rx_broadcast": 8.0, + "port_16-rx_bytes": 24630367.0, + "port_16-rx_multicast": 3936.0, + "port_16-rx_packets": 60944.0, + "port_16-tx_broadcast": 191990.0, + "port_16-tx_bytes": 154033825.0, + "port_16-tx_multicast": 647405.0, + "port_16-tx_packets": 849103.0, + "port_3-rx_broadcast": 14.0, + "port_3-rx_bytes": 37970.0, + "port_3-rx_packets": 485.0, + "port_3-tx_broadcast": 191984.0, + "port_3-tx_bytes": 155259350.0, + "port_3-tx_multicast": 651340.0, + "port_3-tx_packets": 844480.0, + "port_4-rx_broadcast": 9.0, + "port_4-rx_bytes": 26511461.0, + "port_4-rx_multicast": 14479.0, + "port_4-rx_packets": 71331.0, + "port_4-tx_broadcast": 191989.0, + "port_4-tx_bytes": 154000741.0, + "port_4-tx_multicast": 647406.0, + "port_4-tx_packets": 848948.0, + "port_8-rx_broadcast": 8.0, + "port_8-rx_bytes": 26279012.0, + "port_8-rx_multicast": 3933.0, + "port_8-rx_packets": 77466.0, + "port_8-tx_broadcast": 191990.0, + "port_8-tx_bytes": 155483425.0, + "port_8-tx_multicast": 647408.0, + "port_8-tx_packets": 862103.0, + "rx_broadcast": 182554.0, + "rx_bytes": 241301794.0, + "rx_crypts": 0.0, + "rx_dropped": 0.0, + "rx_errors": 0.0, + "rx_frags": 0.0, + "rx_multicast": 661891.0, + "rx_packets": 1186210.0, + "site_id": "5a32aa4ee4b0412345678910", + "sw": "fc:ec:da:11:22:33", + "time": 1587859200000, + "tx_broadcast": 777436.0, + "tx_bytes": 755632329.0, + "tx_dropped": 0.0, + "tx_errors": 0.0, + "tx_multicast": 2615794.0, + "tx_packets": 3761403.0, + "tx_retries": 0.0 + } + }, + "state": 1, + "stp_priority": "32768", + "stp_version": "rstp", + "switch_caps": { + "feature_caps": 1022, + "max_aggregate_sessions": 6, + "max_mirror_sessions": 1 + }, + "sys_error_caps": 0, + "sys_stats": { + "loadavg_1": "2.82", + "loadavg_15": "2.81", + "loadavg_5": "2.80", + "mem_buffer": 0, + "mem_total": 262402048, + "mem_used": 129331200 + }, + "syslog_key": "REDACTED", + "system-stats": { + "cpu": "100.0", + "mem": "49.3", + "uptime": "3971865" + }, + "total_max_power": 135, + "two_phase_adopt": false, + "tx_bytes": 2027844548, + "type": "usw", + "unsupported": false, + "unsupported_reason": 0, + "upgradable": true, + "upgrade_state": 0, + "upgrade_to_firmware": "4.0.80.10875", + "uplink": { + "full_duplex": true, + "ip": "192.168.0.57", + "mac": "fc:ec:da:11:22:33", + "max_speed": 1000, + "media": "GE", + "name": "eth0", + "netmask": "255.255.255.0", + "num_port": 18, + "port_idx": 1, + "rx_bytes": 2027844548, + "rx_bytes-r": 712, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 12170261, + "speed": 1000, + "tx_bytes": 1832127075, + "tx_bytes-r": 330, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 4364049, + "type": "wire", + "up": true, + "uplink_mac": "f0:9f:11:22:33:44", + "uplink_remote_port": 5 + }, + "uplink_depth": 2, + "uptime": 3971865, + "user-num_sta": 4, + "version": "4.0.66.10832", + "x_aes_gcm": "REDACTED", + "x_authkey": "REDACTED", + "x_fingerprint": "REDACTED", + "x_has_ssh_hostkey": "REDACTED", + "x_inform_authkey": "REDACTED", + "x_ssh_hostkey_fingerprint": "REDACTED" +} diff --git a/tests/fixtures/controller/us8-4.0.66-stat-device.json b/tests/fixtures/controller/us8-4.0.66-stat-device.json new file mode 100644 index 0000000..279cbe9 --- /dev/null +++ b/tests/fixtures/controller/us8-4.0.66-stat-device.json @@ -0,0 +1,587 @@ +{ + "_id": "5a7cc21ae4b068sbddb234565324134", + "_uptime": 3971894, + "adoptable_when_upgraded": false, + "adopted": true, + "architecture": "armv7l", + "board_rev": 10, + "bytes": 1209354602451, + "cfgversion": "123131b3x1d2x454xx", + "config_network": { + "ip": "192.168.0.8", + "type": "dhcp" + }, + "connect_request_ip": "192.168.0.8", + "connect_request_port": "49349", + "considered_lost_at": 1588175834, + "device_id": "235678987654345678", + "dhcp_server_table": [], + "dot1x_portctrl_enabled": false, + "downlink_table": [ + { + "full_duplex": true, + "mac": "fc:ec:da:11:22:33", + "port_idx": 5, + "speed": 1000 + }, + { + "full_duplex": true, + "mac": "80:2a:a8:00:01:02", + "port_idx": 6, + "speed": 1000 + } + ], + "ethernet_table": [ + { + "mac": "f0:9f:11:22:33:44", + "name": "eth0", + "num_port": 8 + }, + { + "mac": "f0:9f:11:22:33:4a", + "name": "srv0" + } + ], + "flowctrl_enabled": false, + "fw_caps": 21683749, + "gateway_mac": "192.168.0.1", + "guest-num_sta": 0, + "has_fan": false, + "has_temperature": false, + "hash_id": "REDACTED", + "hw_caps": 0, + "inform_ip": "192.168.0.5", + "inform_url": "http://192.168.0.7:8080/inform", + "internet": true, + "ip": "192.168.0.8", + "jumboframe_enabled": false, + "kernel_version": "3.6.5", + "known_cfgversion": "23434545676787654", + "last_seen": 1588175735, + "last_uplink": { + "uplink_mac": "78:8a:20:33:44:55" + }, + "led_override": "on", + "license_state": "registered", + "locating": false, + "mac": "f0:9f:11:22:33:44", + "manufacturer_id": 4, + "model": "US8", + "name": "Switch 8", + "next_heartbeat_at": 1588175768, + "next_interval": 23, + "num_sta": 4, + "outdoor_mode_override": "default", + "overheating": false, + "port_overrides": [ + { + "poe_mode": "auto", + "port_idx": 5, + "portconf_id": "5a32aa4ee4babd4452422ddd22222" + } + ], + "port_table": [ + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 1", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 1, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 244434, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": true, + "jumbo": false, + "lldp_table": [ + { + "lldp_chassis_id": "78:8A:20:44:33:22:11", + "lldp_port_id": "eth1", + "lldp_system_name": "USG" + } + ], + "masked": false, + "media": "GE", + "name": "Port 2", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 2, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 44064, + "rx_bytes": 1109019728759, + "rx_bytes-r": 240953, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 138783, + "rx_packets": 808013990, + "satisfaction": 100, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 2498252, + "tx_bytes": 100334873692, + "tx_bytes-r": 3480, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7847706, + "tx_packets": 356816368, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 3", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 3, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 388, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 4", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 4, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 17, + "rx_bytes": 9242748, + "rx_bytes-r": 5, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 136169, + "satisfaction": 100, + "speed": 100, + "speed_caps": 1048623, + "stp_pathcost": 200000, + "stp_state": "forwarding", + "tx_broadcast": 2542342, + "tx_bytes": 1919704579, + "tx_bytes-r": 383, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7854446, + "tx_packets": 10540945, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 1781, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [ + { + "lldp_chassis_id": "FC:EC:DA:33:22:44", + "lldp_port_id": "0/1", + "lldp_system_name": "Switch16" + } + ], + "masked": false, + "media": "GE", + "name": "Port 5", + "op_mode": "switch", + "poe_caps": 0, + "poe_mode": "auto", + "port_idx": 5, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 129026, + "rx_bytes": 435751727043, + "rx_bytes-r": 867, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 411610, + "rx_packets": 457317083, + "satisfaction": 100, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 2413331, + "tx_bytes": 429589071593, + "tx_bytes-r": 914, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 7573771, + "tx_packets": 370316574, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 244345, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [ + { + "lldp_chassis_id": "80:2A:A8:55:44:33", + "lldp_port_id": "80:2A:A8:55:44:33", + "lldp_system_name": "UAPACPRO" + } + ], + "masked": false, + "media": "GE", + "name": "Port 6", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 6, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 218412, + "rx_bytes": 53516789416, + "rx_bytes-r": 4113, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 2935589, + "rx_packets": 333052376, + "satisfaction": 90, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 2323945, + "tx_bytes": 2275838496776, + "tx_bytes-r": 240232, + "tx_dropped": 2665, + "tx_errors": 0, + "tx_multicast": 5051186, + "tx_packets": 1574259392, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 3508, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 7", + "op_mode": "switch", + "poe_caps": 0, + "port_idx": 7, + "port_poe": false, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 2031756, + "rx_bytes": 1602876591571, + "rx_bytes-r": 613, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 2646968, + "rx_packets": 1117936736, + "satisfaction": 100, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 510499, + "tx_bytes": 400026198993, + "tx_bytes-r": 2895, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 5207435, + "tx_packets": 440118452, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "lldp_table": [], + "masked": false, + "media": "GE", + "name": "Port 8", + "op_mode": "switch", + "poe_caps": 8, + "poe_enable": false, + "poe_mode": "off", + "poe_voltage": "48.00", + "port_idx": 8, + "port_poe": true, + "portconf_id": "5a32aa4ee4babd4452422ddd22222", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + } + ], + "power_source": "262144", + "power_source_voltage": "48.00", + "prev_non_busy_state": 1, + "required_version": "3.7.16", + "rx_bytes": 100334873692, + "satisfaction": 98, + "serial": "F09F11223344", + "site_id": "5a32aa4ee4b0412345678910", + "ssh_session_table": [], + "start_connected_millis": 1587859250668, + "start_disconnected_millis": 1587859249151, + "stat": { + "sw": { + "bytes": 522138756790.0, + "datetime": "2020-04-26T00:00:00Z", + "duration": 316469000.0, + "o": "sw", + "oid": "f0:9f:11:22:33:44", + "port_2-rx_broadcast": 3728.0, + "port_2-rx_bytes": 76911368375.0, + "port_2-rx_multicast": 11056.0, + "port_2-rx_packets": 56426757.0, + "port_2-tx_broadcast": 188293.0, + "port_2-tx_bytes": 6099269315.0, + "port_2-tx_multicast": 650992.0, + "port_2-tx_packets": 24859744.0, + "port_4-rx_bytes": 1255789.0, + "port_4-rx_packets": 18703.0, + "port_4-tx_broadcast": 192021.0, + "port_4-tx_bytes": 156439725.0, + "port_4-tx_multicast": 651520.0, + "port_4-tx_packets": 862886.0, + "port_5-rx_broadcast": 10231.0, + "port_5-rx_bytes": 1916386586.0, + "port_5-rx_multicast": 33021.0, + "port_5-rx_packets": 14642662.0, + "port_5-tx_broadcast": 181790.0, + "port_5-tx_bytes": 36477482238.0, + "port_5-tx_multicast": 628931.0, + "port_5-tx_packets": 27718236.0, + "port_6-rx_broadcast": 19949.0, + "port_6-rx_bytes": 3988926804.0, + "port_6-rx_multicast": 258385.0, + "port_6-rx_packets": 26449642.0, + "port_6-tx_broadcast": 172072.0, + "port_6-tx_bytes": 216628215977.0, + "port_6-tx_dropped": 202.0, + "port_6-tx_multicast": 403675.0, + "port_6-tx_packets": 148081715.0, + "port_7-rx_broadcast": 148618.0, + "port_7-rx_bytes": 177986447879.0, + "port_7-rx_multicast": 211883.0, + "port_7-rx_packets": 119394527.0, + "port_7-tx_broadcast": 43403.0, + "port_7-tx_bytes": 1972964102.0, + "port_7-tx_multicast": 439638.0, + "port_7-tx_packets": 18291623.0, + "rx_broadcast": 182526.0, + "rx_bytes": 260804385433.0, + "rx_crypts": 0.0, + "rx_dropped": 0.0, + "rx_errors": 0.0, + "rx_frags": 0.0, + "rx_multicast": 514345.0, + "rx_packets": 216932291.0, + "site_id": "5a32aa4ee4b0412345678910", + "sw": "f0:9f:11:22:33:44", + "time": 1587859200000, + "tx_broadcast": 777579.0, + "tx_bytes": 261334371357.0, + "tx_dropped": 202.0, + "tx_errors": 0.0, + "tx_multicast": 2774756.0, + "tx_packets": 219814204.0, + "tx_retries": 0.0 + } + }, + "state": 1, + "stp_priority": "32768", + "stp_version": "rstp", + "switch_caps": { + "feature_caps": 1022, + "max_aggregate_sessions": 4, + "max_mirror_sessions": 1 + }, + "sys_error_caps": 0, + "sys_stats": { + "loadavg_1": "1.12", + "loadavg_15": "1.45", + "loadavg_5": "1.31", + "mem_buffer": 0, + "mem_total": 262402048, + "mem_used": 128737280 + }, + "syslog_key": "REDACTED", + "system-stats": { + "cpu": "56.3", + "mem": "49.1", + "uptime": "3971894" + }, + "total_max_power": 0, + "two_phase_adopt": false, + "tx_bytes": 1109019728759, + "type": "usw", + "unsupported": false, + "unsupported_reason": 0, + "upgradable": true, + "upgrade_state": 0, + "upgrade_to_firmware": "4.0.80.10875", + "uplink": { + "full_duplex": true, + "ip": "192.168.0.8", + "mac": "f0:9f:11:22:33:44", + "max_speed": 1000, + "media": "GE", + "name": "eth0", + "netmask": "255.255.255.0", + "num_port": 8, + "port_idx": 2, + "rx_bytes": 1109019728759, + "rx_bytes-r": 240953, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 808013990, + "speed": 1000, + "tx_bytes": 100334873692, + "tx_bytes-r": 3480, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 356816368, + "type": "wire", + "up": true, + "uplink_mac": "78:8a:20:33:44:55" + }, + "uplink_depth": 1, + "uptime": 3971894, + "user-num_sta": 4, + "version": "4.0.66.10832", + "x_aes_gcm": "REDACTED", + "x_authkey": "REDACTED", + "x_has_ssh_hostkey": "REDACTED", + "x_inform_authkey": "REDACTED", + "x_ssh_hostkey_fingerprint": "REDACTED" +} diff --git a/tests/fixtures/controller/usmini-1.8.4-stat-device.json b/tests/fixtures/controller/usmini-1.8.4-stat-device.json new file mode 100644 index 0000000..df137ac --- /dev/null +++ b/tests/fixtures/controller/usmini-1.8.4-stat-device.json @@ -0,0 +1,359 @@ +{ + "_id": "5f47a419c753120123456789", + "_uptime": 9273422, + "adopt_ip": "198.168.0.9", + "adopt_url": "http://192.168.0.1:8080/inform", + "adoptable_when_upgraded": false, + "adopted": true, + "anomalies": -1, + "anon_id": "REDACTED", + "board_rev": 12, + "bytes": 0, + "cfgversion": "96376fe9d11ae1ac", + "config_network": { + "ip": "198.168.0.9", + "type": "dhcp" + }, + "connect_request_ip": "198.168.0.9", + "connect_request_port": "60216", + "connected_at": 1634732311, + "connection_network_name": "LAN", + "default": false, + "device_id": "5f47a419c753120123456789", + "dhcp_server_table": [], + "discovered_via": "l2", + "displayable_version": "1.8.4", + "dot1x_portctrl_enabled": false, + "downlink_table": [], + "ethernet_table": [ + { + "mac": "74:ac:b9:a1:01:01", + "name": "eth0", + "num_port": 5 + } + ], + "flowctrl_enabled": false, + "fw_caps": 0, + "guest-num_sta": 0, + "has_fan": false, + "has_temperature": false, + "hw_caps": 0, + "inform_ip": "192.168.0.1", + "inform_url": "http://192.168.0.1:8080/inform", + "ip": "198.168.0.9", + "jumboframe_enabled": false, + "known_cfgversion": "96376fe9d11ae1ac", + "last_seen": 1635577067, + "last_uplink": { + "port_idx": 1, + "type": "wire", + "uplink_mac": "fc:ec:00:11:22:33", + "uplink_remote_port": 13 + }, + "lcm_brightness_override": false, + "lcm_idle_timeout_override": false, + "lcm_tracker_enabled": false, + "led_override": "on", + "led_override_color": "#0000ff", + "led_override_color_brightness": 100, + "license_state": "registered", + "lldp_table": [ + { + "chassis_id": "fc:ec:00:11:22:33", + "is_wired": true, + "local_port_idx": 1, + "local_port_name": "eth0", + "port_id": "Port " + } + ], + "locating": false, + "mac": "74:ac:b9:a1:01:01", + "manufacturer_id": 2, + "model": "USMINI", + "model_in_eol": false, + "model_in_lts": false, + "model_incompatible": false, + "name": "UniFi Switch Flex Mini", + "next_interval": 34, + "num_sta": 0, + "outdoor_mode_override": "default", + "overheating": false, + "port_table": [ + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 577, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": true, + "jumbo": false, + "masked": false, + "media": "GE", + "name": "Port 1", + "op_mode": "switch", + "port_idx": 1, + "port_poe": false, + "portconf_id": "5f3edd2aba4cc806a19f2db2", + "rx_broadcast": 6679204, + "rx_bytes": 6147696151, + "rx_bytes-r": 452, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 20240009, + "rx_packets": 30183544, + "speed": 1000, + "speed_caps": 1048623, + "tx_broadcast": 3397, + "tx_bytes": 1243754733, + "tx_bytes-r": 124, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 310278, + "tx_packets": 3836158, + "up": true + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "masked": false, + "media": "GE", + "name": "Port 2", + "op_mode": "switch", + "port_idx": 2, + "port_poe": false, + "portconf_id": "5f3edd2aba4cc806a19f2db2", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "speed": 0, + "speed_caps": 1048623, + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "masked": false, + "media": "GE", + "name": "Port 3", + "op_mode": "switch", + "port_idx": 3, + "port_poe": false, + "portconf_id": "5f3edd2aba4cc806a19f2db2", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "speed": 0, + "speed_caps": 1048623, + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "masked": false, + "media": "GE", + "name": "Port 4", + "op_mode": "switch", + "port_idx": 4, + "port_poe": false, + "portconf_id": "5f3edd2aba4cc806a19f2db2", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "speed": 0, + "speed_caps": 1048623, + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "aggregated_by": false, + "autoneg": true, + "bytes-r": 0, + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "masked": false, + "media": "GE", + "name": "Port 5", + "op_mode": "switch", + "port_idx": 5, + "port_poe": false, + "portconf_id": "5f3edd2aba4cc806a19f2db2", + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "speed": 0, + "speed_caps": 1048623, + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + } + ], + "power_source_ctrl_enabled": false, + "provisioned_at": 1610008100, + "required_version": "1.7.3", + "rollupgrade": false, + "rx_bytes": 0, + "satisfaction": -1, + "serial": "74ACB9A10101", + "site_id": "5a32aa4ee4b0412345678910", + "start_connected_millis": 1634732311256, + "start_disconnected_millis": 1634732296240, + "startup_timestamp": 1626303645, + "stat": { + "sw": { + "bytes": 648398923.0, + "datetime": "2021-10-20T12:15:00Z", + "duration": 844723000.0, + "o": "sw", + "oid": "74:ac:b9:a1:01:01", + "port_1-rx_broadcast": 565601.0, + "port_1-rx_bytes": 535337644.0, + "port_1-rx_multicast": 1790802.0, + "port_1-rx_packets": 2652630.0, + "port_1-tx_broadcast": 335.0, + "port_1-tx_bytes": 113061279.0, + "port_1-tx_multicast": 28157.0, + "port_1-tx_packets": 348590.0, + "rx_broadcast": 565601.0, + "rx_bytes": 535337644.0, + "rx_crypts": 0.0, + "rx_dropped": 0.0, + "rx_errors": 0.0, + "rx_frags": 0.0, + "rx_multicast": 1790802.0, + "rx_packets": 2652630.0, + "site_id": "5a32aa4ee4b0412345678910", + "sw": "74:ac:b9:a1:01:01", + "time": 1634732100000, + "tx_broadcast": 335.0, + "tx_bytes": 113061279.0, + "tx_dropped": 0.0, + "tx_errors": 0.0, + "tx_multicast": 28157.0, + "tx_packets": 348590.0, + "tx_retries": 0.0 + } + }, + "state": 1, + "stp_priority": "32768", + "stp_version": "rstp", + "switch_caps": { + "feature_caps": 44, + "max_aggregate_sessions": 0, + "max_mirror_sessions": 1, + "vlan_caps": 2 + }, + "sys_error_caps": 0, + "sys_stats": { + "mem_total": 163840, + "mem_used": 131940 + }, + "syslog_key": "REDACTED", + "system-stats": {}, + "two_phase_adopt": false, + "tx_bytes": 0, + "type": "usw", + "unsupported": false, + "unsupported_reason": 0, + "upgradable": false, + "uplink": { + "full_duplex": true, + "ip": "198.168.0.9", + "mac": "74:ac:b9:a1:01:01", + "max_speed": 1000, + "media": "GE", + "name": "eth0", + "netmask": "255.255.255.0", + "num_port": 5, + "port_idx": 1, + "rx_bytes": 0, + "rx_bytes-r": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_packets": 0, + "speed": 1000, + "tx_bytes": 0, + "tx_bytes-r": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 0, + "type": "wire", + "up": true, + "uplink_mac": "fc:ec:00:11:22:33", + "uplink_remote_port": 13 + }, + "uplink_depth": 2, + "uptime": 9273422, + "user-num_sta": 0, + "version": "1.8.4.674", + "x_aes_gcm": "REDACTED", + "x_authkey": "REDACTED", + "x_has_ssh_hostkey": "REDACTED" +} diff --git a/tests/fixtures/controller/wlanconf.json b/tests/fixtures/controller/wlanconf.json new file mode 100644 index 0000000..273ce8e --- /dev/null +++ b/tests/fixtures/controller/wlanconf.json @@ -0,0 +1,74 @@ +[ + { + "_id": "012345678910111213141516", + "bc_filter_enabled": false, + "bc_filter_list": [], + "dtim_mode": "default", + "dtim_na": 1, + "dtim_ng": 1, + "enabled": true, + "group_rekey": 3600, + "mac_filter_enabled": false, + "mac_filter_list": [], + "mac_filter_policy": "allow", + "minrate_na_advertising_rates": false, + "minrate_na_beacon_rate_kbps": 6000, + "minrate_na_data_rate_kbps": 6000, + "minrate_na_enabled": false, + "minrate_na_mgmt_rate_kbps": 6000, + "minrate_ng_advertising_rates": false, + "minrate_ng_beacon_rate_kbps": 1000, + "minrate_ng_data_rate_kbps": 1000, + "minrate_ng_enabled": false, + "minrate_ng_mgmt_rate_kbps": 1000, + "name": "SSID 1", + "no2ghz_oui": false, + "schedule": [], + "security": "wpapsk", + "site_id": "5a32aa4ee4b0412345678910", + "usergroup_id": "012345678910111213141518", + "wep_idx": 1, + "wlangroup_id": "012345678910111213141519", + "wpa_enc": "ccmp", + "wpa_mode": "wpa2", + "x_iapp_key": "REDACTED", + "x_passphrase": "REDACTED" + }, + { + "_id": "123456789101112161415160", + "bc_filter_enabled": true, + "bc_filter_list": [], + "dtim_mode": "default", + "dtim_na": 1, + "dtim_ng": 1, + "enabled": false, + "group_rekey": 3600, + "hide_ssid": true, + "is_guest": true, + "mac_filter_enabled": false, + "mac_filter_list": [], + "mac_filter_policy": "allow", + "minrate_na_advertising_rates": false, + "minrate_na_beacon_rate_kbps": 6000, + "minrate_na_data_rate_kbps": 6000, + "minrate_na_enabled": false, + "minrate_na_mgmt_rate_kbps": 6000, + "minrate_ng_advertising_rates": false, + "minrate_ng_beacon_rate_kbps": 1000, + "minrate_ng_cck_rates_enabled": true, + "minrate_ng_data_rate_kbps": 1000, + "minrate_ng_enabled": false, + "minrate_ng_mgmt_rate_kbps": 1000, + "name": "SSID 2", + "schedule": [], + "security": "wpapsk", + "site_id": "5a32aa4ee4b0412345678910", + "usergroup_id": "123456789101112161415162", + "wep_idx": 1, + "wlangroup_id": "123456789101112161415163", + "wpa_enc": "ccmp", + "wpa_mode": "wpa2", + "x_iapp_key": "REDACTED", + "x_passphrase": "REDACTED" + } +] diff --git a/tests/fixtures/ssh/us24-7.1.26-mca-dump.json b/tests/fixtures/ssh/us24-7.1.26-mca-dump.json new file mode 100644 index 0000000..1a9d052 --- /dev/null +++ b/tests/fixtures/ssh/us24-7.1.26-mca-dump.json @@ -0,0 +1,1220 @@ +{ + "anon_id": "REDACTED", + "architecture": "armv7l", + "ble_caps": 0, + "board_rev": 6, + "bomrev": "113-02294-06", + "bomrev_id": "0008f606", + "boot": { + "id": "a88c0507-3a1f-4756-9933-5b609dd858be" + }, + "bootid": 0, + "bootrom_version": "usw-v1.1.4.115-g14af1ee6", + "cfgversion": "80a2550b9c259c2c", + "connect_request_ip": "10.0.0.10", + "connect_request_port": "42858", + "default": false, + "dhcp_server_table": [], + "discovery_response": false, + "dualboot": true, + "ever_crash": false, + "fan_level": 0, + "fw2_caps": 0, + "fw_caps": 2806576677, + "gateway_ip": "10.0.0.1", + "gateway_mac": "02:00:00:00:00:01", + "general_temperature": 66, + "guest_kicks": 0, + "guest_token": "REDACTED", + "has_eth1": false, + "has_fan": true, + "has_speaker": false, + "has_temperature": true, + "hash_id": "REDACTED", + "hostname": "usw-1", + "hw_caps": 0, + "if_table": [ + { + "full_duplex": true, + "ip": "10.0.0.10", + "mac": "64:f8:46:00:00:10", + "name": "eth0", + "netmask": "255.255.255.0", + "num_port": 26, + "rx_bytes": 584881911, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 8113500, + "speed": 10, + "tx_bytes": 1550612076, + "tx_dropped": 0, + "tx_errors": 0, + "tx_packets": 2680108, + "up": true + } + ], + "inform_min_interval": 30, + "inform_url": "http://10.0.0.10:8080/inform", + "internet": true, + "ip": "10.0.0.10", + "ipv6": [ + "fe80::66f8:46ff:fe00:10/64" + ], + "isolated": false, + "kernel_version": "3.6.5", + "last_error_conns": [], + "lldp_table": [ + { + "chassis_id": "f0:9f:c2:00:00:01", + "is_wired": true, + "local_port_idx": 22, + "local_port_name": "22", + "port_id": "Port 1" + } + ], + "locating": false, + "mac": "64:f8:46:00:00:10", + "manufacturer_id": 4, + "model": "US24", + "model_display": "US-24-G1", + "netmask": "255.255.255.0", + "overheating": false, + "port_table": [ + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": false, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 1, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 2, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 3, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 4, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 5, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 6, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 7, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 8, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 29, + "hostname": "client1", + "ip": "10.0.8.101", + "mac": "02:00:00:00:00:02", + "static": false, + "uptime": 1393672, + "vlan": 8 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 9, + "port_poe": false, + "rx_broadcast": 92, + "rx_bytes": 502653803622, + "rx_dropped": 164490, + "rx_errors": 0, + "rx_multicast": 500462, + "rx_packets": 719826129, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 103413, + "tx_bytes": 476432452703, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 5637841, + "tx_packets": 727409838, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 10, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 51, + "hostname": "client2", + "ip": "10.0.12.68", + "mac": "02:00:00:00:00:03", + "static": false, + "uptime": 9969159, + "vlan": 12 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 11, + "port_poe": false, + "rx_broadcast": 33706, + "rx_bytes": 12927426694, + "rx_dropped": 237, + "rx_errors": 0, + "rx_multicast": 8599958, + "rx_packets": 33927182, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 100, + "speed_caps": 1048623, + "stp_pathcost": 200000, + "stp_state": "forwarding", + "tx_broadcast": 11584238, + "tx_bytes": 7128091013, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 12605544, + "tx_packets": 48805457, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 52984, + "ip": "10.0.6.76", + "mac": "02:00:00:00:00:04", + "static": false, + "uptime": 5846798, + "vlan": 6 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 12, + "port_poe": false, + "rx_broadcast": 2987, + "rx_bytes": 6154743583, + "rx_dropped": 432783, + "rx_errors": 0, + "rx_multicast": 1080995, + "rx_packets": 39434951, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 6409376, + "tx_bytes": 416497978849, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 15690563, + "tx_packets": 310897957, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 561085, + "ip": "10.0.8.2", + "mac": "02:00:00:00:00:05", + "static": false, + "uptime": 676898, + "vlan": 8 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 13, + "port_poe": false, + "rx_broadcast": 17, + "rx_bytes": 248872246851, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 2834, + "rx_packets": 550668627, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 94827, + "tx_bytes": 1187555907101, + "tx_dropped": 133, + "tx_errors": 0, + "tx_multicast": 5905530, + "tx_packets": 881360967, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 63, + "hostname": "client3", + "ip": "10.0.12.65", + "mac": "02:00:00:00:00:06", + "static": false, + "uptime": 376816, + "vlan": 12 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 14, + "port_poe": false, + "rx_broadcast": 38829, + "rx_bytes": 3660736295, + "rx_dropped": 31, + "rx_errors": 0, + "rx_multicast": 655632, + "rx_packets": 13115703, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 100, + "speed_caps": 1048623, + "stp_pathcost": 200000, + "stp_state": "forwarding", + "tx_broadcast": 11578531, + "tx_bytes": 11317104179, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 20548878, + "tx_packets": 43418318, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 8448, + "ip": "10.0.6.82", + "mac": "02:00:00:00:00:07", + "static": false, + "uptime": 226672, + "vlan": 6 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 15, + "port_poe": false, + "rx_broadcast": 3761, + "rx_bytes": 10225097097, + "rx_dropped": 455870, + "rx_errors": 0, + "rx_multicast": 1489054, + "rx_packets": 83428280, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 6408566, + "tx_bytes": 780250601634, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 15306063, + "tx_packets": 562401025, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 10270, + "ip": "10.0.6.10", + "mac": "02:00:00:00:00:08", + "static": false, + "uptime": 761061, + "vlan": 6 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 16, + "port_poe": false, + "rx_broadcast": 4398719, + "rx_bytes": 4802358165005, + "rx_dropped": 336304, + "rx_errors": 0, + "rx_multicast": 1341247, + "rx_packets": 3599943417, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 2011806, + "tx_bytes": 833882559310, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 15332201, + "tx_packets": 976452685, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 17, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 18, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 5, + "ip": "10.0.0.6", + "mac": "02:00:00:00:00:09", + "static": false, + "uptime": 9968565, + "vlan": 1 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 19, + "port_poe": false, + "rx_broadcast": 281981, + "rx_bytes": 4831534751983, + "rx_dropped": 265631, + "rx_errors": 1, + "rx_multicast": 735312, + "rx_packets": 4114906179, + "satisfaction": 75, + "satisfaction_reason": 3, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 33858995, + "tx_bytes": 254151967256, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 35340376, + "tx_packets": 2028474354, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "GE", + "poe_caps": 0, + "port_idx": 20, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "speed": 0, + "speed_caps": 1048623, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": true, + "jumbo": false, + "mac_table": [ + { + "age": 2, + "ip": "10.0.12.1", + "mac": "02:00:00:00:00:01", + "static": false, + "uptime": 763010, + "vlan": 12 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 21, + "port_poe": false, + "rx_broadcast": 11098152, + "rx_bytes": 18727976380883, + "rx_dropped": 0, + "rx_errors": 2, + "rx_multicast": 355426, + "rx_packets": 22848084574, + "satisfaction": 75, + "satisfaction_reason": 3, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 23042906, + "tx_bytes": 17363884968887, + "tx_dropped": 598920, + "tx_errors": 0, + "tx_multicast": 35434779, + "tx_packets": 22017913203, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 19, + "ip": "10.0.0.7", + "mac": "02:00:00:00:00:0a", + "static": false, + "uptime": 595765, + "vlan": 1 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 22, + "port_poe": false, + "rx_broadcast": 2231923, + "rx_bytes": 6380861897331, + "rx_dropped": 403994, + "rx_errors": 1, + "rx_multicast": 2082963, + "rx_packets": 6583664405, + "satisfaction": 75, + "satisfaction_reason": 3, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 31909072, + "tx_bytes": 3515889947744, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 33984677, + "tx_packets": 6526423244, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 48, + "hostname": "client4", + "ip": "10.0.12.77", + "mac": "02:00:00:00:00:0b", + "static": false, + "uptime": 595766, + "vlan": 12, + "wevent_age": 136871, + "wevent_type": "join" + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 23, + "port_poe": false, + "rx_broadcast": 2396132, + "rx_bytes": 1804835269691, + "rx_dropped": 634198, + "rx_errors": 784, + "rx_multicast": 5884619, + "rx_packets": 1893119137, + "satisfaction": 75, + "satisfaction_reason": 3, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 31744737, + "tx_bytes": 1480739688813, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 30588145, + "tx_packets": 2129646231, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": true, + "is_uplink": false, + "jumbo": false, + "mac_table": [ + { + "age": 60, + "hostname": "client5", + "ip": "10.0.12.246", + "mac": "02:00:00:00:00:0c", + "static": false, + "uptime": 595760, + "vlan": 12 + } + ], + "mac_table_count": 1, + "media": "GE", + "poe_caps": 0, + "port_idx": 24, + "port_poe": false, + "rx_broadcast": 13335433, + "rx_bytes": 1328970911978, + "rx_dropped": 661020, + "rx_errors": 0, + "rx_multicast": 11304085, + "rx_packets": 6980002825, + "satisfaction": 90, + "satisfaction_reason": 1, + "speed": 1000, + "speed_caps": 1048623, + "stp_pathcost": 20000, + "stp_state": "forwarding", + "tx_broadcast": 20805265, + "tx_bytes": 12422482537692, + "tx_dropped": 3403, + "tx_errors": 0, + "tx_multicast": 26322462, + "tx_packets": 11572199963, + "up": true + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "SFP", + "poe_caps": 0, + "port_idx": 25, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "sfp_found": false, + "speed": 0, + "speed_caps": 1048608, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + }, + { + "anomalies": 0, + "autoneg": true, + "dot1x_mode": "unknown", + "dot1x_status": "disabled", + "enable": true, + "flowctrl_rx": false, + "flowctrl_tx": false, + "full_duplex": false, + "is_uplink": false, + "jumbo": false, + "mac_table": [], + "mac_table_count": 0, + "media": "SFP", + "poe_caps": 0, + "port_idx": 26, + "port_poe": false, + "rx_broadcast": 0, + "rx_bytes": 0, + "rx_dropped": 0, + "rx_errors": 0, + "rx_multicast": 0, + "rx_packets": 0, + "satisfaction": 100, + "satisfaction_reason": 0, + "sfp_found": false, + "speed": 0, + "speed_caps": 1048608, + "stp_pathcost": 0, + "stp_state": "disabled", + "tx_broadcast": 0, + "tx_bytes": 0, + "tx_dropped": 0, + "tx_errors": 0, + "tx_multicast": 0, + "tx_packets": 0, + "up": false + } + ], + "reboot_duration": 90, + "required_version": "3.3.13", + "root_switch": "64:f8:46:00:00:10", + "satisfaction": 93, + "satisfaction_reason": 4, + "selfrun_beacon": true, + "serial": "64f846000010", + "service_mac": "02:00:00:00:00:0d", + "ssh_session_table": [], + "state": 2, + "stats_inform_interval": 2, + "stp_priority": 0, + "stream_token": "REDACTED", + "switch_caps": { + "etherlight_caps": 0, + "feature_caps": 70822910, + "max_acl_port_range": 16, + "max_aggregate_sessions": 13, + "max_class_maps": 0, + "max_custom_ip_acls": 128, + "max_custom_mac_acls": 128, + "max_global_acls": 128, + "max_l3_intf": 0, + "max_mac_based_vlan_count": 256, + "max_mirror_sessions": 1, + "max_qos_profiles": 0, + "max_reserved_routes": 0, + "max_static_routes": 0, + "max_vlan_count": 1000 + }, + "sys_error_caps": 0, + "sys_stats": { + "loadavg_1": "1.59", + "loadavg_15": "1.73", + "loadavg_5": "1.77", + "mem_buffer": 0, + "mem_total": 262496256, + "mem_used": 114589696 + }, + "sysid": 60208, + "system-stats": { + "cpu": "57.4", + "mem": "43.8", + "uptime": "9969234" + }, + "time": 1738945112, + "time_ms": 1026, + "timestamp": "2025-02-07T11:18:32", + "tm_ready": true, + "total_mac_in_used": 70, + "total_max_power": 0, + "upgrade_duration": 230, + "uplink": "eth0", + "uptime": 9969266, + "uptime_str": "115d9h14m26s", + "version": "7.1.26.15869" +} diff --git a/tests/fixtures/ssh/us24-7.1.26-running.cfg b/tests/fixtures/ssh/us24-7.1.26-running.cfg new file mode 100644 index 0000000..39be969 --- /dev/null +++ b/tests/fixtures/ssh/us24-7.1.26-running.cfg @@ -0,0 +1,482 @@ +# unifi +unifi.version=9.0.114 +unifi.anonymous_controller_id=00000000-0000-4000-8000-000000000001 +unifi.anonymous_site_id=00000000-0000-4000-8000-000000000002 +unifi.reporterid=00000000-0000-4000-8000-000000000001 +unifi.siteid=000000000000000000000001 +unifi.idp=enabled +unifi.mcip=239.254.127.63 +unifi.key=REDACTED +unifi.feature.always_send_crash_logs=enabled +# system +system.analytics.status=disabled +system.timezone=EST5EDT,M3.2.0,M11.1.0 +locale.timezone=EST5EDT,M3.2.0,M11.1.0 +# users +users.status=enabled +users.1.name=admin +users.1.password=REDACTED +users.1.status=enabled +users.2.name=nobody +users.2.password=REDACTED +users.2.shell=/bin/false +users.2.status=enabled +# vlan +vlan.status=disabled +# bridge +bridge.status=disabled +# netconf +netconf.status=enabled +netconf.1.status=enabled +netconf.1.devname=eth0 +netconf.1.ip=10.0.0.10 +netconf.1.autoip.status=disabled +netconf.1.netmask=255.255.255.0 +netconf.1.promisc=enabled +netconf.1.up=enabled +# dhcpc +dhcpc.status=enabled +# route +route.1.status=enabled +route.1.devname=eth0 +route.1.ip=0.0.0.0 +route.1.gateway=10.0.0.1 +route.status=enabled +# resolv +resolv.status=enabled +resolv.host.1.name=usw-1 +resolv.nameserver.1.ip=1.1.1.1 +resolv.nameserver.2.status=disabled +# switch +switch.power_source.status=disabled +switch.managementvlan=1 +switch.wevent.idp=enabled +switch.wevent.mcip=239.254.127.63 +switch.wevent.key=REDACTED +switch.jumboframes=disabled +switch.mtu=9216 +switch.stp.version=rstp +switch.stp.priority=0 +switch.stp.status=enabled +switch.dot1x.status=disabled +switch.vlan.1.id=1 +switch.vlan.1.mode=untagged +switch.vlan.1.status=enabled +switch.vlan.2.id=2 +switch.vlan.2.mode=tagged +switch.vlan.2.status=enabled +switch.vlan.2.igmp_snooping=true +switch.vlan.2.igmp_fastleave=false +switch.vlan.2.igmp_maxresponse=10 +switch.vlan.2.igmp_mcrtrexpiretime=0 +switch.vlan.2.igmp_groupmembership=260 +switch.vlan.2.igmp_querier= +switch.vlan.2.igmp_supression=false +switch.vlan.2.forward_unknown_multicast=false +switch.vlan.3.id=3 +switch.vlan.3.mode=tagged +switch.vlan.3.status=enabled +switch.vlan.3.igmp_snooping=true +switch.vlan.3.igmp_fastleave=false +switch.vlan.3.igmp_maxresponse=10 +switch.vlan.3.igmp_mcrtrexpiretime=0 +switch.vlan.3.igmp_groupmembership=260 +switch.vlan.3.igmp_querier= +switch.vlan.3.igmp_supression=false +switch.vlan.3.forward_unknown_multicast=false +switch.vlan.4.id=4 +switch.vlan.4.mode=tagged +switch.vlan.4.status=enabled +switch.vlan.4.igmp_snooping=true +switch.vlan.4.igmp_fastleave=false +switch.vlan.4.igmp_maxresponse=10 +switch.vlan.4.igmp_mcrtrexpiretime=0 +switch.vlan.4.igmp_groupmembership=260 +switch.vlan.4.igmp_querier= +switch.vlan.4.igmp_supression=false +switch.vlan.4.forward_unknown_multicast=false +switch.vlan.5.id=5 +switch.vlan.5.mode=tagged +switch.vlan.5.status=enabled +switch.vlan.5.igmp_snooping=true +switch.vlan.5.igmp_fastleave=false +switch.vlan.5.igmp_maxresponse=10 +switch.vlan.5.igmp_mcrtrexpiretime=0 +switch.vlan.5.igmp_groupmembership=260 +switch.vlan.5.igmp_querier= +switch.vlan.5.igmp_supression=false +switch.vlan.5.forward_unknown_multicast=false +switch.vlan.6.id=6 +switch.vlan.6.mode=tagged +switch.vlan.6.status=enabled +switch.vlan.6.igmp_snooping=true +switch.vlan.6.igmp_fastleave=false +switch.vlan.6.igmp_maxresponse=10 +switch.vlan.6.igmp_mcrtrexpiretime=0 +switch.vlan.6.igmp_groupmembership=260 +switch.vlan.6.igmp_querier= +switch.vlan.6.igmp_supression=false +switch.vlan.6.forward_unknown_multicast=false +switch.vlan.7.id=7 +switch.vlan.7.mode=tagged +switch.vlan.7.status=enabled +switch.vlan.8.id=8 +switch.vlan.8.mode=tagged +switch.vlan.8.status=enabled +switch.vlan.8.igmp_snooping=true +switch.vlan.8.igmp_fastleave=false +switch.vlan.8.igmp_maxresponse=10 +switch.vlan.8.igmp_mcrtrexpiretime=0 +switch.vlan.8.igmp_groupmembership=260 +switch.vlan.8.igmp_querier= +switch.vlan.8.igmp_supression=false +switch.vlan.8.forward_unknown_multicast=false +switch.vlan.9.id=9 +switch.vlan.9.mode=tagged +switch.vlan.9.status=enabled +switch.vlan.10.id=10 +switch.vlan.10.mode=tagged +switch.vlan.10.status=enabled +switch.vlan.10.igmp_snooping=true +switch.vlan.10.igmp_fastleave=false +switch.vlan.10.igmp_maxresponse=10 +switch.vlan.10.igmp_mcrtrexpiretime=0 +switch.vlan.10.igmp_groupmembership=260 +switch.vlan.10.igmp_querier= +switch.vlan.10.igmp_supression=false +switch.vlan.10.forward_unknown_multicast=false +switch.vlan.11.id=11 +switch.vlan.11.mode=tagged +switch.vlan.11.status=enabled +switch.vlan.12.id=12 +switch.vlan.12.mode=tagged +switch.vlan.12.status=enabled +switch.vlan.13.id=100 +switch.vlan.13.mode=tagged +switch.vlan.13.status=enabled +switch.dhcp_snoop.status=enabled +# switch ACL +switch.routing_enabled=false +switch.port.1.name=1 +switch.port.1.status=disabled +switch.port.1.lldpmed.opmode=enabled +switch.port.1.lldpmed.topology_notify=disabled +switch.port.1.stp.port_mode=enabled +switch.port.1.keepalive=disabled +switch.port.1.opmode=switch +switch.port.1.port-security=enabled +switch.port.2.name=2 +switch.port.2.lldpmed.opmode=enabled +switch.port.2.lldpmed.topology_notify=disabled +switch.port.2.stp.port_mode=enabled +switch.port.2.keepalive=disabled +switch.port.2.opmode=switch +switch.port.2.pvid=11 +switch.port.2.port-security=disabled +switch.vlan.1.port.2.mode=exclude +switch.vlan.2.port.2.mode=exclude +switch.vlan.3.port.2.mode=exclude +switch.vlan.4.port.2.mode=exclude +switch.vlan.5.port.2.mode=exclude +switch.vlan.6.port.2.mode=exclude +switch.vlan.7.port.2.mode=exclude +switch.vlan.8.port.2.mode=exclude +switch.vlan.9.port.2.mode=exclude +switch.vlan.10.port.2.mode=exclude +switch.vlan.11.port.2.mode=untagged +switch.vlan.12.port.2.mode=exclude +switch.vlan.13.port.2.mode=exclude +switch.port.3.name=3 +switch.port.3.lldpmed.opmode=enabled +switch.port.3.lldpmed.topology_notify=disabled +switch.port.3.stp.port_mode=enabled +switch.port.3.keepalive=disabled +switch.port.3.opmode=switch +switch.port.3.port-security=disabled +switch.port.4.name=4 +switch.port.4.lldpmed.opmode=enabled +switch.port.4.lldpmed.topology_notify=disabled +switch.port.4.stp.port_mode=enabled +switch.port.4.keepalive=disabled +switch.port.4.opmode=switch +switch.port.4.port-security=disabled +switch.port.5.name=5 +switch.port.5.lldpmed.opmode=enabled +switch.port.5.lldpmed.topology_notify=disabled +switch.port.5.stp.port_mode=enabled +switch.port.5.keepalive=disabled +switch.port.5.opmode=switch +switch.port.5.port-security=disabled +switch.port.6.name=6 +switch.port.6.lldpmed.opmode=enabled +switch.port.6.lldpmed.topology_notify=disabled +switch.port.6.stp.port_mode=enabled +switch.port.6.keepalive=disabled +switch.port.6.opmode=switch +switch.port.6.port-security=disabled +switch.port.7.name=7 +switch.port.7.lldpmed.opmode=enabled +switch.port.7.lldpmed.topology_notify=disabled +switch.port.7.stp.port_mode=enabled +switch.port.7.keepalive=disabled +switch.port.7.opmode=switch +switch.port.7.port-security=disabled +switch.port.8.name=8 +switch.port.8.lldpmed.opmode=enabled +switch.port.8.lldpmed.topology_notify=disabled +switch.port.8.stp.port_mode=enabled +switch.port.8.keepalive=disabled +switch.port.8.opmode=switch +switch.port.8.port-security=disabled +switch.port.9.name=9 +switch.port.9.lldpmed.opmode=enabled +switch.port.9.lldpmed.topology_notify=disabled +switch.port.9.stp.port_mode=enabled +switch.port.9.keepalive=disabled +switch.port.9.opmode=switch +switch.port.9.pvid=8 +switch.port.9.port-security=disabled +switch.vlan.1.port.9.mode=exclude +switch.vlan.2.port.9.mode=exclude +switch.vlan.3.port.9.mode=exclude +switch.vlan.4.port.9.mode=exclude +switch.vlan.5.port.9.mode=exclude +switch.vlan.6.port.9.mode=exclude +switch.vlan.7.port.9.mode=exclude +switch.vlan.8.port.9.mode=untagged +switch.vlan.9.port.9.mode=exclude +switch.vlan.10.port.9.mode=exclude +switch.vlan.11.port.9.mode=exclude +switch.vlan.12.port.9.mode=exclude +switch.vlan.13.port.9.mode=exclude +switch.port.10.name=10 +switch.port.10.lldpmed.opmode=enabled +switch.port.10.lldpmed.topology_notify=disabled +switch.port.10.stp.port_mode=enabled +switch.port.10.keepalive=disabled +switch.port.10.opmode=switch +switch.port.10.pvid=12 +switch.port.10.port-security=disabled +switch.vlan.1.port.10.mode=exclude +switch.vlan.2.port.10.mode=exclude +switch.vlan.3.port.10.mode=exclude +switch.vlan.4.port.10.mode=exclude +switch.vlan.5.port.10.mode=exclude +switch.vlan.6.port.10.mode=exclude +switch.vlan.7.port.10.mode=exclude +switch.vlan.8.port.10.mode=exclude +switch.vlan.9.port.10.mode=exclude +switch.vlan.10.port.10.mode=exclude +switch.vlan.11.port.10.mode=exclude +switch.vlan.12.port.10.mode=untagged +switch.vlan.13.port.10.mode=exclude +switch.port.11.name=11 +switch.port.11.lldpmed.opmode=enabled +switch.port.11.lldpmed.topology_notify=disabled +switch.port.11.stp.port_mode=enabled +switch.port.11.keepalive=disabled +switch.port.11.opmode=switch +switch.port.11.pvid=12 +switch.port.11.port-security=disabled +switch.vlan.1.port.11.mode=exclude +switch.vlan.2.port.11.mode=exclude +switch.vlan.3.port.11.mode=exclude +switch.vlan.4.port.11.mode=exclude +switch.vlan.5.port.11.mode=exclude +switch.vlan.6.port.11.mode=exclude +switch.vlan.7.port.11.mode=exclude +switch.vlan.8.port.11.mode=exclude +switch.vlan.9.port.11.mode=exclude +switch.vlan.10.port.11.mode=exclude +switch.vlan.11.port.11.mode=exclude +switch.vlan.12.port.11.mode=untagged +switch.vlan.13.port.11.mode=exclude +switch.port.12.name=12 +switch.port.12.lldpmed.opmode=enabled +switch.port.12.lldpmed.topology_notify=disabled +switch.port.12.stp.port_mode=enabled +switch.port.12.keepalive=disabled +switch.port.12.opmode=switch +switch.port.12.pvid=6 +switch.port.12.port-security=disabled +switch.vlan.1.port.12.mode=exclude +switch.vlan.2.port.12.mode=exclude +switch.vlan.3.port.12.mode=exclude +switch.vlan.4.port.12.mode=exclude +switch.vlan.5.port.12.mode=exclude +switch.vlan.6.port.12.mode=untagged +switch.vlan.7.port.12.mode=exclude +switch.vlan.8.port.12.mode=exclude +switch.vlan.9.port.12.mode=exclude +switch.vlan.10.port.12.mode=exclude +switch.vlan.11.port.12.mode=exclude +switch.vlan.12.port.12.mode=exclude +switch.vlan.13.port.12.mode=exclude +switch.port.13.name=13 +switch.port.13.lldpmed.opmode=enabled +switch.port.13.lldpmed.topology_notify=disabled +switch.port.13.stp.port_mode=enabled +switch.port.13.keepalive=disabled +switch.port.13.opmode=switch +switch.port.13.pvid=8 +switch.port.13.port-security=disabled +switch.vlan.1.port.13.mode=exclude +switch.vlan.2.port.13.mode=exclude +switch.vlan.3.port.13.mode=exclude +switch.vlan.4.port.13.mode=exclude +switch.vlan.5.port.13.mode=exclude +switch.vlan.6.port.13.mode=exclude +switch.vlan.7.port.13.mode=exclude +switch.vlan.8.port.13.mode=untagged +switch.vlan.9.port.13.mode=exclude +switch.vlan.10.port.13.mode=exclude +switch.vlan.11.port.13.mode=exclude +switch.vlan.12.port.13.mode=exclude +switch.vlan.13.port.13.mode=exclude +switch.port.14.name=14 +switch.port.14.lldpmed.opmode=enabled +switch.port.14.lldpmed.topology_notify=disabled +switch.port.14.stp.port_mode=enabled +switch.port.14.keepalive=disabled +switch.port.14.opmode=switch +switch.port.14.pvid=12 +switch.port.14.port-security=disabled +switch.vlan.1.port.14.mode=exclude +switch.vlan.2.port.14.mode=exclude +switch.vlan.3.port.14.mode=exclude +switch.vlan.4.port.14.mode=exclude +switch.vlan.5.port.14.mode=exclude +switch.vlan.6.port.14.mode=exclude +switch.vlan.7.port.14.mode=exclude +switch.vlan.8.port.14.mode=exclude +switch.vlan.9.port.14.mode=exclude +switch.vlan.10.port.14.mode=exclude +switch.vlan.11.port.14.mode=exclude +switch.vlan.12.port.14.mode=untagged +switch.vlan.13.port.14.mode=exclude +switch.port.15.name=15 +switch.port.15.lldpmed.opmode=enabled +switch.port.15.lldpmed.topology_notify=disabled +switch.port.15.stp.port_mode=enabled +switch.port.15.keepalive=disabled +switch.port.15.opmode=switch +switch.port.15.pvid=6 +switch.port.15.port-security=disabled +switch.vlan.1.port.15.mode=exclude +switch.vlan.2.port.15.mode=exclude +switch.vlan.3.port.15.mode=exclude +switch.vlan.4.port.15.mode=exclude +switch.vlan.5.port.15.mode=exclude +switch.vlan.6.port.15.mode=untagged +switch.vlan.7.port.15.mode=exclude +switch.vlan.8.port.15.mode=exclude +switch.vlan.9.port.15.mode=exclude +switch.vlan.10.port.15.mode=exclude +switch.vlan.11.port.15.mode=exclude +switch.vlan.12.port.15.mode=exclude +switch.vlan.13.port.15.mode=exclude +switch.port.16.name=16 +switch.port.16.lldpmed.opmode=enabled +switch.port.16.lldpmed.topology_notify=disabled +switch.port.16.stp.port_mode=enabled +switch.port.16.keepalive=disabled +switch.port.16.opmode=switch +switch.port.16.pvid=6 +switch.port.16.port-security=disabled +switch.vlan.1.port.16.mode=exclude +switch.vlan.2.port.16.mode=exclude +switch.vlan.3.port.16.mode=exclude +switch.vlan.4.port.16.mode=exclude +switch.vlan.5.port.16.mode=exclude +switch.vlan.6.port.16.mode=untagged +switch.vlan.7.port.16.mode=exclude +switch.vlan.8.port.16.mode=exclude +switch.vlan.9.port.16.mode=exclude +switch.vlan.10.port.16.mode=exclude +switch.vlan.11.port.16.mode=exclude +switch.vlan.12.port.16.mode=exclude +switch.vlan.13.port.16.mode=exclude +switch.port.17.name=17 +switch.port.17.lldpmed.opmode=enabled +switch.port.17.lldpmed.topology_notify=disabled +switch.port.17.stp.port_mode=enabled +switch.port.17.keepalive=disabled +switch.port.17.opmode=switch +switch.port.17.port-security=disabled +switch.port.18.name=18 +switch.port.18.lldpmed.opmode=enabled +switch.port.18.lldpmed.topology_notify=disabled +switch.port.18.stp.port_mode=enabled +switch.port.18.keepalive=disabled +switch.port.18.opmode=switch +switch.port.18.port-security=disabled +switch.port.19.name=19 +switch.port.19.lldpmed.opmode=enabled +switch.port.19.lldpmed.topology_notify=disabled +switch.port.19.stp.port_mode=enabled +switch.port.19.keepalive=disabled +switch.port.19.opmode=switch +switch.port.19.port-security=disabled +switch.port.20.name=20 +switch.port.20.lldpmed.opmode=enabled +switch.port.20.lldpmed.topology_notify=disabled +switch.port.20.stp.port_mode=enabled +switch.port.20.keepalive=disabled +switch.port.20.opmode=switch +switch.port.20.port-security=disabled +switch.port.21.name=21 +switch.port.21.lldpmed.opmode=enabled +switch.port.21.lldpmed.topology_notify=disabled +switch.port.21.stp.port_mode=enabled +switch.port.21.keepalive=disabled +switch.port.21.opmode=switch +switch.port.21.port-security=disabled +switch.port.22.name=22 +switch.port.22.lldpmed.opmode=enabled +switch.port.22.lldpmed.topology_notify=disabled +switch.port.22.stp.port_mode=enabled +switch.port.22.keepalive=disabled +switch.port.22.opmode=switch +switch.port.22.port-security=disabled +switch.port.23.name=23 +switch.port.23.lldpmed.opmode=enabled +switch.port.23.lldpmed.topology_notify=disabled +switch.port.23.stp.port_mode=enabled +switch.port.23.keepalive=disabled +switch.port.23.opmode=switch +switch.port.23.port-security=disabled +switch.port.24.name=24 +switch.port.24.lldpmed.opmode=enabled +switch.port.24.lldpmed.topology_notify=disabled +switch.port.24.stp.port_mode=enabled +switch.port.24.keepalive=disabled +switch.port.24.opmode=switch +switch.port.24.port-security=disabled +switch.port.25.name=SFP 1 +switch.port.25.lldpmed.opmode=enabled +switch.port.25.lldpmed.topology_notify=disabled +switch.port.25.stp.port_mode=enabled +switch.port.25.keepalive=disabled +switch.port.25.opmode=switch +switch.port.25.port-security=disabled +switch.port.26.name=SFP 2 +switch.port.26.lldpmed.opmode=enabled +switch.port.26.lldpmed.topology_notify=disabled +switch.port.26.stp.port_mode=enabled +switch.port.26.keepalive=disabled +switch.port.26.opmode=switch +switch.port.26.port-security=disabled +# syslog +syslog.status=enabled +syslog.level=7 +sshd.status=enabled +sshd.auth.passwd=enabled +sshd.1.status=enabled +sshd.1.ifname=eth0 +# ntpclient +ntpclient.status=enabled +ntpclient.1.status=enabled +ntpclient.1.server=0.pool.ntp.org +ntpclient.2.status=enabled +ntpclient.2.server=1.pool.ntp.org +# misc diff --git a/tests/test_parse_device.py b/tests/test_parse_device.py new file mode 100644 index 0000000..681894a --- /dev/null +++ b/tests/test_parse_device.py @@ -0,0 +1,253 @@ +"""Facts, ports, LLDP, MAC table and PoE from a device record. + +A controller's ``stat/device`` entry and a device's own ``mca-dump`` carry the same +record; each parser is run against both where the fixture allows. +""" + +from __future__ import annotations + +from typing import Any + +import pytest + +from napalm_ubiquiti.parsers.device import ( + MANAGEMENT, + parse_facts, + parse_interfaces, + parse_interfaces_ip, + parse_lldp_rows, + parse_mac_table, + parse_poe, + port_name, +) + + +class TestFacts: + def test_controller_record(self, us16: dict[str, Any]) -> None: + facts = parse_facts(us16) + + assert facts["vendor"] == "Ubiquiti" + assert facts["model"] == "US16P150" + assert facts["hostname"] == "Switch 16" + assert facts["fqdn"] == "Switch 16" + assert facts["os_version"] == "4.0.66.10832" + assert facts["serial_number"] == "FCECDA112233" + assert facts["uptime"] == 3971865.0 + assert facts["interface_list"][:2] == ["Port 1", "Port 2"] + assert facts["interface_list"][-1] == MANAGEMENT + assert len(facts["interface_list"]) == 19 + + def test_mca_dump_prefers_the_product_name_and_upper_cases_the_serial( + self, us24_dump: dict[str, Any] + ) -> None: + facts = parse_facts(us24_dump) + + assert facts["model"] == "US-24-G1" + assert facts["hostname"] == "usw-1" + assert facts["serial_number"] == "64F846000010" + + def test_a_record_without_a_name_uses_its_mac(self) -> None: + facts = parse_facts({"mac": "f4:92:bf:00:00:01", "model": "U6LR", "version": "6.6.55"}) + + assert facts["hostname"] == "f4:92:bf:00:00:01" + assert facts["uptime"] == 0.0 + assert facts["serial_number"] == "" + + +class TestInterfaces: + def test_ports_are_named_by_index_and_keep_their_label(self, us16: dict[str, Any]) -> None: + interfaces = parse_interfaces(us16) + + assert interfaces["Port 1"] == { + "is_up": True, + "is_enabled": True, + "description": "", + "last_flapped": -1.0, + "mtu": 1500, + "speed": 1000.0, + "mac_address": "", + } + assert interfaces["Port 2"]["is_up"] is False + + def test_a_renamed_port_keeps_its_name_as_description(self, uap: dict[str, Any]) -> None: + interfaces = parse_interfaces(uap) + + assert interfaces["Port 1"]["description"] == "Main" + + def test_management_carries_the_device_mac(self, us16: dict[str, Any]) -> None: + mgmt = parse_interfaces(us16)[MANAGEMENT] + + assert mgmt["mac_address"] == "fc:ec:da:11:22:33" + assert mgmt["is_up"] is True + + def test_a_disabled_port_and_jumbo_frames(self, us24_dump: dict[str, Any]) -> None: + record = dict(us24_dump) + record["port_table"] = [dict(us24_dump["port_table"][0], jumbo=True)] + + port = parse_interfaces(record)["Port 1"] + + assert port["is_enabled"] is False + assert port["mtu"] == 9216 + + def test_a_port_without_an_index_is_left_out(self) -> None: + record = {"mac": "78:8a:20:33:44:55", "port_table": [{"name": "wan", "up": True}]} + + assert list(parse_interfaces(record)) == [MANAGEMENT] + + def test_port_name(self) -> None: + assert port_name(7) == "Port 7" + + +class TestInterfacesIp: + def test_controller_record_takes_the_netmask_of_its_uplink(self, us16: dict[str, Any]) -> None: + assert parse_interfaces_ip(us16) == { + MANAGEMENT: {"ipv4": {"192.168.0.57": {"prefix_length": 24}}} + } + + def test_mca_dump_has_its_own_netmask(self, us24_dump: dict[str, Any]) -> None: + assert parse_interfaces_ip(us24_dump) == { + MANAGEMENT: {"ipv4": {"10.0.0.10": {"prefix_length": 24}}} + } + + def test_no_address_no_entry(self) -> None: + assert parse_interfaces_ip({"mac": "f4:92:bf:00:00:01"}) == {} + + def test_an_unusable_netmask_leaves_32(self) -> None: + record = {"ip": "192.0.2.5", "uplink": {"netmask": "0.0.0.0"}} + + assert parse_interfaces_ip(record) == { + MANAGEMENT: {"ipv4": {"192.0.2.5": {"prefix_length": 32}}} + } + + +class TestLldp: + def test_old_firmware_lists_neighbours_per_port(self, us8: dict[str, Any]) -> None: + rows = parse_lldp_rows(us8) + + assert [(r["local_port"], r["system_name"], r["port_id"]) for r in rows] == [ + ("Port 2", "USG", "eth1"), + ("Port 5", "Switch16", "0/1"), + ("Port 6", "UAPACPRO", "80:2A:A8:55:44:33"), + ] + + def test_a_chassis_id_that_is_a_mac_is_typed_and_lower_cased(self, us8: dict[str, Any]) -> None: + row = parse_lldp_rows(us8)[1] + + assert row["chassis_id"] == "fc:ec:da:33:22:44" + assert row["chassis_id_type"] == "mac" + + def test_a_chassis_id_that_is_no_mac_stays_as_sent(self, us16: dict[str, Any]) -> None: + """The anonymised fixture carries a seven-octet id: not a MAC, kept verbatim.""" + row = parse_lldp_rows(us16)[0] + + assert row["chassis_id"] == "F0:9F:C2:1A:2B:3C:4E" + assert row["chassis_id_type"] == "local" + + def test_new_firmware_lists_them_at_the_top(self, us24_dump: dict[str, Any]) -> None: + rows = parse_lldp_rows(us24_dump) + + assert rows == [ + { + "local_port": "Port 22", + "chassis_id": "f0:9f:c2:00:00:01", + "chassis_id_type": "mac", + "port_id": "Port 1", + "port_id_type": "local", + "port_description": "", + "system_name": "", + "system_description": "", + "management_addresses": [], + "capabilities": [], + "enabled_capabilities": [], + } + ] + + def test_both_shapes_of_one_neighbour_count_once(self, usmini: dict[str, Any]) -> None: + record = dict(usmini) + record["port_table"] = [ + dict( + usmini["port_table"][0], + lldp_table=[{"lldp_chassis_id": "FC:EC:00:11:22:33", "lldp_port_id": "Port ", "lldp_system_name": "sw"}], + ) + ] + + rows = parse_lldp_rows(record) + + assert len(rows) == 1 + assert rows[0]["system_name"] == "sw" + + def test_no_table_no_rows(self) -> None: + assert parse_lldp_rows({"port_table": [{"port_idx": 1}]}) == [] + + +class TestMacTable: + def test_mca_dump_lists_what_each_port_learned(self, us24_dump: dict[str, Any]) -> None: + table = parse_mac_table(us24_dump) + + assert len(table) == 12 + first = table[0] + assert first["mac"] == "02:00:00:00:00:02" + assert first["vlan"] == 8 + assert first["interface"].startswith("Port ") + assert first["static"] is False + assert first["active"] is True + assert first["moves"] == 0 + assert first["last_move"] == -1.0 + + def test_a_controller_record_without_tables_is_empty(self, us16: dict[str, Any]) -> None: + assert parse_mac_table(us16) == [] + + +class TestPoe: + def test_controller_record(self, us16: dict[str, Any]) -> None: + poe = parse_poe(us16) + + assert poe["total_power_budget"] == 135.0 + assert len(poe["ports"]) == 16 + assert poe["ports"]["Port 1"] == { + "enabled": True, + "status": "searching", + "poe_class": "unknown", + "power_draw": 0.0, + "power_budget": 0.0, + "voltage": 0.0, + "current": 0.0, + } + + @pytest.mark.parametrize( + ("port", "status"), + [ + ({"poe_mode": "off"}, "disabled"), + ({"poe_mode": "auto", "poe_good": True, "poe_power": "4.30"}, "delivering"), + ({"poe_mode": "pasv24", "poe_good": True}, "delivering"), + ({"poe_mode": "auto", "poe_good": False}, "searching"), + ], + ) + def test_status(self, port: dict[str, Any], status: str) -> None: + record = {"port_table": [dict(port, port_idx=1, port_poe=True)]} + + assert parse_poe(record)["ports"]["Port 1"]["status"] == status + + def test_drawn_power_adds_up(self) -> None: + record = { + "total_max_power": 60, + "port_table": [ + {"port_idx": 1, "port_poe": True, "poe_mode": "auto", "poe_good": True, "poe_power": "4.30", "poe_class": "Class 2", "poe_voltage": "53.10", "poe_current": "81.00"}, + {"port_idx": 2, "port_poe": True, "poe_mode": "auto", "poe_good": True, "poe_power": "2.20"}, + {"port_idx": 3, "port_poe": False}, + ], + } + + poe = parse_poe(record) + + assert poe["total_power_draw"] == pytest.approx(6.5) + assert poe["ports"]["Port 1"]["poe_class"] == "Class 2" + assert poe["ports"]["Port 1"]["current"] == 81.0 + assert set(poe["ports"]) == {"Port 1", "Port 2"} + + def test_unreadable_numbers_read_as_zero(self, us8: dict[str, Any]) -> None: + port = parse_poe(us8)["ports"]["Port 8"] + + assert port["power_draw"] == 0.0 + assert port["voltage"] == 48.0 + assert port["poe_class"] == "unknown" diff --git a/tests/test_sanitize.py b/tests/test_sanitize.py new file mode 100644 index 0000000..98b6db2 --- /dev/null +++ b/tests/test_sanitize.py @@ -0,0 +1,53 @@ +"""The fixture sanitiser: no secret of a recorded device reaches the repository.""" + +from __future__ import annotations + +import json +import pathlib +import sys + +sys.path.insert(0, str(pathlib.Path(__file__).parents[1] / "tools")) + +from sanitize import REDACTED, anonymise_macs, redact, redact_cfg, sanitize # noqa: E402 + + +def test_controller_keys_are_redacted_at_any_depth() -> None: + record = {"x_authkey": "abc", "vap_table": [{"x_passphrase": "pw", "essid": "Lab"}]} + + assert redact(record) == {"x_authkey": REDACTED, "vap_table": [{"x_passphrase": REDACTED, "essid": "Lab"}]} + + +def test_device_tokens_are_redacted() -> None: + assert redact({"guest_token": "t", "anon_id": "a", "model": "US24"}) == { + "guest_token": REDACTED, + "anon_id": REDACTED, + "model": "US24", + } + + +def test_running_cfg_secret_lines_are_redacted() -> None: + text = "unifi.key=55da\nusers.1.password=x\nswitch.port.2.pvid=11\n# comment\n" + + assert redact_cfg(text) == "unifi.key=REDACTED\nusers.1.password=REDACTED\nswitch.port.2.pvid=11\n# comment\n" + + +def test_replacements_apply_after_redaction_in_both_formats() -> None: + cfg = sanitize("resolv.host.1.name=usw-real\n", {"usw-real": "usw-1"}) + data = json.loads(sanitize('{"mac": "64:f8:46:45:57:f0"}', {"45:57:f0": "00:00:10"})) + + assert cfg == "resolv.host.1.name=usw-1\n" + assert data == {"mac": "64:f8:46:00:00:10"} + + +def test_other_macs_map_consistently_to_local_ones() -> None: + text = "aa:bb:cc:00:00:01 AA:BB:CC:00:00:01 f0:9f:c2:00:00:01 aa:bb:cc:00:00:02" + + out = anonymise_macs(text, keep={"f0:9f:c2:00:00:01"}) + + assert out == "02:00:00:00:00:01 02:00:00:00:00:01 f0:9f:c2:00:00:01 02:00:00:00:00:02" + + +def test_sanitize_keeps_the_replaced_macs() -> None: + out = sanitize('{"a": "64:f8:46:45:57:f0", "b": "1c:a8:46:7b:2f:55"}', {"64:f8:46:45:57:f0": "64:f8:46:00:00:10"}, macs=True) + + assert json.loads(out) == {"a": "64:f8:46:00:00:10", "b": "02:00:00:00:00:01"} diff --git a/tools/sanitize.py b/tools/sanitize.py new file mode 100644 index 0000000..df9e92b --- /dev/null +++ b/tools/sanitize.py @@ -0,0 +1,101 @@ +"""Anonymise recorded UniFi output before it becomes a test fixture. + + python tools/sanitize.py IN OUT [--replace OLD=NEW ...] + +JSON input (controller responses, ``mca-dump``): every value under a secret key is +replaced -- the ``x_*`` keys a controller keeps (authkeys, passphrases, SSH host key +fingerprints) and the tokens a device carries. ``running.cfg`` input: the value of +every line whose key names a key, password or token. ``--replace`` swaps a string +everywhere, in the same way in every file, so that a MAC address or serial stays +consistent between the fixtures that mention it. ``--macs`` then maps every other +MAC address to a locally administered one (``02:00:00:00:..``), the same input to +the same output. +""" + +from __future__ import annotations + +import argparse +import json +import pathlib +import re +from typing import Any + +REDACTED = "REDACTED" +SECRET_KEYS = frozenset( + {"guest_token", "syslog_key", "anon_id", "hash_id", "stream_token", "x_passphrase"} +) +MAC = re.compile(r"\b[0-9a-f]{2}(?::[0-9a-f]{2}){5}\b", re.IGNORECASE) +KEEP_PREFIX = "02:00:00:00:" +CFG_SECRET = re.compile(r"(?:^|\.)(key|password|authkey|token|passphrase|x_[a-z_]+)$") + + +def _is_secret(key: str) -> bool: + return key.startswith("x_") or key in SECRET_KEYS + + +def redact(value: Any) -> Any: + """*value* with every secret key's value replaced, at any depth.""" + if isinstance(value, dict): + return {k: (REDACTED if _is_secret(k) else redact(v)) for k, v in value.items()} + if isinstance(value, list): + return [redact(item) for item in value] + return value + + +def redact_cfg(text: str) -> str: + """A ``running.cfg`` with the value of every secret line replaced.""" + lines = [] + for line in text.splitlines(): + key, sep, _ = line.partition("=") + lines.append(f"{key}={REDACTED}" if sep and CFG_SECRET.search(key) else line) + return "\n".join(lines) + "\n" + + +def anonymise_macs(text: str, keep: set[str]) -> str: + """Every MAC address in *text* not in *keep* mapped to a locally administered one.""" + mapping: dict[str, str] = {} + + def _swap(match: re.Match[str]) -> str: + mac = match.group(0).lower() + if mac in keep or mac.startswith(KEEP_PREFIX): + return match.group(0) + if mac not in mapping: + n = len(mapping) + 1 + mapping[mac] = f"{KEEP_PREFIX}{n >> 8:02x}:{n & 0xFF:02x}" + return mapping[mac] + + return MAC.sub(_swap, text) + + +def sanitize( + text: str, replacements: dict[str, str], *, macs: bool = False +) -> str: + """*text* redacted (JSON or ``running.cfg``), then with *replacements* applied. + + With *macs*, every MAC address the replacements did not set is anonymised. + """ + try: + out = json.dumps(redact(json.loads(text)), indent=1, sort_keys=True) + "\n" + except json.JSONDecodeError: + out = redact_cfg(text) + for old, new in replacements.items(): + out = out.replace(old, new) + if macs: + out = anonymise_macs(out, {new.lower() for new in replacements.values()}) + return out + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("source", type=pathlib.Path) + parser.add_argument("target", type=pathlib.Path) + parser.add_argument("--replace", action="append", default=[], metavar="OLD=NEW") + parser.add_argument("--macs", action="store_true", help="anonymise every other MAC") + args = parser.parse_args() + replacements = dict(item.split("=", 1) for item in args.replace) + text = sanitize(args.source.read_text(), replacements, macs=args.macs) + args.target.write_text(text) + + +if __name__ == "__main__": + main()