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] = {}
|
states: Dict[str, str] = {}
|
||||||
|
|
||||||
def norm_state(s: dict) -> str:
|
def norm_state(s: dict) -> str:
|
||||||
# Proxmox bywa: {"state":"enabled","active":"active"} albo {"active":1} albo {"status":"running"} itp.
|
raw_active = str(
|
||||||
raw_active = str(s.get("active", "")).lower()
|
s.get("active", "") or
|
||||||
|
s.get("active-state", "") or
|
||||||
|
s.get("ActiveState", "") or
|
||||||
|
s.get("activestate", "")
|
||||||
|
).lower()
|
||||||
|
|
||||||
status = str(s.get("status", "")).lower()
|
status = str(s.get("status", "")).lower()
|
||||||
substate = str(s.get("substate", "")).lower()
|
substate = str(s.get("substate", "")).lower()
|
||||||
state = str(s.get("state", "")).lower()
|
state = str(s.get("state", "")).lower()
|
||||||
|
|
||||||
any_active = (
|
any_active = (
|
||||||
raw_active in ("active", "running", "1", "true") or
|
raw_active in ("active", "running", "1", "true") or
|
||||||
status in ("active", "running") or
|
status in ("active", "running") or
|
||||||
substate in ("running") or
|
substate in ("running", "active") or
|
||||||
("running" in state)
|
("running" in state or "active" in state)
|
||||||
)
|
)
|
||||||
return "active" if any_active else "inactive"
|
return "active" if any_active else "inactive"
|
||||||
|
|
||||||
@@ -319,12 +325,10 @@ def units_for_node(node: str) -> Dict[str, str]:
|
|||||||
if name in wanted:
|
if name in wanted:
|
||||||
states[name] = norm_state(s)
|
states[name] = norm_state(s)
|
||||||
|
|
||||||
# fallback lokalny tylko jeśli API nic nie zwróciło
|
|
||||||
if not states:
|
|
||||||
for u in wanted:
|
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:
|
for u in wanted:
|
||||||
states.setdefault(u, "inactive")
|
states.setdefault(u, "inactive")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user