feat(interfaces): report the assigned interface name alongside the physical one
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user