fix(snmp): report no community instead of inventing "public"
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 56s
driver / test (3.12) (pull_request) Successful in 57s
driver / test (3.13) (pull_request) Successful in 51s
driver / lowest (pull_request) Successful in 25s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m28s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 56s
driver / test (3.12) (pull_request) Successful in 57s
driver / test (3.13) (pull_request) Successful in 51s
driver / lowest (pull_request) Successful in 25s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m28s
driver / publish (pull_request) Skipped
get_snmp_config started from community "public" and returned it with running=True when no row of the community table parsed. Without a listed community it now reports the agent as not running, as it already did for "no community entry exists". The issue's other two points were already fixed on main: the management VLAN is matched exactly sincec2f0f7c(_management_vlan, with the caller's listen address), and the floor on napalm-device-types is 4.21.1 with no requirements.txt since4e171bf. Closes #3
This commit is contained in:
1 parent
f515859472
commit
34f00f9f3a
4 files changed
+55
-16
No files matched your search
@@ -33,7 +33,7 @@ from napalm.base.exceptions import (
|
||||
ReplaceConfigException,
|
||||
)
|
||||
from napalm_device_types import ConfigLifecycleMixin, FingerprintRule, SnmpAgentMixin, SwitchDriver
|
||||
from napalm_device_types.models import InterfaceConfigDict, VlanConfigDict
|
||||
from napalm_device_types.models import InterfaceConfigDict, SNMPConfigDict, VlanConfigDict
|
||||
from napalm_device_types.ssh_host_keys import HostKeyCheck, SshHostKeyMismatch
|
||||
from netmiko import ConnectHandler
|
||||
from netmiko.exceptions import NetmikoAuthenticationException, NetmikoTimeoutException
|
||||
@@ -1927,23 +1927,19 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
|
||||
|
||||
# ── SNMP / Health ──────────────────────────────────────────────────────────
|
||||
|
||||
def get_snmp_config(self):
|
||||
def get_snmp_config(self) -> SNMPConfigDict:
|
||||
"""Return SNMP agent config if SNMP is enabled on the switch.
|
||||
|
||||
TP-Link JetStream switches have SNMP built-in — no daemon to install.
|
||||
Reads community from 'show snmp community'.
|
||||
Reads community from 'show snmp community'; without a listed one the agent
|
||||
does not run (#3).
|
||||
"""
|
||||
try:
|
||||
from napalm_device_types.models import SNMPConfigDict
|
||||
except ImportError:
|
||||
return None
|
||||
|
||||
no_agent = SNMPConfigDict(running=False, community="", port=161, version="2c")
|
||||
out = self._send_command("show snmp community")
|
||||
if not out or "disabled" in out.lower() or "no community entry exists" in out.lower():
|
||||
return SNMPConfigDict(running=False, community="", port=161, version="2c")
|
||||
return no_agent
|
||||
|
||||
# Parse first read-only community
|
||||
community = "public"
|
||||
community = None
|
||||
in_table = False
|
||||
for line in out.splitlines():
|
||||
line_s = line.strip()
|
||||
@@ -1956,7 +1952,8 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
|
||||
if len(parts) >= 2:
|
||||
community = parts[0]
|
||||
break
|
||||
|
||||
if community is None:
|
||||
return no_agent
|
||||
return SNMPConfigDict(running=True, community=community, port=161, version="2c")
|
||||
|
||||
def get_device_warnings(self) -> list:
|
||||
|
||||
Reference in new issue
Block a user