diff --git a/supervisor/host/network.py b/supervisor/host/network.py index 19c9de8c2..2aeb7cff8 100644 --- a/supervisor/host/network.py +++ b/supervisor/host/network.py @@ -119,6 +119,10 @@ class NetworkManager(CoreSysAttributes): self.apply_changes(interface, update_only=True) for interface in interfaces if interface.enabled + and ( + interface.ipv4.method != InterfaceMethod.DISABLED + or interface.ipv6.method != InterfaceMethod.DISABLED + ) ] ) diff --git a/tests/host/test_network.py b/tests/host/test_network.py index 33890db5a..bdfc1d4b2 100644 --- a/tests/host/test_network.py +++ b/tests/host/test_network.py @@ -2,6 +2,9 @@ from unittest.mock import Mock, patch from supervisor.coresys import CoreSys +from supervisor.dbus.const import InterfaceMethod +from supervisor.host.const import InterfaceType +from supervisor.host.network import Interface, IpConfig async def test_load(coresys: CoreSys): @@ -24,8 +27,32 @@ async def test_load(coresys: CoreSys): assert coresys.host.network.interfaces[1].name == "wlan0" assert coresys.host.network.interfaces[1].enabled is False - assert activate_connection.call_count == 1 - assert activate_connection.call_args.args == ( + activate_connection.assert_called_once_with( "/org/freedesktop/NetworkManager/Settings/1", "/org/freedesktop/NetworkManager/Devices/1", ) + + +async def test_load_with_disabled_methods(coresys: CoreSys): + """Test load does not disable methods of interfaces.""" + with patch( + "supervisor.host.network.Interface.from_dbus_interface", + return_value=Interface( + "eth0", + True, + False, + False, + InterfaceType.ETHERNET, + IpConfig(InterfaceMethod.DISABLED, [], None, []), + IpConfig(InterfaceMethod.DISABLED, [], None, []), + None, + None, + ), + ), patch.object( + coresys.host.sys_dbus.network, + "activate_connection", + new=Mock(wraps=coresys.host.sys_dbus.network.activate_connection), + ) as activate_connection: + await coresys.host.network.load() + + activate_connection.assert_not_called()