Never disable interfaces at startup (#3676)

This commit is contained in:
Mike Degatano 2022-06-09 07:55:36 -04:00 committed by GitHub
parent b82dbc0cac
commit 3b3cd61e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

@ -119,6 +119,10 @@ class NetworkManager(CoreSysAttributes):
self.apply_changes(interface, update_only=True) self.apply_changes(interface, update_only=True)
for interface in interfaces for interface in interfaces
if interface.enabled if interface.enabled
and (
interface.ipv4.method != InterfaceMethod.DISABLED
or interface.ipv6.method != InterfaceMethod.DISABLED
)
] ]
) )

View File

@ -2,6 +2,9 @@
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from supervisor.coresys import CoreSys 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): 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].name == "wlan0"
assert coresys.host.network.interfaces[1].enabled is False assert coresys.host.network.interfaces[1].enabled is False
assert activate_connection.call_count == 1 activate_connection.assert_called_once_with(
assert activate_connection.call_args.args == (
"/org/freedesktop/NetworkManager/Settings/1", "/org/freedesktop/NetworkManager/Settings/1",
"/org/freedesktop/NetworkManager/Devices/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()