No files matched your search
@@ -14,6 +14,11 @@ All notable changes to this driver. The format follows
|
|||||||
- The floor on urllib3 is 1.26.5: older releases bundle a `six` that Python 3.12
|
- The floor on urllib3 is 1.26.5: older releases bundle a `six` that Python 3.12
|
||||||
cannot import.
|
cannot import.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `configure_snmp_agent` over the REST API opens its temporary SSH session on port 22.
|
||||||
|
It used `optional_args["port"]`, which names the REST API's port when REST is the
|
||||||
|
transport, so the SNMP setup failed on switches managed over REST.
|
||||||
|
|
||||||
## [0.6.0] - 2026-10-23
|
## [0.6.0] - 2026-10-23
|
||||||
|
|
||||||
The first release on PyPI.
|
The first release on PyPI.
|
||||||
|
|||||||
@@ -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 #.
|
#: What may stand in a quoted CLI value: no whitespace, quote or #.
|
||||||
_CLI_WORD = re.compile(r'^[^\s"#]+$')
|
_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
|
HP ProCurve switches do not support exec_channel SSH; they require
|
||||||
an interactive shell (invoke_shell), which netmiko's hp_procurve
|
an interactive shell (invoke_shell), which netmiko's hp_procurve
|
||||||
device type handles correctly. Port 22 is used explicitly because
|
device type handles correctly. Port 22: ``port`` is the REST API's.
|
||||||
self.port is the REST API port (443) in API transport mode.
|
|
||||||
"""
|
"""
|
||||||
try:
|
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:
|
try:
|
||||||
return conn.send_command("show running-config")
|
return conn.send_command("show running-config")
|
||||||
finally:
|
finally:
|
||||||
@@ -1254,7 +1254,7 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver):
|
|||||||
"""The agent is built in; configure community, contact and location, then save.
|
"""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
|
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 = [
|
steps = [
|
||||||
("install", lambda: {"ok": True, "output": "the SNMP agent is built in"}),
|
("install", lambda: {"ok": True, "output": "the SNMP agent is built in"}),
|
||||||
@@ -1269,7 +1269,7 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver):
|
|||||||
ssh_error = ""
|
ssh_error = ""
|
||||||
for legacy in (False, True):
|
for legacy in (False, True):
|
||||||
try:
|
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"
|
self._transport = "ssh_legacy" if legacy else "ssh"
|
||||||
break
|
break
|
||||||
except SshHostKeyMismatch as exc: # the same host either way
|
except SshHostKeyMismatch as exc: # the same host either way
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ def test_the_config_fallback_checks_the_key_of_port_22():
|
|||||||
|
|
||||||
def test_the_snmp_fix_over_rest_stops_at_a_changed_key():
|
def test_the_snmp_fix_over_rest_stops_at_a_changed_key():
|
||||||
seen: list = []
|
seen: list = []
|
||||||
driver = _driver(seen, {"443": SshHostKey.of(OTHER_KEY).as_dict()}, port=443)
|
driver = _driver(seen, {"22": SshHostKey.of(OTHER_KEY).as_dict()}, port=443)
|
||||||
driver._transport = "api"
|
driver._transport = "api"
|
||||||
driver._api = MagicMock()
|
driver._api = MagicMock()
|
||||||
with patch(HANDLER, side_effect=_refuse) as handler:
|
with patch(HANDLER, side_effect=_refuse) as handler:
|
||||||
@@ -112,3 +112,16 @@ def test_the_snmp_fix_over_rest_stops_at_a_changed_key():
|
|||||||
assert result["success"] is False
|
assert result["success"] is False
|
||||||
assert handler.call_count == 1
|
assert handler.call_count == 1
|
||||||
assert "host key" in str(result)
|
assert "host key" in str(result)
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_snmp_fix_over_rest_opens_ssh_on_port_22_not_the_api_port():
|
||||||
|
"""``port`` is the REST API's port when REST is the transport (#17)."""
|
||||||
|
seen: list = []
|
||||||
|
driver = _driver(seen, {"22": SshHostKey.of(SERVER_KEY).as_dict()}, port=443)
|
||||||
|
driver._transport = "api"
|
||||||
|
driver._api = MagicMock()
|
||||||
|
with patch(HANDLER, return_value=_device()) as handler:
|
||||||
|
driver.configure_snmp_agent({"community": "c0mm", "allowed_sources": []})
|
||||||
|
assert handler.call_args.kwargs["port"] == 22
|
||||||
|
assert handler.call_args.kwargs["ssh_strict"] is True
|
||||||
|
assert (seen[0]["port"], seen[0]["accepted"]) == (22, True)
|
||||||
Reference in new issue
Block a user