commit a86dab8c5816ae25985e56c86facd9a4294c7230 Author: yumoqing Date: Fri Aug 7 11:23:20 2026 +0800 init: pccs module skeleton — models, CRUD, API, load_path diff --git a/scripts/load_path.py b/scripts/load_path.py new file mode 100644 index 0000000..3fd7822 --- /dev/null +++ b/scripts/load_path.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +"""pccs RBAC 权限管理""" +import subprocess, os, sys, json, glob + +def find_sage_root(): + for c in [os.path.expanduser("~/sage"), os.path.expanduser("~/repos/sage")]: + if os.path.isdir(os.path.join(c, "py3")): return c + return None + +SAGE = find_sage_root() +if not SAGE: sys.exit("Sage root not found") +PY = os.path.join(SAGE, "py3", "bin", "python") +SET = os.path.join(SAGE, "set_role_perm.py") + +JSON_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "json") +API_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "wwwroot", "api") + +def load_cruds(): + defs = [] + for f in sorted(glob.glob(os.path.join(JSON_DIR, "*.json"))): + try: + d = json.load(open(f)) + defs.append({"tblname": d["tblname"], "alias": d.get("alias", d["tblname"]), "subtables": d.get("params", {}).get("subtables", [])}) + except: pass + return defs + +def get_apis(): + if not os.path.isdir(API_DIR): return [] + return [f"/pccs/api/{f}" for f in sorted(os.listdir(API_DIR)) if f.endswith(".dspy")] + +cruds = load_cruds() +apis = get_apis() + +PATHS_ANY = [ + f"/pccs/menu.ui", +] +PATHS_LOGINED = [ + f"/pccs", + f"/pccs/index.ui", +] +for d in cruds: + PATHS_ANY.append(f"/pccs/{d['alias']}") + PATHS_LOGINED.append(f"/pccs/{d['alias']}/index.ui") + for act in ["get", "add", "update", "delete"]: + PATHS_LOGINED.append(f"/pccs/{d['alias']}/{act}_{d['tblname']}.dspy") +for api in apis: + PATHS_LOGINED.append(api) + +PATHS_OPERATOR = list(PATHS_LOGINED) + +PATHS_ANY = list(dict.fromkeys(PATHS_ANY)) +PATHS_LOGINED = list(dict.fromkeys(PATHS_LOGINED)) +PATHS_OPERATOR = list(dict.fromkeys(PATHS_OPERATOR)) + +def reg(role, paths): + ok = 0 + for p in paths: + r = subprocess.run([PY, SET, role, p], capture_output=True, text=True) + if r.returncode == 0: ok += 1 + print(f" {role}: {ok}/{len(paths)}") + return ok + +total = 0 +print(f"{mod_name}: any={len(PATHS_ANY)} logined={len(PATHS_LOGINED)} operator={len(PATHS_OPERATOR)}") +total += reg("any", PATHS_ANY) +total += reg("logined", PATHS_LOGINED) +total += reg("reseller.operator", PATHS_OPERATOR) +print(f"Done. {total} entries.") diff --git a/setup.json b/setup.json new file mode 100644 index 0000000..8146a57 --- /dev/null +++ b/setup.json @@ -0,0 +1,8 @@ +{ + "name": "pccs", + "version": "0.1.0", + "description": "PCCS Sage 顶层模块 — 算力中心集群系统,聚合 pcpool + pcc", + "packages": [], + "install_requires": ["pcpool", "pcc"], + "python_requires": ">=3.10" +} \ No newline at end of file diff --git a/wwwroot/menu.ui b/wwwroot/menu.ui new file mode 100644 index 0000000..3bd862f --- /dev/null +++ b/wwwroot/menu.ui @@ -0,0 +1,19 @@ +{ + "widgettype": "VBox", + "options": {"width": "100%", "height": "100%"}, + "subwidgets": [ + {"widgettype": "Text", "options": {"otext": "算力中心集群系统", "i18n": true, "cfontsize": 1.5, "fontWeight": "bold", "margin": "10px"}}, + {"widgettype": "Tree", "id": "pccs_menu", "options": { + "data": [ + {"id": "pool", "label": "算力池管理", "children": [ + {"id": "pool_list", "label": "算力池列表", "url": "/pcpool/compute_pool_list/index.ui"}, + {"id": "node_list", "label": "算力节点列表", "url": "/pcpool/compute_node_list/index.ui"} + ]}, + {"id": "cluster", "label": "集群管理", "children": [ + {"id": "cluster_list", "label": "集群列表", "url": "/pcc/cluster_list/index.ui"}, + {"id": "cn_list", "label": "节点分配", "url": "/pcc/cluster_node_list/index.ui"} + ]} + ] + }} + ] +}