fix w statusie watchdog-mux
This commit is contained in:
20
app.py
20
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()
|
||||
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"
|
||||
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")
|
||||
|
||||
|
Reference in New Issue
Block a user