Fix missing primary interface after change (#2274)

* Fix missing primary interface after change

* Fix test
This commit is contained in:
Joakim Sørensen 2020-11-20 12:01:59 +01:00 committed by GitHub
parent 5367ac257e
commit e607d4feeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

View File

@ -14,6 +14,9 @@ DBUS_NAME_RAUC = "de.pengutronix.rauc"
DBUS_NAME_RAUC_INSTALLER = "de.pengutronix.rauc.Installer"
DBUS_NAME_RAUC_INSTALLER_COMPLETED = "de.pengutronix.rauc.Installer.Completed"
DBUS_NAME_SETTINGS_CONNECTION = "org.freedesktop.NetworkManager.Settings.Connection"
DBUS_NAME_NM_CONNECTION_ACTIVE_CHANGED = (
"org.freedesktop.NetworkManager.Connection.Active.PropertiesChanged"
)
DBUS_NAME_SYSTEMD = "org.freedesktop.systemd1"
DBUS_OBJECT_BASE = "/"

View File

@ -10,6 +10,7 @@ import attr
from ..coresys import CoreSys, CoreSysAttributes
from ..dbus.const import (
DBUS_NAME_NM_CONNECTION_ACTIVE_CHANGED,
ConnectionStateType,
DeviceType,
InterfaceMethod as NMInterfaceMethod,
@ -161,6 +162,9 @@ class NetworkManager(CoreSysAttributes):
_LOGGER.warning("Requested Network interface update is not possible")
raise HostNetworkError()
await self.sys_dbus.network.dbus.wait_signal(
DBUS_NAME_NM_CONNECTION_ACTIVE_CHANGED
)
await self.update()
async def scan_wifi(self, interface: Interface) -> List[AccessPoint]:

View File

@ -48,7 +48,9 @@ RE_GVARIANT_TUPLE_C: re.Pattern[Any] = re.compile(
RE_BIN_STRING_OCT: re.Pattern[Any] = re.compile(r"\\\\(\d{3})")
RE_BIN_STRING_HEX: re.Pattern[Any] = re.compile(r"\\\\x([0-9A-Za-z]{2})")
RE_MONITOR_OUTPUT: re.Pattern[Any] = re.compile(r".+?: (?P<signal>[^ ].+) (?P<data>.*)")
RE_MONITOR_OUTPUT: re.Pattern[Any] = re.compile(
r".+?: (?P<signal>[^\s].+?) (?P<data>.*)"
)
# Map GDBus to errors
MAP_GDBUS_ERROR: Dict[str, Any] = {

View File

@ -63,6 +63,9 @@ def dbus() -> DBus:
return load_json_fixture(f"{fixture}.json")
async def mock_wait_signal(_, __):
pass
async def mock_send(_, command, silent=False):
if silent:
return ""
@ -86,9 +89,13 @@ def dbus() -> DBus:
return load_fixture(f"{fixture}.{filetype}")
with patch("supervisor.utils.gdbus.DBus._send", new=mock_send), patch(
"supervisor.utils.gdbus.DBus.wait_signal", new=mock_wait_signal
), patch(
"supervisor.dbus.interface.DBusInterface.is_connected",
return_value=True,
), patch("supervisor.utils.gdbus.DBus.get_properties", new=mock_get_properties):
), patch(
"supervisor.utils.gdbus.DBus.get_properties", new=mock_get_properties
):
yield dbus_commands