fix(snmp): read the community from the Name column
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 12s
driver / types (pull_request) Successful in 59s
driver / test (3.12) (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 50s
driver / lowest (pull_request) Successful in 24s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m26s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 12s
driver / types (pull_request) Successful in 59s
driver / test (3.12) (pull_request) Successful in 58s
driver / test (3.13) (pull_request) Successful in 50s
driver / lowest (pull_request) Successful in 24s
driver / build (pull_request) Successful in 26s
driver / security (pull_request) Successful in 1m2s
CI / driver (pull_request) Successful in 2m26s
driver / publish (pull_request) Skipped
The switch's community table starts with an Index column, and get_snmp_config took a row's first word, so it reported the community as "1". The name now comes from the column headed Name, found in the header line above the dashes; the tests read the recorded table. Found while recording fixtures for #3.
This commit is contained in:
1 parent
34f00f9f3a
commit
8e7be0e47e
6 files changed
+55
-22
No files matched your search
@@ -39,6 +39,7 @@ from netmiko import ConnectHandler
|
||||
from netmiko.exceptions import NetmikoAuthenticationException, NetmikoTimeoutException
|
||||
|
||||
from napalm_tplink_jetstream._ssh import netmiko_connect_args
|
||||
from napalm_tplink_jetstream.parsers import parse_snmp_communities
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -1939,22 +1940,10 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
|
||||
if not out or "disabled" in out.lower() or "no community entry exists" in out.lower():
|
||||
return no_agent
|
||||
|
||||
community = None
|
||||
in_table = False
|
||||
for line in out.splitlines():
|
||||
line_s = line.strip()
|
||||
if re.match(r"^-{4,}", line_s):
|
||||
in_table = True
|
||||
continue
|
||||
if not in_table or not line_s:
|
||||
continue
|
||||
parts = line_s.split()
|
||||
if len(parts) >= 2:
|
||||
community = parts[0]
|
||||
break
|
||||
if community is None:
|
||||
communities = parse_snmp_communities(out)
|
||||
if not communities:
|
||||
return no_agent
|
||||
return SNMPConfigDict(running=True, community=community, port=161, version="2c")
|
||||
return SNMPConfigDict(running=True, community=communities[0], port=161, version="2c")
|
||||
|
||||
def get_device_warnings(self) -> list:
|
||||
"""Return device warnings. Currently delegates to SNMP detection only."""
|
||||
|
||||
Reference in new issue
Block a user