feat(interfaces): report the assigned interface name alongside the physical one
CI / test (3.10) (push) Failing after 8s
CI / test (3.11) (push) Failing after 7s
CI / test (3.12) (push) Failing after 10s
CI / test (3.9) (push) Failing after 8s

get_interfaces() keys entries by the physical device ("em0"), which is what
every other call in this driver speaks. Wake-on-LAN is the exception: it needs
the name OPNsense assigned ("lan", "opt1") and silently rejects anything else
with an empty {} at HTTP 200.

The overview export already carries it, so pass it through as "identifier".
Empty for interfaces OPNsense has not assigned.
This commit is contained in:
Christian Manivong
2026-08-20 11:10:25 +07:00
parent 8ba95a0709
commit 0c5670981d
2 changed files with 45 additions and 0 deletions
+6
View File
@@ -220,6 +220,11 @@ class OPNsenseDriver(OPNsensePingMixin, FirewallDriver):
Each entry contains NAPALM standard keys:
``is_up``, ``is_enabled``, ``description``, ``last_flapped``,
``mac_address``, ``speed``, ``mtu``.
Plus one non-standard key, ``identifier``: OPNsense's *assigned*
interface name ("lan", "opt1"), as opposed to the physical device the
dict is keyed by ("em0"). Empty for unassigned interfaces. This is the
name :meth:`send_wake_on_lan` requires — see the note there.
"""
data = self._get("/api/interfaces/overview/export")
interfaces: dict[str, dict[str, Any]] = {}
@@ -240,6 +245,7 @@ class OPNsenseDriver(OPNsensePingMixin, FirewallDriver):
"mac_address": (iface.get("macaddr") or iface.get("mac") or "").lower(),
"speed": float(iface["speed_mbps"]) if iface.get("speed_mbps") else 0.0,
"mtu": int(iface["mtu"]) if iface.get("mtu") else 0,
"identifier": iface.get("identifier") or "",
}
return interfaces