99 lines
4.1 KiB
Python
99 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Разметка stage: domain / solution_class / sales_scope / sip_context.
|
|
|
|
SIP — протокол. Домен определяет сценарий:
|
|
vcs — переговорная/commercial video
|
|
telephony — SIP-телефоны, DECT, гарнитуры (reference, не наш sales line)
|
|
"""
|
|
import re
|
|
import yaml
|
|
from collections import Counter
|
|
|
|
P = "/root/buryan-infra/ops/combine/catalog-p0-2026-11-18.yaml"
|
|
R = "/root/buryan-infra/ops/combine/P0-SOLUTION-CLASSES-2026-11-18.md"
|
|
d = yaml.safe_load(open(P, encoding="utf-8"))
|
|
devs = d["devices"]
|
|
|
|
|
|
def cls(x):
|
|
n = (x.get("model") or "").lower()
|
|
dom = x.get("domain") or "vcs"
|
|
grp = x.get("group") or ""
|
|
role = x.get("role") or ""
|
|
if dom == "telephony":
|
|
if n.startswith(("sip-t", "t3", "t4", "t5", "t7", "t8", "vp", "mp")):
|
|
return "telephony.sip.desk"
|
|
if n.startswith("cp"):
|
|
return "telephony.sip.conference"
|
|
if any(k in n for k in ("w70", "w80", "dect", "w53", "w56", "w57", "w59", "w73", "w76", "w77", "w78", "w79")):
|
|
return "telephony.dect"
|
|
if any(k in n for k in ("uh", "bh", "ehs", "wh", "yhs")):
|
|
return "telephony.headset"
|
|
return "telephony.accessory"
|
|
if any(k in n for k in ("uvc", "smartvision", "mb-cam", "cam50")):
|
|
return "vcs.camera.ptz" if "ptz" in n else "vcs.camera.usb"
|
|
if grp == "A_integration_terminals":
|
|
if n.startswith("mvc"):
|
|
return "vcs.kit.room"
|
|
if any(k in n for k in ("mini-pc", "room compute", "conferencing pc")):
|
|
return "vcs.pc"
|
|
return "vcs.terminal.room"
|
|
if grp == "B_video_bars":
|
|
if "meetingboard" in n or "hiboard" in n:
|
|
return "vcs.board"
|
|
if any(k in n for k in ("a10", "a20", "a25", "v12", "p15", "bcc950", "connect")):
|
|
return "vcs.bar.compact"
|
|
return "vcs.bar.room"
|
|
if grp == "D_usb_byod":
|
|
if any(k in n for k in ("ptz", "e60", "rally camera", "sight", "scribe")):
|
|
return "vcs.camera.ptz" if "ptz" in n else "vcs.camera.usb"
|
|
if any(k in n for k in ("vch", "wpp", "swytch", "byod")):
|
|
return "vcs.sharing"
|
|
if "camera" in role or any(k in n for k in ("uvc", "xc", "uc3", "uc4", "uc5", "cam")):
|
|
return "vcs.camera.usb"
|
|
return "vcs.accessory"
|
|
if grp == "E_audio":
|
|
return "vcs.audio"
|
|
if grp == "E_control":
|
|
return "vcs.control.touch"
|
|
if grp == "E_display":
|
|
return "passive.display"
|
|
if grp == "E_mount":
|
|
return "passive.mount"
|
|
if grp == "E_power":
|
|
return "passive.power"
|
|
if grp == "E_infra":
|
|
return "infrastructure.network"
|
|
return "vcs.accessory"
|
|
|
|
|
|
for x in devs:
|
|
x["solution_class"] = cls(x)
|
|
x["analog_group"] = x["solution_class"]
|
|
if x.get("domain") == "telephony":
|
|
x["sales_scope"] = "reference"
|
|
elif x.get("vendor") == "yealink":
|
|
x["sales_scope"] = "own"
|
|
else:
|
|
x["sales_scope"] = "alternative"
|
|
prots = [p.upper() for p in (x.get("protocols") or [])]
|
|
if "SIP" in prots:
|
|
x["sip_context"] = "telephony_endpoint" if x.get("domain") == "telephony" else "vcs_endpoint"
|
|
else:
|
|
x["sip_context"] = "none"
|
|
|
|
yaml.safe_dump(d, open(P, "w", encoding="utf-8"), allow_unicode=True, sort_keys=False)
|
|
c = Counter(x["solution_class"] for x in devs)
|
|
s = Counter(x["sales_scope"] for x in devs)
|
|
lines = ["# P0 — solution_class / sales_scope", "",
|
|
"SIP — протокол, не домен. `domain` и `solution_class` строго разделяют VCS и телефонию.", "",
|
|
"| solution_class | Кол-во |", "|---|---|"]
|
|
for k, n in c.most_common():
|
|
lines.append("| %s | %d |" % (k, n))
|
|
lines += ["", "| sales_scope | Кол-во |", "|---|---|"]
|
|
for k, n in s.most_common():
|
|
lines.append("| %s | %d |" % (k, n))
|
|
lines += ["", "`own` — Yealink VCS; `alternative` — другие VCS-вендоры; `reference` — телефония (не наш sales line)."]
|
|
open(R, "w", encoding="utf-8").write("\n".join(lines) + "\n")
|
|
print("classified", len(devs), "classes", len(c), "scopes", dict(s))
|