fix(snmp): open the REST side session's SSH on port 22

configure_snmp_agent over the REST API opened its temporary SSH session
on optional_args["port"], which names the REST API's port when REST is
the transport. It now uses port 22, as the running-config fallback
already did.

The second finding of the issue, the unverified REST certificate, needs
a decision and stays open.

Refs #17
This commit is contained in:
Christian Manivong committed 2026-11-01 21:44:52 +01:00
1 parent 58428042f1
commit 874e25a1ce
3 files changed
+24 -6

No files matched your search

+5 -5
View File
@@ -79,6 +79,7 @@ _SSH_DISABLED_LEGACY = {
}
_SSH_PORT_BESIDE_API = 22 # SSH beside the REST API: ``port`` then is the API's (#17)
#: What may stand in a quoted CLI value: no whitespace, quote or #.
_CLI_WORD = re.compile(r'^[^\s"#]+$')
@@ -663,11 +664,10 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver):
HP ProCurve switches do not support exec_channel SSH; they require
an interactive shell (invoke_shell), which netmiko's hp_procurve
device type handles correctly. Port 22 is used explicitly because
self.port is the REST API port (443) in API transport mode.
device type handles correctly. Port 22: ``port`` is the REST API's.
"""
try:
conn = self._ssh_connect(port=22) # always SSH — self.port is the REST API port
conn = self._ssh_connect(port=_SSH_PORT_BESIDE_API)
try:
return conn.send_command("show running-config")
finally:
@@ -1254,7 +1254,7 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver):
"""The agent is built in; configure community, contact and location, then save.
The REST API has no writable SNMP endpoint, so over REST a temporary SSH
session runs the config-mode CLI.
session on port 22 runs the config-mode CLI.
"""
steps = [
("install", lambda: {"ok": True, "output": "the SNMP agent is built in"}),
@@ -1269,7 +1269,7 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver):
ssh_error = ""
for legacy in (False, True):
try:
self._device = self._ssh_connect(legacy)
self._device = self._ssh_connect(legacy, port=_SSH_PORT_BESIDE_API)
self._transport = "ssh_legacy" if legacy else "ssh"
break
except SshHostKeyMismatch as exc: # the same host either way