get_facts read HostName from getBasicInformation, which a VMG4005-B50A
does not send, and fell back to the address the driver connects to:
netOrk kept the gateway named 192.168.1.1. The gateway's own System page
reads host name and domain with GET /cgi-bin/System?oid=snmp, sealed like
a DAL answer; get_facts now reads them there. fqdn is the host name with
its domain. A gateway with no name set reports "", and get_facts raises
when the System page cannot be read.
get_interfaces reported a fixed set: wan, lan and two Wi-Fi radios, all
up at 1000 Mbit/s, the LAN with the WAN's MAC. get_interfaces_ip gave
both a /24, the LAN's address being the hostname the driver connected
to. getBasicInformation carries none of WanIp, LanIp or MacAddress on a
VMG4005-B50A, a VDSL bridge without Wi-Fi whose LAN is a /29, and the
gateway showed all of the invented values.
Both now read the DAL's cardpage_status, which a GET answers sealed like
a PUT: the IP interfaces in WanLanInfo (br0, atm0.1, ptm0.2) with their
status, MAC and netmask, the Ethernet ports in LanInfo (eth1) with their
speed. A speed or MTU the gateway does not report is 0, unknown. IPv6
addresses are not read yet: no gateway seen so far had IPv6 on.
A VMG has no configuration export. The override returned {}, so a caller
could not tell "not supported" from "read an empty configuration": netOrk
took it for a backup that came back empty and raised config_backup_failed
on every poll. Without the override NAPALM's stub raises
NotImplementedError and the getter reads as not implemented.
is_alive() opened a TCP connection to the gateway whether or not the
driver was opened, and after close() too. NAPALM's __del__ asks it of
every collected driver, so each one connected once more and could stall
for up to five seconds. Without an open session it now answers False
and connects nowhere; with one, it reports whether the gateway still
answers on its port.
Closes#19
NAPALM's __del__ calls is_alive(), and this driver's is_alive() opens a
TCP connection to the gateway whether or not the driver was opened or
closed, so every driver a test built connected to 192.168.1.1:80 when
it was collected. The tests now build their drivers with an is_alive()
that opens nothing (the is_alive tests call the class's method), and a
session-wide guard in conftest refuses every connection and fails the
run if anything tried one.
Closes#17
_dal_query and _fetch_page returned None for any failure, and the
getters turned that into empty data, so a timeout or an expired session
read as a gateway with no hosts, port forwards, SSIDs or Wi-Fi clients.
Both now raise: ConnectionException when the gateway does not answer or
refuses the session, RuntimeError naming the request otherwise. A getter
whose DAL request fails still reads the HTML page and raises when that
fails too; get_facts no longer swallows a failed get_interfaces.
Closes#15
The driver's evidence was all vendor-wide: Zyxel's enterprise OID, Zyxel
OUIs and "zyxel" on the web page. Every managed Zyxel device has all
three, and they were the driver's whole maximum, so discovery named any
Zyxel switch this gateway with high confidence.
Discovery now also fetches /getRSAPublickKey on ports 80 and 443, the
DAL key exchange the driver logs in with, without counting the port.
Its "RSAPublicKey" answer weighs 24: vendor-wide evidence alone is 28 of
52 (medium), a gateway 52 of 52, or 37 of 52 without SNMP.
Closes#13
ping() returned three replies of 0 ms whenever the DAL accepted a
PINGTEST request, without reading any result, so a LAN scan through
this gateway marked every address alive. The DAL answer is only an
acknowledgement with no reply count, so ping() now returns NAPALM's
error reply without contacting the gateway and the driver opts out of
ping sweeps with SUPPORTS_PING = False.
Closes#2
requests ignores a timeout attribute on a Session, so open() setting
one left every call without a timeout and an unresponsive gateway
could hang a worker indefinitely. Each get/post/put now carries the
driver's timeout.
Closes#3
GS1920 and GS2210 are Zyxel switches. Counting them as evidence for a
VMG gateway driver made discovery score a Zyxel switch higher for this
driver than a real VMG gateway.
Closes#4
The host list says a host is active, not when the gateway last saw it, so
get_arp_table reports ARP_AGE_UNKNOWN instead of 0.0 ("confirmed just now").
NetOrk/netork#1327
- CI moves to .gitea/workflows/ci.yml and calls the shared driver workflow
of NAPALM/driver-standard; .github/ is gone.
- requires-python >=3.10 (napalm-device-types needs it), floor
napalm-device-types>=4.21.1 (was napalm_device_types>=0.4.0), LICENSE
file, py.typed, SPDX license string, links to git.netork.io, a dev extra
with floors.
- README (pyproject named one that did not exist) and CHANGELOG.md.
- mypy strict for the package; napalm_zyxel.zyxel_driver is exempt for now
(24 errors), recorded in the quality baseline with its two complex
functions. Coverage floor 68 % (measured 68.97 %).
Closes#8
- nosec for SHA512_password in the login payload (B105): it is a flag
telling the gateway how Input_Passwd is encoded, not a password; a false
positive.
- A failed login raises ConnectionException from the underlying error, so
the cause stays attached.
- tests: pytest.raises instead of try / assert False / except, which
python -O would have turned into tests that always pass.
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM
driver uses (E, F, I, UP, B at line length 100, Python 3.10). What ruff
cannot fix comes in the next commit.
The gateway had reboot(), but the contract (HostRebootMixin) and the
application look for reboot_host(), so the gateway could not be
restarted from it. reboot_host() returns None and raises when the
gateway refuses, as the contract says.
run_device_action dispatched reboot, restart_wifi[:band] and
get_diagnostics by string, with a result shape other than its
contract's. restart_wifi(band) and get_diagnostics() are methods now;
napalm-device-types deprecates run_device_action.
BREAKING CHANGE: reboot() and run_device_action are removed.
Closes#5. Part of #6.