47 lines
2.0 KiB
Python
47 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Применить курированные профили других вендоров к веткам и stage."""
|
|
import glob
|
|
import os
|
|
import shutil
|
|
import time
|
|
import yaml
|
|
|
|
PROFILES = "/root/buryan-infra/ops/combine/vendors-other-models-2026-11-18.yaml"
|
|
prof = yaml.safe_load(open(PROFILES, encoding="utf-8"))
|
|
pmap = {(x["vendor"], x["model"]): x for x in prof.get("devices") or []}
|
|
paths = [os.path.join("/opt/work-hub/compat", "catalog.yaml")] + \
|
|
sorted(glob.glob("/opt/work-hub/compat/catalog-*.yaml")) + \
|
|
["/root/buryan-infra/ops/combine/catalog-p0-2026-11-18.yaml"]
|
|
for p in paths:
|
|
if not os.path.exists(p):
|
|
continue
|
|
d = yaml.safe_load(open(p, encoding="utf-8"))
|
|
n = 0
|
|
for x in d.get("devices") or []:
|
|
q = pmap.get((x.get("vendor"), x.get("model")))
|
|
if not q:
|
|
continue
|
|
for k in ("role", "group", "line", "solution_class", "form_factor",
|
|
"native_vcs", "deployment", "components", "sales_scope"):
|
|
if k in q:
|
|
x[k] = q[k]
|
|
if not q.get("solution_class"):
|
|
role = q.get("role") or x.get("role")
|
|
grp = q.get("group") or x.get("group")
|
|
cls = {"camera": "vcs.camera.usb", "pc": "vcs.terminal.pc",
|
|
"audio": "vcs.audio", "speaker": "vcs.audio",
|
|
"touch": "vcs.control.touch", "display": "passive.display",
|
|
"mount": "passive.mount", "codec": "vcs.terminal.room",
|
|
"kit": "vcs.byod.kit", "sharing_hub": "vcs.sharing"}.get(role)
|
|
if role == "codec" and grp == "B_video_bars":
|
|
cls = "vcs.bar.room"
|
|
if cls:
|
|
x["solution_class"] = cls
|
|
x["domain"] = "vcs"
|
|
x["analog_group"] = x.get("solution_class")
|
|
n += 1
|
|
if n:
|
|
shutil.copy2(p, p + ".bak-prof-" + time.strftime("%Y%m%d-%H%M%S"))
|
|
yaml.safe_dump(d, open(p, "w", encoding="utf-8"), allow_unicode=True, sort_keys=False)
|
|
print(os.path.basename(p), "profiles", n)
|