fix(interfaces): report the WAN speed in Mbit/s
NewLayer1DownstreamMaxBitRate is bit/s; dividing by 1000 gave kbit/s, so a 250 Mbit/s line came out as 250000 in a field NAPALM defines as Mbit/s. Closes #2
This commit is contained in:
1 parent
5dbfe62271
commit
3783f74eb8
3 files changed
+10
-1
No files matched your search
@@ -16,6 +16,8 @@ All notable changes to this driver. The format follows
|
||||
- `get_arp_table()` reports an unknown age as `-1.0` (napalm-device-types'
|
||||
`ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed just now": the host
|
||||
list says a host is active, not when the box last saw it (NetOrk/netork#1327).
|
||||
- `get_interfaces()` reports the `wan` speed in Mbit/s as NAPALM defines it: a
|
||||
250 Mbit/s line was shown as 250000 (#2).
|
||||
|
||||
## [0.3.0] - 2026-10-23
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@ _ANY_REMOTE = "0.0.0.0" # nosec B104
|
||||
# (e.g. a service not present on a given FritzOS version/model).
|
||||
_OPTIONAL_SERVICE_ERRORS = (FritzServiceError, FritzActionError, FritzConnectionException)
|
||||
|
||||
#: TR-064 reports the WAN sync rate in bit/s; NAPALM's interface ``speed`` is Mbit/s.
|
||||
_BIT_PER_MBIT = 1_000_000
|
||||
|
||||
|
||||
def _to_float(value: Any, default: float = 0.0) -> float:
|
||||
"""Convert a TR-064 field to float, returning *default* for non-numeric values like 'Auto'."""
|
||||
@@ -265,7 +268,7 @@ class FritzBoxDriver(ResidentialGatewayDriver):
|
||||
"description": link.get("NewWANAccessType", "WAN"),
|
||||
"last_flapped": -1.0,
|
||||
"mac_address": "",
|
||||
"speed": _to_float(link.get("NewLayer1DownstreamMaxBitRate")) / 1000,
|
||||
"speed": _to_float(link.get("NewLayer1DownstreamMaxBitRate")) / _BIT_PER_MBIT,
|
||||
"mtu": 1500,
|
||||
}
|
||||
except _OPTIONAL_SERVICE_ERRORS:
|
||||
|
||||
@@ -393,6 +393,10 @@ class TestGetInterfaces:
|
||||
assert interfaces["wan"]["is_up"] is True
|
||||
assert interfaces["wan"]["description"] == "DSL"
|
||||
|
||||
def test_wan_speed_in_mbit(self, driver):
|
||||
# NewLayer1DownstreamMaxBitRate is bit/s: 250 000 000 bit/s is 250 Mbit/s.
|
||||
assert driver.get_interfaces()["wan"]["speed"] == 250.0
|
||||
|
||||
def test_wlan_interfaces_present(self, driver):
|
||||
interfaces = driver.get_interfaces()
|
||||
assert interfaces["wlanconfiguration1"]["description"] == "MyWifi"
|
||||
|
||||
Reference in new issue
Block a user