fix(config): read what retrieve asks in the REST-to-SSH fallback #26

Merged
christianmanivong merged 1 commits from fix/bugs-2026-11-02b into main 2026-11-02 08:42:36 +00:00
Owner

What

get_config over the REST transport, on a switch whose REST API has no configuration (2530 / YA series), reads over SSH what retrieve asks for.

  • The SSH transport's reading moves into _read_config(retrieve): running and/or startup as asked (show config where show startup-config is unknown), a part not asked for is "".
  • _get_config_via_ssh(retrieve) opens its temporary SSH session on port 22, runs _read_config through it and restores the driver's own session afterwards. It returns the config dict instead of the running text. A part that cannot be read raises ConnectionException; a changed host key keeps its own type.

Why

The fallback read the running config only, whatever was asked, and returned an empty startup config: a retrieve="startup" call got the running config read and an empty startup.

Tests

Fixtures only (no device). tests/unit/test_config_ssh_fallback.py: REST answering 404 plus a stub SSH session; retrieve="all" returns both configs, running/startup send only their command, the show config alternative, a failed startup read raises, the SSH session is closed and not left as the driver's session. Four of them failed before the change. Two existing tests' SSH mocks got a prompt, and the host-key test reads ["running"] from the new return value.

pytest 155 passed, ruff format/check clean, mypy clean, napalm-standard check passes, napalm-standard ratchet within the baseline (procurve.py 1385→1383 lines).

Closes #25

## What `get_config` over the REST transport, on a switch whose REST API has no configuration (2530 / YA series), reads over SSH what `retrieve` asks for. - The SSH transport's reading moves into `_read_config(retrieve)`: running and/or startup as asked (`show config` where `show startup-config` is unknown), a part not asked for is `""`. - `_get_config_via_ssh(retrieve)` opens its temporary SSH session on port 22, runs `_read_config` through it and restores the driver's own session afterwards. It returns the config dict instead of the running text. A part that cannot be read raises `ConnectionException`; a changed host key keeps its own type. ## Why The fallback read the running config only, whatever was asked, and returned an empty startup config: a `retrieve="startup"` call got the running config read and an empty startup. ## Tests Fixtures only (no device). `tests/unit/test_config_ssh_fallback.py`: REST answering 404 plus a stub SSH session; `retrieve="all"` returns both configs, `running`/`startup` send only their command, the `show config` alternative, a failed startup read raises, the SSH session is closed and not left as the driver's session. Four of them failed before the change. Two existing tests' SSH mocks got a prompt, and the host-key test reads `["running"]` from the new return value. pytest 155 passed, ruff format/check clean, mypy clean, `napalm-standard check` passes, `napalm-standard ratchet` within the baseline (`procurve.py` 1385→1383 lines). Closes #25
christianmanivong added 1 commit 2026-11-02 08:15:15 +00:00
fix(config): read what retrieve asks in the REST-to-SSH fallback
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 25s
driver / types (pull_request) Successful in 1m15s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 1m4s
driver / lowest (pull_request) Successful in 29s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m9s
CI / driver (pull_request) Successful in 2m54s
driver / publish (pull_request) Skipped
e0ff997d1b
A switch whose REST API has no configuration is read over a temporary
SSH session. That path read the running config only, whatever retrieve
asked for, and returned an empty startup config. It now reads through
the same code as the SSH transport: running and/or startup as asked,
"show config" where "show startup-config" is unknown, and a part that
could not be read raises.

Closes #25
christianmanivong merged commit bb8b3a7182 into main 2026-11-02 08:42:36 +00:00
christianmanivong deleted branch fix/bugs-2026-11-02b 2026-11-02 08:42:36 +00:00
Sign in to join this conversation.