mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-15 05:06:30 +00:00
Process NetworkManager PrimaryConnection changes (#5903)
Process NetworkManager interface updates in case PrimaryConnection changes. This makes sure that the /network/interface/default/info endpoint can be used to get the IP address of the primary interface.
This commit is contained in:
parent
1faf529b42
commit
8251b6c61c
@ -185,10 +185,14 @@ class NetworkManager(DBusInterfaceProxy):
|
||||
if not changed and self.dns.is_connected:
|
||||
await self.dns.update()
|
||||
|
||||
if changed and (
|
||||
if (
|
||||
changed
|
||||
and DBUS_ATTR_PRIMARY_CONNECTION not in changed
|
||||
and (
|
||||
DBUS_ATTR_DEVICES not in changed
|
||||
or {intr.object_path for intr in self.interfaces if intr.managed}.issubset(
|
||||
set(changed[DBUS_ATTR_DEVICES])
|
||||
or {
|
||||
intr.object_path for intr in self.interfaces if intr.managed
|
||||
}.issubset(set(changed[DBUS_ATTR_DEVICES]))
|
||||
)
|
||||
):
|
||||
# If none of our managed devices were removed then most likely this is just veths changing.
|
||||
|
@ -249,3 +249,25 @@ async def test_network_manager_stopped(
|
||||
capture_exception.assert_called_once()
|
||||
assert isinstance(capture_exception.call_args.args[0], DBusServiceUnkownError)
|
||||
assert "NetworkManager not responding" in caplog.text
|
||||
|
||||
|
||||
async def test_primary_connection_update(
|
||||
network_manager_service: NetworkManagerService,
|
||||
network_manager: NetworkManager,
|
||||
):
|
||||
"""Test handling of primary connection change."""
|
||||
interface = next(
|
||||
(
|
||||
intr
|
||||
for intr in network_manager.interfaces
|
||||
if intr.object_path == "/org/freedesktop/NetworkManager/Devices/1"
|
||||
),
|
||||
None,
|
||||
)
|
||||
await network_manager.update({"PrimaryConnection": "/"})
|
||||
assert interface.primary is False
|
||||
|
||||
await network_manager.update(
|
||||
{"PrimaryConnection": "/org/freedesktop/NetworkManager/ActiveConnection/1"}
|
||||
)
|
||||
assert interface.primary is True
|
||||
|
Loading…
x
Reference in New Issue
Block a user