openhpc-webui 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. openhpc_webui-0.2.0/.github/workflows/python-publish.yml +85 -0
  2. openhpc_webui-0.2.0/.gitignore +5 -0
  3. openhpc_webui-0.2.0/.python-version +1 -0
  4. openhpc_webui-0.2.0/AGENTS.md +37 -0
  5. openhpc_webui-0.2.0/CLAUDE.md +112 -0
  6. openhpc_webui-0.2.0/PKG-INFO +173 -0
  7. openhpc_webui-0.2.0/README.md +161 -0
  8. openhpc_webui-0.2.0/docs/DEPLOYMENT.md +247 -0
  9. openhpc_webui-0.2.0/docs/DISK_QUOTA.md +223 -0
  10. openhpc_webui-0.2.0/docs/LDAP_ROCKY9.md +346 -0
  11. openhpc_webui-0.2.0/docs/SLURM_USAGE_AND_CREDITS.md +231 -0
  12. openhpc_webui-0.2.0/docs/SSSD_LDAP_ROCKY9.md +331 -0
  13. openhpc_webui-0.2.0/docs/TECHNICAL_GUIDE.md +249 -0
  14. openhpc_webui-0.2.0/docs/USER_MANUAL.md +365 -0
  15. openhpc_webui-0.2.0/docs/dashboard.png +0 -0
  16. openhpc_webui-0.2.0/docs/job.png +0 -0
  17. openhpc_webui-0.2.0/docs/login.png +0 -0
  18. openhpc_webui-0.2.0/docs/requirement.md +93 -0
  19. openhpc_webui-0.2.0/docs/slurm.conf +117 -0
  20. openhpc_webui-0.2.0/docs/user.png +0 -0
  21. openhpc_webui-0.2.0/env.example +56 -0
  22. openhpc_webui-0.2.0/openhpc_webui/__about__.py +3 -0
  23. openhpc_webui-0.2.0/openhpc_webui/__init__.py +5 -0
  24. openhpc_webui-0.2.0/openhpc_webui/__main__.py +7 -0
  25. openhpc_webui-0.2.0/openhpc_webui/application.py +1739 -0
  26. openhpc_webui-0.2.0/openhpc_webui/audit.py +318 -0
  27. openhpc_webui-0.2.0/openhpc_webui/cli.py +7 -0
  28. openhpc_webui-0.2.0/openhpc_webui/config.py +60 -0
  29. openhpc_webui-0.2.0/openhpc_webui/schemas.py +183 -0
  30. openhpc_webui-0.2.0/openhpc_webui/services/__init__.py +1 -0
  31. openhpc_webui-0.2.0/openhpc_webui/services/admin_manager.py +180 -0
  32. openhpc_webui-0.2.0/openhpc_webui/services/auth_manager.py +133 -0
  33. openhpc_webui-0.2.0/openhpc_webui/services/ldap_manager.py +472 -0
  34. openhpc_webui-0.2.0/openhpc_webui/services/login_limiter.py +100 -0
  35. openhpc_webui-0.2.0/openhpc_webui/services/nfs_quota_manager.py +204 -0
  36. openhpc_webui-0.2.0/openhpc_webui/services/node_config.py +284 -0
  37. openhpc_webui-0.2.0/openhpc_webui/services/partition_config.py +264 -0
  38. openhpc_webui-0.2.0/openhpc_webui/services/slurm_manager.py +1997 -0
  39. openhpc_webui-0.2.0/openhpc_webui.ini +19 -0
  40. openhpc_webui-0.2.0/pyproject.toml +34 -0
  41. openhpc_webui-0.2.0/scripts/build_tailwind.sh +9 -0
  42. openhpc_webui-0.2.0/scripts/deploy.sh +210 -0
  43. openhpc_webui-0.2.0/scripts/slurm_usage_login.sh +268 -0
  44. openhpc_webui-0.2.0/static/all-tailwind-classes-full-min.css +2 -0
  45. openhpc_webui-0.2.0/static/animations.css +31 -0
  46. openhpc_webui-0.2.0/static/apple-touch-icon.png +0 -0
  47. openhpc_webui-0.2.0/static/compat.css +181 -0
  48. openhpc_webui-0.2.0/static/favicon-32.png +0 -0
  49. openhpc_webui-0.2.0/static/favicon.svg +21 -0
  50. openhpc_webui-0.2.0/static/main.js +1230 -0
  51. openhpc_webui-0.2.0/static/nodes.js +400 -0
  52. openhpc_webui-0.2.0/static/partitions.js +420 -0
  53. openhpc_webui-0.2.0/tailwind.css +6 -0
  54. openhpc_webui-0.2.0/templates/account.html +95 -0
  55. openhpc_webui-0.2.0/templates/accounts.html +369 -0
  56. openhpc_webui-0.2.0/templates/admin.html +637 -0
  57. openhpc_webui-0.2.0/templates/base.html +580 -0
  58. openhpc_webui-0.2.0/templates/cluster_users.html +538 -0
  59. openhpc_webui-0.2.0/templates/components/breadcrumb.html +46 -0
  60. openhpc_webui-0.2.0/templates/components/sidebar.html +337 -0
  61. openhpc_webui-0.2.0/templates/groups.html +320 -0
  62. openhpc_webui-0.2.0/templates/index.html +306 -0
  63. openhpc_webui-0.2.0/templates/jobs.html +741 -0
  64. openhpc_webui-0.2.0/templates/login.html +722 -0
  65. openhpc_webui-0.2.0/templates/nodes.html +202 -0
  66. openhpc_webui-0.2.0/templates/partitions.html +210 -0
  67. openhpc_webui-0.2.0/templates/qos.html +68 -0
  68. openhpc_webui-0.2.0/templates/slurm_guide.html +233 -0
  69. openhpc_webui-0.2.0/templates/user_dashboard.html +260 -0
  70. openhpc_webui-0.2.0/templates/users.html +1330 -0
  71. openhpc_webui-0.2.0/tests/test_application_factory.py +31 -0
  72. openhpc_webui-0.2.0/tests/test_audit_logging.py +112 -0
  73. openhpc_webui-0.2.0/tests/test_dashboard.py +76 -0
  74. openhpc_webui-0.2.0/tests/test_ldap_user_display_name.py +106 -0
  75. openhpc_webui-0.2.0/tests/test_login_limiter.py +125 -0
  76. openhpc_webui-0.2.0/tests/test_nfs_quota_manager.py +147 -0
  77. openhpc_webui-0.2.0/tests/test_security_and_config.py +461 -0
  78. openhpc_webui-0.2.0/tests/test_slurm_credits.py +391 -0
  79. openhpc_webui-0.2.0/tests/test_slurm_jobs.py +32 -0
  80. openhpc_webui-0.2.0/tests/test_slurm_qos.py +60 -0
  81. openhpc_webui-0.2.0/tests/test_slurm_reports.py +157 -0
  82. openhpc_webui-0.2.0/tests/test_tailwind_assets.py +29 -0
  83. openhpc_webui-0.2.0/uv.lock +2110 -0
@@ -0,0 +1,85 @@
1
+ # This workflow will upload a Python Package to PyPI when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ concurrency:
16
+ group: pypi-publish
17
+ cancel-in-progress: false
18
+
19
+ permissions:
20
+ contents: read
21
+
22
+ jobs:
23
+ release-build:
24
+ runs-on: ubuntu-latest
25
+
26
+ steps:
27
+ - name: Check out release source
28
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
29
+
30
+ - name: Set up Python
31
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
32
+ with:
33
+ python-version: "3.11"
34
+
35
+ - name: Verify release version
36
+ env:
37
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
38
+ run: |
39
+ PACKAGE_VERSION="$(python -c 'from openhpc_webui import __version__; print(__version__)')"
40
+ if [ "$RELEASE_TAG" != "v$PACKAGE_VERSION" ]; then
41
+ echo "Release tag $RELEASE_TAG does not match package version $PACKAGE_VERSION" >&2
42
+ exit 1
43
+ fi
44
+
45
+ - name: Install build and test dependencies
46
+ run: python -m pip install "build==1.3.0" .
47
+
48
+ - name: Run tests
49
+ run: python -m unittest discover -s tests
50
+
51
+ - name: Build release distributions
52
+ run: python -m build
53
+
54
+ - name: Upload distributions
55
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
56
+ with:
57
+ name: release-dists
58
+ path: dist/
59
+ if-no-files-found: error
60
+
61
+ pypi-publish:
62
+ runs-on: ubuntu-latest
63
+ needs:
64
+ - release-build
65
+ permissions:
66
+ # IMPORTANT: this permission is mandatory for trusted publishing
67
+ id-token: write
68
+
69
+ # Dedicated environments with protections for publishing are strongly recommended.
70
+ # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
71
+ environment:
72
+ name: pypi
73
+ url: https://pypi.org/project/openhpc-webui/
74
+
75
+ steps:
76
+ - name: Retrieve release distributions
77
+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
78
+ with:
79
+ name: release-dists
80
+ path: dist/
81
+
82
+ - name: Publish release distributions to PyPI
83
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
84
+ with:
85
+ packages-dir: dist/
@@ -0,0 +1,5 @@
1
+ .env
2
+ __pycache__/
3
+ .venv
4
+ .Ds_Store
5
+ .playwright-cli
@@ -0,0 +1 @@
1
+ 3.9
@@ -0,0 +1,37 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ - `openhpc_webui/application.py` contains the FastAPI application factory and route layer.
5
+ - Core integrations live in `openhpc_webui/services/`; request models and settings live in `openhpc_webui/schemas.py` and `openhpc_webui/config.py`.
6
+ - UI templates are in `templates/` (with shared layout/components in `templates/base.html` and `templates/components/`).
7
+ - Frontend static assets are in `static/` (offline Tailwind CSS bundle plus page scripts).
8
+ - Operations/deployment docs are in `README.md`, `docs/DEPLOYMENT.md`, and `docs/USER_MANUAL.md`.
9
+
10
+ ## Build, Test, and Development Commands
11
+ - `uv sync` installs Python dependencies into the project environment.
12
+ - `uvicorn openhpc_webui.application:app --reload --port 6827` starts local development server with auto-reload.
13
+ - `uvicorn openhpc_webui.application:app --host 127.0.0.1 --port 6827 --proxy-headers --forwarded-allow-ips=127.0.0.1` runs a production-style local binding behind Nginx.
14
+ - `python -m compileall -q openhpc_webui` performs a quick syntax validation pass.
15
+ - `bash update_offline.sh` refreshes offline assets/content for disconnected deployment scenarios.
16
+
17
+ ## Coding Style & Naming Conventions
18
+ - Target Python `>=3.9`; follow PEP 8 and keep 4-space indentation.
19
+ - Use `snake_case` for modules, functions, and variables; use clear action-based names (for example, `create_user`, `get_partition_status`).
20
+ - Prefer type hints for public functions and API helpers.
21
+ - Keep route handlers thin; place LDAP/Slurm logic in manager modules.
22
+ - Templates and static files should use feature-oriented names (for example, `jobs.html`, `nodes.js`).
23
+
24
+ ## Testing Guidelines
25
+ - Automated tests live under `tests/`; extend them when introducing non-trivial logic.
26
+ - Name test files `test_<module>.py` and test functions `test_<behavior>()`.
27
+ - Before opening a PR, run syntax checks and manually verify key flows: login, user/group CRUD, partition/node/jobs pages.
28
+
29
+ ## Commit & Pull Request Guidelines
30
+ - Follow the repository’s existing style: short, imperative, task-focused subjects (examples: `Add auth toggle`, `修复节点数据异常问题`).
31
+ - Keep each commit scoped to one logical change.
32
+ - PRs should include: purpose, changed modules/templates, manual verification steps, related issue/task, and UI screenshots for template/static changes.
33
+
34
+ ## Security & Configuration Tips
35
+ - Never commit real credentials; keep `.env` local and start from `env.example`.
36
+ - Rotate `SECRET_KEY` and LDAP admin credentials in production.
37
+ - Validate Slurm command permissions and run behind internal network controls.
@@ -0,0 +1,112 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a lightweight web management portal for HPC centers, built to run in offline intranet environments. It manages LDAP identity systems, Slurm cluster resources, and job status.
8
+
9
+ **Key Characteristics:**
10
+ - All-Chinese UI interface (全中文界面)
11
+ - Theme color: #dc3023 (China Red / Research Red)
12
+ - Offline deployment: All static resources must be localized (no external CDNs)
13
+ - Minimalist, professional admin dashboard aesthetic
14
+ - Target environment: Python 3.9+
15
+
16
+ ## Development Commands
17
+
18
+ ### Running the Application
19
+ ```bash
20
+ # Development server (from project root)
21
+ uvicorn openhpc_webui.application:app --reload --port 6827
22
+
23
+ # Production server
24
+ uvicorn openhpc_webui.application:app --host 127.0.0.1 --port 6827 --proxy-headers --forwarded-allow-ips=127.0.0.1
25
+ ```
26
+
27
+ ### Package Management
28
+ This project uses `uv` for dependency management:
29
+ ```bash
30
+ # Install dependencies
31
+ uv sync
32
+
33
+ # Add a new dependency
34
+ uv add <package-name>
35
+
36
+ # Activate virtual environment
37
+ source .venv/bin/activate
38
+ ```
39
+
40
+ ## Architecture Overview
41
+
42
+ ### Technology Stack
43
+ - **Backend:** FastAPI (Python 3.9+)
44
+ - **Frontend:** Native HTML/JS + Tailwind CSS (must be localized)
45
+ - **Authentication:** LDAP Admin binding
46
+ - **Dependencies:** python-ldap, pyslurm (or subprocess-based Slurm CLI parsing), uvicorn
47
+
48
+ ### Planned Module Structure
49
+
50
+ 1. **LDAP User & Group Management** (`/users`)
51
+ - User CRUD operations (list, create with UID/GID/home/shell, password change, delete)
52
+ - Group management with user assignment
53
+ - LDAP connection health checks
54
+
55
+ 2. **Slurm Resource Management** (`/partitions`)
56
+ - Partition overview (name, node status: Alloc/Idle/Down, quotas)
57
+ - Node monitoring (status, CPU/VRAM usage)
58
+ - Partition control (Up/Down operations)
59
+
60
+ 3. **Job Management** (`/jobs`)
61
+ - Real-time job queue from `squeue` (JobID, user, partition, status, runtime, nodes)
62
+ - Job details (submission script, output paths)
63
+ - Admin job cancellation via `scancel`
64
+
65
+ 4. **Dashboard** (`/dashboard`)
66
+ - Overview metrics: total users, active jobs, idle nodes
67
+
68
+ ### UI/UX Guidelines
69
+ - **Layout:** Fixed left sidebar navigation, top breadcrumb, main content area on right
70
+ - **Colors:**
71
+ - Primary: #dc3023 (navigation, buttons, logo)
72
+ - Background: #f8f9fa (light gray)
73
+ - Text: #1a1a1a
74
+ - **Components:**
75
+ - Card-style containers with subtle shadows
76
+ - Compact tables with column sorting
77
+ - Status badges: Running (green), Queued (yellow), Completed/Failed (gray/red)
78
+ - **Fonts:** System sans-serif (PingFang SC, Microsoft YaHei)
79
+
80
+ ### Offline Requirements (Critical)
81
+ - **NO external CDN dependencies** (Tailwind, FontAwesome, Google Fonts)
82
+ - All CSS/JS must be in `static/` directory
83
+ - Use system fonts only
84
+
85
+ ## Development Guidelines
86
+
87
+ ### File Organization
88
+ - `openhpc_webui/application.py` - FastAPI application factory and route layer
89
+ - `openhpc_webui/services/` - LDAP, Slurm, quota, and system integrations
90
+ - `openhpc_webui/schemas.py` - API request models
91
+ - `openhpc_webui/config.py` - environment settings and runtime paths
92
+ - `templates/` - HTML templates (Jinja2)
93
+ - `static/` - All CSS, JS, and static assets (must be self-contained)
94
+ - `requirement.md` - Complete project requirements in Chinese
95
+
96
+ ### Slurm Integration Notes
97
+ - Parse Slurm commands via subprocess: `sinfo --json`, `squeue`, `sacct`
98
+ - Implement proper error handling for LDAP connection failures
99
+ - All Slurm operations require admin privileges verification
100
+
101
+ ### Security Considerations
102
+ - LDAP admin credentials must be securely configured
103
+ - Validate all user inputs before LDAP/Slurm operations
104
+ - Implement proper session management for admin authentication
105
+ - Add confirmation modals for destructive operations (delete user, cancel job)
106
+
107
+ ## Important Context
108
+
109
+ - This is designed for **internal network deployment only** - no internet access assumed
110
+ - All UI text should be in **Chinese**
111
+ - When implementing Slurm features, prefer JSON output formats where available (`sinfo --json`)
112
+ - Use Tailwind utility classes but ensure the CSS file is bundled locally in `static/`
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.5
2
+ Name: openhpc_webui
3
+ Version: 0.2.0
4
+ Summary: openhpc_webui
5
+ Requires-Python: >=3.9
6
+ Requires-Dist: fastapi[standard]<0.129,>=0.128.0
7
+ Requires-Dist: itsdangerous>=2.2.0
8
+ Requires-Dist: jinja2>=3.1.6
9
+ Requires-Dist: ldap3>=2.9.1
10
+ Requires-Dist: python-dotenv>=1.2.1
11
+ Description-Content-Type: text/markdown
12
+
13
+ # openhpc_webui
14
+
15
+ `openhpc_webui` 是面向高校、科研机构和企业智算中心的轻量级中文管理门户。项目将 OpenLDAP 身份管理、Slurm 账户与关联、分区和节点配置、作业状态及输出查看集中到同一个 Web 界面,适合内网和离线环境。
16
+
17
+ 当前版本:`0.2.0`
18
+
19
+ ## 功能概览
20
+
21
+ | 模块 | 主要能力 |
22
+ | --- | --- |
23
+ | 系统总览 | LDAP 用户数、活动作业、空闲节点、近期作业和分区状态 |
24
+ | 用户管理 | LDAP 用户增删改、禁用、SSH 密钥、存储配额、核时/卡时和作业报表 |
25
+ | 组管理 | LDAP 组创建、编辑、删除及成员信息查看 |
26
+ | 账户管理 | Slurm 账户创建、编辑和删除 |
27
+ | 集群用户 | Slurm Association、QOS、默认 QOS、分区和 TRES Minutes 管理 |
28
+ | 分区管理 | Slurm 分区配置、节点状态统计及配置重载 |
29
+ | 节点管理 | 节点配置维护、Drain、Resume 和状态查看 |
30
+ | 作业管理 | 活动作业、近期完成作业、详情、取消及标准输出/错误查看 |
31
+ | 权限管理 | 门户管理员授权与撤销 |
32
+
33
+ 页面资源随项目提供,不依赖外部 CDN。列表采用固定表头、对齐的数字和状态列,并在内容溢出时提供横向滚动。
34
+
35
+ ## 权限模型
36
+
37
+ | 能力 | 管理员 | 普通用户 |
38
+ | --- | :---: | :---: |
39
+ | 系统总览和管理页面 | 是 | 否 |
40
+ | 查看全部活动及近期完成作业 | 是 | 是 |
41
+ | 查看作业详情 | 是 | 是 |
42
+ | 查看作业输出 | 任意作业 | 仅自己的作业 |
43
+ | 取消作业 | 任意作业 | 仅自己的作业 |
44
+ | 修改自己的 LDAP 密码 | 是 | 是 |
45
+
46
+ 管理员由 `ADMIN_USERS` 配置,也可以在权限管理页面在线维护。普通用户访问管理员页面时会被重定向到作业页面。
47
+
48
+ ## 界面预览
49
+
50
+ ### 登录
51
+
52
+ ![openhpc_webui 登录界面](./docs/login.png)
53
+
54
+ ### 系统总览
55
+
56
+ ![openhpc_webui 系统总览](./docs/dashboard.png)
57
+
58
+ ### 用户管理
59
+
60
+ ![openhpc_webui 用户管理](./docs/user.png)
61
+
62
+ ### 作业管理
63
+
64
+ ![openhpc_webui 作业管理](./docs/job.png)
65
+
66
+ ## 技术栈
67
+
68
+ - Python 3.9+
69
+ - FastAPI、Jinja2 和 Uvicorn
70
+ - ldap3 / OpenLDAP
71
+ - Slurm CLI:`sinfo`、`squeue`、`sacct`、`scontrol`、`sacctmgr`、`scancel`
72
+ - uv 依赖与环境管理
73
+ - Tailwind CSS CLI 4.x(仅在修改模板或前端脚本中的工具类后重新构建)
74
+
75
+ ## 项目结构
76
+
77
+ ```text
78
+ openhpc_webui/
79
+ ├── openhpc_webui/
80
+ │ ├── application.py # FastAPI 路由与接口
81
+ │ ├── cli.py # 命令行入口
82
+ │ ├── core/ # 配置、认证和公共能力
83
+ │ ├── models/ # 请求与响应模型
84
+ │ └── services/ # LDAP、Slurm 和系统集成
85
+ ├── templates/ # Jinja2 页面模板
86
+ ├── static/ # 离线 CSS、JavaScript 和图标
87
+ ├── tests/ # 自动化测试
88
+ ├── docs/ # 使用、部署和运维文档
89
+ ├── env.example # 环境变量示例
90
+ └── pyproject.toml # 项目元数据与依赖
91
+ ```
92
+
93
+ ## 环境要求
94
+
95
+ 运行门户的主机需要:
96
+
97
+ - 能够访问 OpenLDAP 服务;
98
+ - 安装 Slurm 客户端命令,并能连接 Slurm 控制端;
99
+ - 对节点和分区配置文件具有业务所需的读写权限;
100
+ - 使用 NFS 配额时安装并配置 `quota` / `setquota`;
101
+ - 生产环境具备 Nginx、Supervisor 或等效的进程管理能力。
102
+
103
+ Web 管理员身份不会绕过 Linux 文件权限或 Slurm 权限。
104
+
105
+ ## 快速开始
106
+
107
+ ```bash
108
+ uv sync
109
+ cp env.example .env
110
+ uv run uvicorn openhpc_webui.application:app --reload --port 6827
111
+ ```
112
+
113
+ 浏览器访问 `http://127.0.0.1:6827`。也可以使用项目命令启动监听在 `0.0.0.0:6827` 的服务:
114
+
115
+ ```bash
116
+ uv run openhpc_webui
117
+ ```
118
+
119
+ ### 最小配置
120
+
121
+ 编辑 `.env`,至少确认以下配置:
122
+
123
+ | 配置项 | 用途 |
124
+ | --- | --- |
125
+ | `LDAP_URI` | LDAP 服务地址 |
126
+ | `LDAP_BASE_DN` | LDAP Base DN |
127
+ | `LDAP_DEFAULT_BIND_DN` | 管理 Bind DN |
128
+ | `LDAP_DEFAULT_AUTHTOK` | 管理 Bind 密码 |
129
+ | `SECRET_KEY` | Session 签名密钥,生产环境不少于 32 个随机字符 |
130
+ | `AUTHORIZED` | 是否启用登录认证,生产环境必须为 `True` |
131
+ | `ADMIN_USERS` | 管理员用户名,多个值使用英文逗号分隔 |
132
+ | `SLURM_DEFAULT_ACCOUNT` | 创建 LDAP 用户时使用的默认 Slurm 账户 |
133
+ | `SLURM_CONFIG_DIR` | 节点与分区配置文件目录,默认 `/etc/slurm` |
134
+
135
+ 完整配置说明见[技术指南](./docs/TECHNICAL_GUIDE.md)。
136
+
137
+ ## 生产部署
138
+
139
+ 生产环境建议由 Supervisor 管理 Uvicorn,并仅监听 `127.0.0.1:6827`;由 Nginx 提供 HTTPS 和反向代理。不要直接将开发服务器暴露到公网。
140
+
141
+ 部署步骤、自签发证书、服务管理和升级方法见[生产部署指南](./docs/DEPLOYMENT.md)。
142
+
143
+ ## 文档
144
+
145
+ - [用户使用手册](./docs/USER_MANUAL.md):管理员和普通用户的页面操作说明
146
+ - [技术指南](./docs/TECHNICAL_GUIDE.md):配置、运行、架构、测试与故障排查
147
+ - [生产部署指南](./docs/DEPLOYMENT.md):Supervisor、Nginx、HTTPS 和升级
148
+ - [磁盘配额指南](./docs/DISK_QUOTA.md):XFS `/home` 配额启用、验证和 Web UI 配置
149
+ - [核时统计与额度拨付](./docs/SLURM_USAGE_AND_CREDITS.md):统计口径、Slurm 命令、拨付算法和登录提示脚本
150
+ - [Rocky Linux 9 LDAP 部署](./docs/LDAP_ROCKY9.md):OpenLDAP 安装与初始化
151
+ - [Rocky Linux 9 SSSD 接入](./docs/SSSD_LDAP_ROCKY9.md):计算节点接入 LDAP 身份
152
+
153
+ ## 验证与开发
154
+
155
+ ```bash
156
+ ./scripts/build_tailwind.sh
157
+ uv run python -m unittest discover -s tests
158
+ uv run python -m compileall -q openhpc_webui
159
+ ```
160
+
161
+ Tailwind 构建入口为 `tailwind.css`,只扫描 `templates/` 和 `static/*.js` 中实际使用的类,并将压缩后的离线样式写入 `static/all-tailwind-classes-full-min.css`。
162
+
163
+ 提交界面变更前,还应手动检查登录、用户、组、账户、集群用户、分区、节点、作业和权限页面,并附上桌面与窄屏截图。
164
+
165
+ ## 安全建议
166
+
167
+ - 仅在受控内网开放门户,并使用防火墙限制来源。
168
+ - 生产环境启用 HTTPS,并将 `SESSION_HTTPS_ONLY` 设为 `True`。
169
+ - 不要提交 `.env`、LDAP 管理密码、Session 密钥或真实用户数据。
170
+ - 仅授予运行账户完成 LDAP、Slurm 和配置文件操作所需的最小权限。
171
+ - 定期审计管理员列表、Slurm 操作和应用日志。
172
+
173
+ 本项目是集群管理辅助工具,不替代 Slurm、LDAP、监控平台或审计系统本身。
@@ -0,0 +1,161 @@
1
+ # openhpc_webui
2
+
3
+ `openhpc_webui` 是面向高校、科研机构和企业智算中心的轻量级中文管理门户。项目将 OpenLDAP 身份管理、Slurm 账户与关联、分区和节点配置、作业状态及输出查看集中到同一个 Web 界面,适合内网和离线环境。
4
+
5
+ 当前版本:`0.2.0`
6
+
7
+ ## 功能概览
8
+
9
+ | 模块 | 主要能力 |
10
+ | --- | --- |
11
+ | 系统总览 | LDAP 用户数、活动作业、空闲节点、近期作业和分区状态 |
12
+ | 用户管理 | LDAP 用户增删改、禁用、SSH 密钥、存储配额、核时/卡时和作业报表 |
13
+ | 组管理 | LDAP 组创建、编辑、删除及成员信息查看 |
14
+ | 账户管理 | Slurm 账户创建、编辑和删除 |
15
+ | 集群用户 | Slurm Association、QOS、默认 QOS、分区和 TRES Minutes 管理 |
16
+ | 分区管理 | Slurm 分区配置、节点状态统计及配置重载 |
17
+ | 节点管理 | 节点配置维护、Drain、Resume 和状态查看 |
18
+ | 作业管理 | 活动作业、近期完成作业、详情、取消及标准输出/错误查看 |
19
+ | 权限管理 | 门户管理员授权与撤销 |
20
+
21
+ 页面资源随项目提供,不依赖外部 CDN。列表采用固定表头、对齐的数字和状态列,并在内容溢出时提供横向滚动。
22
+
23
+ ## 权限模型
24
+
25
+ | 能力 | 管理员 | 普通用户 |
26
+ | --- | :---: | :---: |
27
+ | 系统总览和管理页面 | 是 | 否 |
28
+ | 查看全部活动及近期完成作业 | 是 | 是 |
29
+ | 查看作业详情 | 是 | 是 |
30
+ | 查看作业输出 | 任意作业 | 仅自己的作业 |
31
+ | 取消作业 | 任意作业 | 仅自己的作业 |
32
+ | 修改自己的 LDAP 密码 | 是 | 是 |
33
+
34
+ 管理员由 `ADMIN_USERS` 配置,也可以在权限管理页面在线维护。普通用户访问管理员页面时会被重定向到作业页面。
35
+
36
+ ## 界面预览
37
+
38
+ ### 登录
39
+
40
+ ![openhpc_webui 登录界面](./docs/login.png)
41
+
42
+ ### 系统总览
43
+
44
+ ![openhpc_webui 系统总览](./docs/dashboard.png)
45
+
46
+ ### 用户管理
47
+
48
+ ![openhpc_webui 用户管理](./docs/user.png)
49
+
50
+ ### 作业管理
51
+
52
+ ![openhpc_webui 作业管理](./docs/job.png)
53
+
54
+ ## 技术栈
55
+
56
+ - Python 3.9+
57
+ - FastAPI、Jinja2 和 Uvicorn
58
+ - ldap3 / OpenLDAP
59
+ - Slurm CLI:`sinfo`、`squeue`、`sacct`、`scontrol`、`sacctmgr`、`scancel`
60
+ - uv 依赖与环境管理
61
+ - Tailwind CSS CLI 4.x(仅在修改模板或前端脚本中的工具类后重新构建)
62
+
63
+ ## 项目结构
64
+
65
+ ```text
66
+ openhpc_webui/
67
+ ├── openhpc_webui/
68
+ │ ├── application.py # FastAPI 路由与接口
69
+ │ ├── cli.py # 命令行入口
70
+ │ ├── core/ # 配置、认证和公共能力
71
+ │ ├── models/ # 请求与响应模型
72
+ │ └── services/ # LDAP、Slurm 和系统集成
73
+ ├── templates/ # Jinja2 页面模板
74
+ ├── static/ # 离线 CSS、JavaScript 和图标
75
+ ├── tests/ # 自动化测试
76
+ ├── docs/ # 使用、部署和运维文档
77
+ ├── env.example # 环境变量示例
78
+ └── pyproject.toml # 项目元数据与依赖
79
+ ```
80
+
81
+ ## 环境要求
82
+
83
+ 运行门户的主机需要:
84
+
85
+ - 能够访问 OpenLDAP 服务;
86
+ - 安装 Slurm 客户端命令,并能连接 Slurm 控制端;
87
+ - 对节点和分区配置文件具有业务所需的读写权限;
88
+ - 使用 NFS 配额时安装并配置 `quota` / `setquota`;
89
+ - 生产环境具备 Nginx、Supervisor 或等效的进程管理能力。
90
+
91
+ Web 管理员身份不会绕过 Linux 文件权限或 Slurm 权限。
92
+
93
+ ## 快速开始
94
+
95
+ ```bash
96
+ uv sync
97
+ cp env.example .env
98
+ uv run uvicorn openhpc_webui.application:app --reload --port 6827
99
+ ```
100
+
101
+ 浏览器访问 `http://127.0.0.1:6827`。也可以使用项目命令启动监听在 `0.0.0.0:6827` 的服务:
102
+
103
+ ```bash
104
+ uv run openhpc_webui
105
+ ```
106
+
107
+ ### 最小配置
108
+
109
+ 编辑 `.env`,至少确认以下配置:
110
+
111
+ | 配置项 | 用途 |
112
+ | --- | --- |
113
+ | `LDAP_URI` | LDAP 服务地址 |
114
+ | `LDAP_BASE_DN` | LDAP Base DN |
115
+ | `LDAP_DEFAULT_BIND_DN` | 管理 Bind DN |
116
+ | `LDAP_DEFAULT_AUTHTOK` | 管理 Bind 密码 |
117
+ | `SECRET_KEY` | Session 签名密钥,生产环境不少于 32 个随机字符 |
118
+ | `AUTHORIZED` | 是否启用登录认证,生产环境必须为 `True` |
119
+ | `ADMIN_USERS` | 管理员用户名,多个值使用英文逗号分隔 |
120
+ | `SLURM_DEFAULT_ACCOUNT` | 创建 LDAP 用户时使用的默认 Slurm 账户 |
121
+ | `SLURM_CONFIG_DIR` | 节点与分区配置文件目录,默认 `/etc/slurm` |
122
+
123
+ 完整配置说明见[技术指南](./docs/TECHNICAL_GUIDE.md)。
124
+
125
+ ## 生产部署
126
+
127
+ 生产环境建议由 Supervisor 管理 Uvicorn,并仅监听 `127.0.0.1:6827`;由 Nginx 提供 HTTPS 和反向代理。不要直接将开发服务器暴露到公网。
128
+
129
+ 部署步骤、自签发证书、服务管理和升级方法见[生产部署指南](./docs/DEPLOYMENT.md)。
130
+
131
+ ## 文档
132
+
133
+ - [用户使用手册](./docs/USER_MANUAL.md):管理员和普通用户的页面操作说明
134
+ - [技术指南](./docs/TECHNICAL_GUIDE.md):配置、运行、架构、测试与故障排查
135
+ - [生产部署指南](./docs/DEPLOYMENT.md):Supervisor、Nginx、HTTPS 和升级
136
+ - [磁盘配额指南](./docs/DISK_QUOTA.md):XFS `/home` 配额启用、验证和 Web UI 配置
137
+ - [核时统计与额度拨付](./docs/SLURM_USAGE_AND_CREDITS.md):统计口径、Slurm 命令、拨付算法和登录提示脚本
138
+ - [Rocky Linux 9 LDAP 部署](./docs/LDAP_ROCKY9.md):OpenLDAP 安装与初始化
139
+ - [Rocky Linux 9 SSSD 接入](./docs/SSSD_LDAP_ROCKY9.md):计算节点接入 LDAP 身份
140
+
141
+ ## 验证与开发
142
+
143
+ ```bash
144
+ ./scripts/build_tailwind.sh
145
+ uv run python -m unittest discover -s tests
146
+ uv run python -m compileall -q openhpc_webui
147
+ ```
148
+
149
+ Tailwind 构建入口为 `tailwind.css`,只扫描 `templates/` 和 `static/*.js` 中实际使用的类,并将压缩后的离线样式写入 `static/all-tailwind-classes-full-min.css`。
150
+
151
+ 提交界面变更前,还应手动检查登录、用户、组、账户、集群用户、分区、节点、作业和权限页面,并附上桌面与窄屏截图。
152
+
153
+ ## 安全建议
154
+
155
+ - 仅在受控内网开放门户,并使用防火墙限制来源。
156
+ - 生产环境启用 HTTPS,并将 `SESSION_HTTPS_ONLY` 设为 `True`。
157
+ - 不要提交 `.env`、LDAP 管理密码、Session 密钥或真实用户数据。
158
+ - 仅授予运行账户完成 LDAP、Slurm 和配置文件操作所需的最小权限。
159
+ - 定期审计管理员列表、Slurm 操作和应用日志。
160
+
161
+ 本项目是集群管理辅助工具,不替代 Slurm、LDAP、监控平台或审计系统本身。