fix(facts): read serial number and uptime from the status page
driver / lint (pull_request) Successful in 20s
driver / standard (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 26s
driver / build (pull_request) Successful in 36s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 2m23s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 20s
driver / standard (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 58s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / lowest (pull_request) Successful in 26s
driver / build (pull_request) Successful in 36s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 2m23s
driver / publish (pull_request) Skipped
get_facts read SerialNumber and SystemUpTime from getBasicInformation, which a VMG4005-B50A does not send, and reported "" and 0. The gateway has both in DeviceInfo of the DAL's cardpage_status, the answer the interfaces are read from. get_facts now reads that answer once and takes the interfaces, serial number and uptime from it. Model and firmware stay with getBasicInformation, which does carry them. Closes #27
This commit is contained in:
1 parent
56a832b9d1
commit
1fda222d56
5 files changed
+125
-45
No files matched your search
@@ -76,6 +76,24 @@ def _ethernet_port(port: dict[str, Any]) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _interfaces(page: dict[str, Any]) -> dict[str, dict[str, Any]]:
|
||||
"""The IP interfaces (``WanLanInfo``) and Ethernet ports (``LanInfo``) of a
|
||||
``cardpage_status`` answer, keyed by the gateway's own interface name."""
|
||||
ifaces = {
|
||||
entry["X_ZYXEL_IfName"]: _ip_interface(entry)
|
||||
for entry in page.get("WanLanInfo") or []
|
||||
if entry.get("X_ZYXEL_IfName")
|
||||
}
|
||||
ifaces.update(
|
||||
{
|
||||
port["Name"]: _ethernet_port(port)
|
||||
for port in page.get("LanInfo") or []
|
||||
if port.get("Name")
|
||||
}
|
||||
)
|
||||
return ifaces
|
||||
|
||||
|
||||
def _ipv4_addresses(entry: dict[str, Any]) -> dict[str, dict[str, int]]:
|
||||
"""The enabled IPv4 addresses of one ``WanLanInfo`` entry, with their prefix length."""
|
||||
return {
|
||||
@@ -354,21 +372,23 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
|
||||
def get_facts(self) -> dict[str, Any]:
|
||||
"""Return device facts such as model, serial, OS version, and uptime.
|
||||
|
||||
The host name and domain are the ones on the gateway's System page;
|
||||
``getBasicInformation`` does not carry them.
|
||||
``getBasicInformation`` carries model and firmware only. The host name and
|
||||
domain are the ones on the gateway's System page; serial number and uptime
|
||||
are the status page's ``DeviceInfo``, read with the interfaces (#27).
|
||||
"""
|
||||
info = self._device_info or {}
|
||||
iface_list = list(self.get_interfaces().keys())
|
||||
page = self._status_page()
|
||||
device = page.get("DeviceInfo") or {}
|
||||
hostname, domain = self._system_name()
|
||||
return {
|
||||
"vendor": self.VENDOR,
|
||||
"model": info.get("ModelName", ""),
|
||||
"serial_number": info.get("SerialNumber", ""),
|
||||
"serial_number": str(device.get("SerialNumber") or ""),
|
||||
"os_version": info.get("SoftwareVersion", ""),
|
||||
"hostname": hostname,
|
||||
"fqdn": f"{hostname}.{domain}" if hostname and domain else hostname,
|
||||
"uptime": int(info.get("SystemUpTime", 0) or 0),
|
||||
"interface_list": iface_list,
|
||||
"uptime": int(device.get("UpTime") or 0),
|
||||
"interface_list": list(_interfaces(page)),
|
||||
}
|
||||
|
||||
def _system_name(self) -> tuple[str, str]:
|
||||
@@ -419,20 +439,7 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
|
||||
Keyed by the gateway's own interface name (``br0``, ``ptm0.2``, ``eth1``). A
|
||||
speed or MTU the gateway does not report is 0: unknown.
|
||||
"""
|
||||
page = self._status_page()
|
||||
ifaces = {
|
||||
entry["X_ZYXEL_IfName"]: _ip_interface(entry)
|
||||
for entry in page.get("WanLanInfo") or []
|
||||
if entry.get("X_ZYXEL_IfName")
|
||||
}
|
||||
ifaces.update(
|
||||
{
|
||||
port["Name"]: _ethernet_port(port)
|
||||
for port in page.get("LanInfo") or []
|
||||
if port.get("Name")
|
||||
}
|
||||
)
|
||||
return ifaces
|
||||
return _interfaces(self._status_page())
|
||||
|
||||
def get_interfaces_ip(self) -> dict[str, dict[str, Any]]:
|
||||
"""The IPv4 addresses of the gateway's IP interfaces, with their netmask.
|
||||
|
||||
Reference in new issue
Block a user