From 9a21739eb93dfc88c92314d082b53f8d69f160a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 17 Oct 2025 13:59:45 +0200 Subject: [PATCH] fix w statusie watchdog-mux --- app.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index 1d3d12f..dd03210 100644 --- a/app.py +++ b/app.py @@ -300,16 +300,22 @@ def units_for_node(node: str) -> Dict[str, str]: states: Dict[str, str] = {} def norm_state(s: dict) -> str: - # Proxmox bywa: {"state":"enabled","active":"active"} albo {"active":1} albo {"status":"running"} itp. - raw_active = str(s.get("active", "")).lower() - status = str(s.get("status", "")).lower() - substate = str(s.get("substate", "")).lower() - state = str(s.get("state", "")).lower() + raw_active = str( + s.get("active", "") or + s.get("active-state", "") or + s.get("ActiveState", "") or + s.get("activestate", "") + ).lower() + + status = str(s.get("status", "")).lower() + substate = str(s.get("substate", "")).lower() + state = str(s.get("state", "")).lower() + any_active = ( raw_active in ("active", "running", "1", "true") or status in ("active", "running") or - substate in ("running") or - ("running" in state) + substate in ("running", "active") or + ("running" in state or "active" in state) ) return "active" if any_active else "inactive" @@ -319,12 +325,10 @@ def units_for_node(node: str) -> Dict[str, str]: if name in wanted: states[name] = norm_state(s) - # fallback lokalny tylko jeśli API nic nie zwróciło - if not states: - for u in wanted: - states[u] = "active" if is_active(u) else "inactive" + for u in wanted: + if states.get(u) != "active" and is_active(u): + states[u] = "active" - # zawsze zwróć pełny zestaw for u in wanted: states.setdefault(u, "inactive")