mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-22 08:36:30 +00:00
Split check for internet connection to help troubleshooting (#2248)
* Split check for internet connection to help troubleshooting * Siplify * revert * cleanup Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
parent
e4bf820038
commit
06ab7e904f
@ -58,10 +58,6 @@ class Core(CoreSysAttributes):
|
|||||||
await self.sys_supervisor.load()
|
await self.sys_supervisor.load()
|
||||||
|
|
||||||
# Check internet on startup
|
# Check internet on startup
|
||||||
if not self.sys_host.network.connectivity:
|
|
||||||
await self.sys_host.network.check_connectivity()
|
|
||||||
|
|
||||||
if not self.sys_supervisor.connectivity:
|
|
||||||
await self.sys_supervisor.check_connectivity()
|
await self.sys_supervisor.check_connectivity()
|
||||||
|
|
||||||
# Evaluate the system
|
# Evaluate the system
|
||||||
|
@ -38,10 +38,10 @@ class NetworkManager(CoreSysAttributes):
|
|||||||
def __init__(self, coresys: CoreSys):
|
def __init__(self, coresys: CoreSys):
|
||||||
"""Initialize system center handling."""
|
"""Initialize system center handling."""
|
||||||
self.coresys: CoreSys = coresys
|
self.coresys: CoreSys = coresys
|
||||||
self._connectivity: bool = None
|
self._connectivity: Optional[bool] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def connectivity(self) -> bool:
|
def connectivity(self) -> Optional[bool]:
|
||||||
"""Return true current connectivity state."""
|
"""Return true current connectivity state."""
|
||||||
return self._connectivity
|
return self._connectivity
|
||||||
|
|
||||||
@ -67,15 +67,13 @@ class NetworkManager(CoreSysAttributes):
|
|||||||
return list(dict.fromkeys(servers))
|
return list(dict.fromkeys(servers))
|
||||||
|
|
||||||
async def check_connectivity(self):
|
async def check_connectivity(self):
|
||||||
"""Check the internet connection."""
|
"""Check the internet connection.
|
||||||
if not self.sys_dbus.network.is_connected:
|
|
||||||
self._connectivity = None
|
ConnectionState 4 == FULL (has internet)
|
||||||
return
|
https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMConnectivityState
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
state = await self.sys_dbus.network.check_connectivity()
|
state = await self.sys_dbus.network.check_connectivity()
|
||||||
|
|
||||||
# ConnectionState 4 == FULL (has internet)
|
|
||||||
# https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMConnectivityState
|
|
||||||
self._connectivity = state[0] == 4
|
self._connectivity = state[0] == 4
|
||||||
except DBusError:
|
except DBusError:
|
||||||
self._connectivity = False
|
self._connectivity = False
|
||||||
|
@ -94,14 +94,21 @@ class Job:
|
|||||||
|
|
||||||
if JobCondition.INTERNET in self.conditions:
|
if JobCondition.INTERNET in self.conditions:
|
||||||
if self._coresys.core.state == CoreState.RUNNING:
|
if self._coresys.core.state == CoreState.RUNNING:
|
||||||
|
if self._coresys.dbus.network.is_connected:
|
||||||
await self._coresys.host.network.check_connectivity()
|
await self._coresys.host.network.check_connectivity()
|
||||||
await self._coresys.supervisor.check_connectivity()
|
await self._coresys.supervisor.check_connectivity()
|
||||||
if not self._coresys.supervisor.connectivity or (
|
if not self._coresys.supervisor.connectivity:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"'%s' blocked from execution, no supervisor internet connection",
|
||||||
|
self._method.__qualname__,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
elif (
|
||||||
self._coresys.host.network.connectivity is not None
|
self._coresys.host.network.connectivity is not None
|
||||||
and not self._coresys.host.network.connectivity
|
and not self._coresys.host.network.connectivity
|
||||||
):
|
):
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"'%s' blocked from execution, no internet connection",
|
"'%s' blocked from execution, no host internet connection",
|
||||||
self._method.__qualname__,
|
self._method.__qualname__,
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user