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).
## 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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
get_configover the REST transport, on a switch whose REST API has no configuration (2530 / YA series), reads over SSH whatretrieveasks for._read_config(retrieve): running and/or startup as asked (show configwhereshow startup-configis unknown), a part not asked for is""._get_config_via_ssh(retrieve)opens its temporary SSH session on port 22, runs_read_configthrough 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 raisesConnectionException; 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/startupsend only their command, theshow configalternative, 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 checkpasses,napalm-standard ratchetwithin the baseline (procurve.py1385→1383 lines).Closes #25