update picked data strucures

This commit is contained in:
Andreas Wrede
2026-04-10 09:18:38 -04:00
parent 2f72cf0118
commit a5f31c5cb5
2 changed files with 16 additions and 3 deletions
+5 -1
View File
@@ -89,9 +89,13 @@ async def reload_configuration(config_obj, config_path, components):
# Reload users # Reload users
users_mod.load_users(new_config) users_mod.load_users(new_config)
# Re-apply host access from updated config to all known hosts # Re-apply host attributes from updated config to all known hosts
from . import config as config_mod from . import config as config_mod
dyndnshosts = config_mod.get_dyndnshosts(new_config)
watchhosts = config_mod.get_watchhosts(new_config)
for hostname, host in hbdclass.Host.hosts.items(): for hostname, host in hbdclass.Host.hosts.items():
host.dyn = hostname in dyndnshosts
host.watched = hostname in watchhosts
access = config_mod.get_host_access(new_config, hostname) access = config_mod.get_host_access(new_config, hostname)
host.apply_access(access["owner"], access["managers"], access["monitors"]) host.apply_access(access["owner"], access["managers"], access["monitors"])
+11 -2
View File
@@ -120,8 +120,11 @@ class AlertState:
# Helper to sanitize numeric values for JSON (handle inf/nan) # Helper to sanitize numeric values for JSON (handle inf/nan)
def sanitize_value(val): def sanitize_value(val):
if isinstance(val, float) and (math.isinf(val) or math.isnan(val)): if isinstance(val, float):
return None if math.isinf(val):
return "overdue"
if math.isnan(val):
return None
return val return val
result = { result = {
@@ -148,6 +151,12 @@ class AlertState:
return result return result
def __setstate__(self, state):
"""Restore from pickle, backfilling fields added after the pickle was written."""
self.__dict__.update(state)
if not hasattr(self, 'consecutive_count'):
self.consecutive_count = 0
def acknowledge(self): def acknowledge(self):
"""Acknowledge this alert to stop reminder notifications.""" """Acknowledge this alert to stop reminder notifications."""
self.acknowledged = True self.acknowledged = True