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
ProcurveApiClient.get() answered {} for a timeout, a refused session or
any HTTP error, so every REST getter reported a failed read as a switch
with no hostname, ports, VLANs or neighbours. get() now raises
ConnectionException (no answer, 401/403) or RuntimeError (other
non-2xx, a body that is not JSON); the getters that expect a resource
to be missing on some firmware pass missing_ok for its 404.
get_config no longer returns an empty configuration when both the REST
read and the SSH fallback failed, and cli() over REST raises instead of
returning "Error: HTTP <status>" as the command's output.
Closes#22
The REST login now checks the certificate before it posts the password
(#17) and then tells a web page from a refused login (#13); the two
login-answer checks moved into _require_login so connect() stays within
the function-length limit. #13's REST tests stand in for the switch's
certificate, since connect() fetches it before the login.
The probe falls back to HTTP when HTTPS does not answer. For a switch
known by its certificate that is a downgrade anyone who blocks port 443
can force: the login would go out in clear text, unchecked. With a
pinned fingerprint the REST API is skipped then and the CLI transports
are tried; without one, plain HTTP is used as before.
Refs #17
The REST login never verified the switch in practice: with ssl_verify
off nothing was checked, and with it on a self-signed certificate (the
one every ProCurve ships) failed the CA check and the login was retried
with verification off. Either way the password went to whatever answered
on port 443.
The certificate is now checked by its SHA-256 fingerprint, trust on
first use (napalm-device-types tls_certificates): the caller passes the
fingerprint to expect in optional_args["tls_fingerprints"] and receives
every one seen through optional_args["tls_certificate_observer"]. A
different certificate ends open() with TlsCertificateMismatch before the
password is sent, without trying SSH or Telnet, which would reach the
same host with the same password. The session is pinned to the checked
certificate for every later connection. ssl_verify no longer has an
effect, and the unverified retry is gone.
Closes#17
Over the REST API, cli() returned the /cli endpoint's
result_base64_encoded field as it came: base64 instead of the command's
output. It now decodes it and drops the NUL byte the switch ends it with,
in the same parser the SNMP read over REST uses.
New finding, confirmed by the show snmp-server answer recorded from a
ProCurve switch; no issue filed.
get_snmp_config sent "show snmp-server" through the CLI session, which
does not exist on the REST transport, and returned None, so every switch
managed over REST read as "SNMP not configured". Over REST the command
now runs through the API's /cli endpoint and the output goes through the
parser the SSH path uses. A failed REST read raises.
Closes#10
A switch whose Telnet sessions were all taken, and a REST API answering
the login with the web UI's HTML page, were both reported as an
authentication failure, which sent the operator after the password. The
Telnet login now keeps the switch's greeting in an in-memory session log
and reports a full switch as a connection error; an HTML answer to the
REST login says so. An SSH attempt records netmiko's underlying error
instead of "timed out" when it was not a timeout.
Session log objects need netmiko 4.3.0, which becomes the floor.
Closes#13
- CI moves to .gitea/workflows/ci.yml and calls the shared driver workflow
of NAPALM/driver-standard; .github/ goes.
- requires-python >=3.10 (napalm-device-types needs it), LICENSE file,
CHANGELOG, py.typed, SPDX license string, links to git.netork.io;
napalm-device-types >=4.21.1, a dev extra with floors.
- [tool.napalm-standard] names the import package napalm_procurve, which is
not the distribution name.
- True floors for netaddr (>=0.7.10) and urllib3 (>=1.23): unbounded, the
lowest job installed versions that do not import on Python 3.10.
- mypy strict for the package; napalm_procurve.api_client, .parsers and
.procurve are exempt for now (136 errors), recorded in the quality
baseline with their long functions and the 1400-line procurve.py.
Coverage floor 54 % (measured 54.28 %).