Set agent diagnostics (#3203)

* Set agent diagnostics

* Add AttributeError to dbus_property wrapper

* Use dbus_property instead of dbus_connected

* Move sync to core setup
This commit is contained in:
Joakim Sørensen 2021-10-18 14:48:47 +02:00 committed by GitHub
parent 8a553dbb59
commit 6ab4dda5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

View File

@ -142,6 +142,7 @@ class APISupervisor(CoreSysAttributes):
if ATTR_DIAGNOSTICS in body:
self.sys_config.diagnostics = body[ATTR_DIAGNOSTICS]
self.sys_dbus.agent.diagnostics = body[ATTR_DIAGNOSTICS]
if ATTR_LOGGING in body:
self.sys_config.logging = body[ATTR_LOGGING]

View File

@ -153,6 +153,12 @@ class Core(CoreSysAttributes):
self.sys_resolution.unhealthy = UnhealthyReason.SETUP
self.sys_capture_exception(err)
# Set OS Agent diagnostics if needed
if self.sys_config.diagnostics is not None and (
self.sys_dbus.agent.diagnostics != self.sys_config.diagnostics
):
self.sys_dbus.agent.diagnostics = self.sys_config.diagnostics
# Evaluate the system
await self.sys_resolution.evaluate.evaluate_system()

View File

@ -70,6 +70,7 @@ class OSAgent(DBusInterface):
return self.properties[DBUS_ATTR_DIAGNOSTICS]
@diagnostics.setter
@dbus_property
def diagnostics(self, value: bool) -> None:
"""Enable or disable OS-Agent diagnostics."""
asyncio.create_task(

View File

@ -13,7 +13,7 @@ def dbus_property(func):
def wrapper(*args, **kwds):
try:
return func(*args, **kwds)
except KeyError:
except (KeyError, AttributeError):
return None
return wrapper