56 lines
2.8 KiB
Python
56 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""P0.5: валидация/карантин атрибутов Комбайна. Прод не меняет."""
|
|
import yaml
|
|
import json
|
|
from collections import Counter
|
|
|
|
VAL = "/opt/work-hub/compat/values.yaml"
|
|
OUT = "/root/buryan-infra/ops/combine/attributes-quarantine-2026-11-18.yaml"
|
|
REP = "/root/buryan-infra/ops/combine/P0-ATTR-REPORT-2026-11-18.md"
|
|
|
|
d = yaml.safe_load(open(VAL, encoding="utf-8"))
|
|
devs = d if isinstance(d, list) else d.get("devices", [])
|
|
bad = []
|
|
for x in devs:
|
|
name = x.get("device") or ""
|
|
attrs = x.get("attributes") or {}
|
|
for k, v in attrs.items():
|
|
reason = None
|
|
try:
|
|
f = float(str(v).split()[0])
|
|
except Exception:
|
|
f = None
|
|
if k in ("camera.fov_h", "camera.fov_v") and f is not None and (f <= 0 or f > 180):
|
|
reason = "FOV вне 0..180"
|
|
if k in ("camera.fov_h", "camera.fov_v") and name == "MeetingBar A30" and f == 120:
|
|
reason = "FOV 120 одновременнно H/V — физически невозможно"
|
|
if k == "camera.max_resolution":
|
|
sv = str(v)
|
|
if sv in ("4", "3840") or "*" in sv:
|
|
reason = "несогласованный формат разрешения"
|
|
if k == "poe.ports" and ("UVC" in name or name.startswith("SIP-")):
|
|
reason = "PoE-порты у камеры/телефона"
|
|
if k == "audio.spl_max" and "UVC" in name:
|
|
reason = "SPL у USB-камеры — поле не по роли"
|
|
if k == "physical.temp_min" and f is not None and f > 60:
|
|
reason = "temp_min выглядит как температура, не диапазон"
|
|
if k == "power.consumption_w" and f is not None and f > 500:
|
|
reason = "потребление >500 Вт"
|
|
if reason:
|
|
bad.append({"device": name, "key": k, "value": v, "reason": reason})
|
|
|
|
yaml.safe_dump({"version": "2026-11-18", "quarantine": bad}, open(OUT, "w", encoding="utf-8"),
|
|
allow_unicode=True, sort_keys=False)
|
|
cnt = Counter(b["reason"] for b in bad)
|
|
lines = ["# P0.5 — карантин атрибутов", "",
|
|
"Прод `values.yaml` не изменён. Проблемных значений: **%d**." % len(bad), "",
|
|
"| Причина | Кол-во |", "|---|---|"]
|
|
for k, n in cnt.most_common():
|
|
lines.append("| %s | %d |" % (k, n))
|
|
lines += ["", "## Значения", "| Устройство | Атрибут | Значение | Причина |", "|---|---|---|---|"]
|
|
for b in bad[:80]:
|
|
lines.append("| %s | %s | %s | %s |" % (b["device"], b["key"], b["value"], b["reason"]))
|
|
open(REP, "w", encoding="utf-8").write("\n".join(lines) + "\n")
|
|
print("quarantine", len(bad), "devices", len({b['device'] for b in bad}))
|
|
print(REP)
|