fix(plus): stop reporting unread or failed reads as empty
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 15s
driver / types (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m17s
driver / test (3.13) (pull_request) Successful in 1m13s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m16s
CI / driver (pull_request) Successful in 3m7s
driver / publish (pull_request) Skipped

Netgear Plus answered reads its web interface cannot do (MAC table,
LLDP, config, users, SNMP, NTP) with empty values without asking the
switch; those now fall through to NAPALM's NotImplementedError, and the
switch-role getters that only returned {} (spanning tree, port channels,
802.1X, MAC ACL) are gone, as device-types reads capability from the
method being there. get_vlans_detail raises when vlan.cgi cannot be
read, get_vlans keys VLANs by int, and Smart get_snmp_config raises when
show snmp fails instead of reading as "no SNMP".

Closes #21
This commit is contained in:
Christian Manivong committed 2026-11-02 09:22:22 +01:00
1 parent 411fed5532
commit 7e3c7d6285
6 files changed
+169 -137

No files matched your search

+16 -114
View File
@@ -396,14 +396,6 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver):
"memory": {},
}
def get_mac_address_table(self) -> list[dict]:
"""Return the MAC address table.
Not available via the HTTP web interface of Plus switches.
Returns an empty list.
"""
return []
def get_arp_table(self, vrf: str = "") -> list[dict]:
"""Return the ARP table.
@@ -412,22 +404,6 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver):
"""
return []
def get_lldp_neighbors(self) -> dict[str, Any]:
"""Return LLDP neighbors.
Not supported on Netgear Plus switches.
Returns an empty dict.
"""
return {}
def get_lldp_neighbors_detail(self, interface: str = "") -> dict[str, Any]:
"""Return detailed LLDP neighbor info.
Not supported on Netgear Plus switches.
Returns an empty dict.
"""
return {}
def get_vlans_detail(self) -> dict[str, Any]:
"""Return VLAN configuration by scraping the switch's /vlan.cgi page.
@@ -440,16 +416,7 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver):
"""
import re
url = f"http://{self.hostname}/vlan.cgi"
try:
resp = self._connector.fetch_page("get", url, {})
except Exception:
return {}
if not resp or resp.status_code != 200 or not resp.text:
return {}
text = resp.text
text = self._fetch_vlan_page()
# Parse VLAN IDs and names from vid-4 / vnm-4 span pairs.
# Example: <span vid-4>...<i ...></i>24</span><span vnm-4 ...>Guest</span>
@@ -496,7 +463,19 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver):
return vlans
def get_vlans(self) -> dict[str, Any]:
def _fetch_vlan_page(self) -> str:
"""The text of ``vlan.cgi``; a failed fetch or an answer that is no page raises (#21)."""
url = f"http://{self.hostname}/vlan.cgi"
try:
resp = self._connector.fetch_page("get", url, {})
except Exception as exc: # py-netgear-plus passes on whatever its request raised
raise ConnectionException(f"Cannot read {url}: {exc}") from exc
if not resp or resp.status_code != 200 or not resp.text:
status = getattr(resp, "status_code", None)
raise RuntimeError(f"{url} answered with no VLAN page (HTTP {status})")
return str(resp.text)
def get_vlans(self) -> dict[int, Any]:
"""Return VLAN information (standard NAPALM format).
Delegates to get_vlans_detail() and merges tagged and untagged ports
@@ -504,27 +483,13 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver):
"""
detail = self.get_vlans_detail()
return {
vid: {
int(vid): {
"name": info["name"],
"interfaces": info["tagged"] + info["untagged"],
}
for vid, info in detail.items()
}
def get_config(
self,
retrieve: str = "all",
full: bool = False,
sanitized: bool = False,
format: str = "text",
) -> dict[str, str]:
"""Return device configuration.
Netgear Plus switches do not expose running/startup config via HTTP.
Returns empty strings for all config slots.
"""
return {"running": "", "startup": "", "candidate": ""}
def load_merge_candidate(self, filename: str | None = None, config: str | None = None) -> None:
raise NotImplementedError("Config management is not supported for Netgear Plus switches.")
@@ -571,73 +536,10 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver):
"cli() is not supported for Netgear Plus switches (HTTP-only device)."
)
def get_users(self) -> dict[str, Any]:
"""Return user accounts.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_snmp_information(self) -> dict[str, Any]:
"""Return SNMP configuration.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_ntp_servers(self) -> dict[str, Any]:
"""Return configured NTP servers.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_ntp_peers(self) -> dict[str, Any]:
"""Return NTP peers.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_ntp_stats(self) -> list[dict]:
"""Return NTP stats.
Not available via HTTP API. Returns an empty list.
"""
return []
# ------------------------------------------------------------------
# SwitchDriver abstract methods (not applicable for this device)
# PoE
# ------------------------------------------------------------------
def get_spanning_tree(self) -> dict[str, Any]:
"""Return spanning tree status.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_port_channels(self) -> dict[str, Any]:
"""Return port-channel information.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_dot1x_ports(self) -> dict[str, Any]:
"""Return 802.1X port configuration.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_mac_acl(self) -> dict[str, Any]:
"""Return MAC ACL information.
Not available via HTTP API. Returns an empty dict.
"""
return {}
def get_poe_status(self) -> dict[str, Any]:
"""Return PoE status.
+1 -5
View File
@@ -1847,11 +1847,7 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
except ImportError:
return None
try:
out = self._send_command("show snmp")
except Exception:
return None
out = self._send_command("show snmp") # a failed read raises (#21)
if not out:
return None