nw-kanseitou 0.2.1__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 (108) hide show
  1. nw_kanseitou-0.2.1/LICENSE +21 -0
  2. nw_kanseitou-0.2.1/PKG-INFO +115 -0
  3. nw_kanseitou-0.2.1/README.md +91 -0
  4. nw_kanseitou-0.2.1/pyproject.toml +235 -0
  5. nw_kanseitou-0.2.1/pyproject.toml.orig +185 -0
  6. nw_kanseitou-0.2.1/src/nw_kanseitou/__init__.py +1 -0
  7. nw_kanseitou-0.2.1/src/nw_kanseitou/accounts.py +116 -0
  8. nw_kanseitou-0.2.1/src/nw_kanseitou/build.py +248 -0
  9. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/__init__.py +4 -0
  10. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/api.py +35 -0
  11. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/apps.py +7 -0
  12. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/engine.py +280 -0
  13. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/inventory.py +45 -0
  14. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/job/__init__.py +0 -0
  15. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/job/run.py +83 -0
  16. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/jobs.py +180 -0
  17. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/migrations/0001_initial.py +44 -0
  18. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/migrations/0002_reads.py +37 -0
  19. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/migrations/0003_image.py +22 -0
  20. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/migrations/__init__.py +0 -0
  21. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/models.py +50 -0
  22. nw_kanseitou-0.2.1/src/nw_kanseitou/execution/specs.py +151 -0
  23. nw_kanseitou-0.2.1/src/nw_kanseitou/init.py +321 -0
  24. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/__init__.py +4 -0
  25. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/api.py +138 -0
  26. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/apps.py +26 -0
  27. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/close.py +168 -0
  28. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/management/__init__.py +0 -0
  29. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/management/commands/__init__.py +0 -0
  30. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/management/commands/check_ledger.py +21 -0
  31. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/netbox.py +151 -0
  32. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/port.py +51 -0
  33. nw_kanseitou-0.2.1/src/nw_kanseitou/ledger/shapes.py +33 -0
  34. nw_kanseitou-0.2.1/src/nw_kanseitou/manage.py +85 -0
  35. nw_kanseitou-0.2.1/src/nw_kanseitou/management/__init__.py +0 -0
  36. nw_kanseitou-0.2.1/src/nw_kanseitou/management/commands/__init__.py +0 -0
  37. nw_kanseitou-0.2.1/src/nw_kanseitou/management/commands/run_worker.py +18 -0
  38. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/__init__.py +528 -0
  39. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/realm.py +99 -0
  40. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/framework-postgres.yaml +38 -0
  41. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/framework.yaml +133 -0
  42. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/gateway.yaml +31 -0
  43. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/keycloak-netbox.yaml +13 -0
  44. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/keycloak-postgres.yaml +15 -0
  45. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/keycloak.yaml +93 -0
  46. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/netbox-postgres.yaml +47 -0
  47. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/netbox.yaml +164 -0
  48. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/postgres-keycloak.yaml +9 -0
  49. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/postgres-netbox.yaml +9 -0
  50. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/postgres.yaml +58 -0
  51. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/realm-netbox.yaml +12 -0
  52. nw_kanseitou-0.2.1/src/nw_kanseitou/manifests/templates/realm.yaml +36 -0
  53. nw_kanseitou-0.2.1/src/nw_kanseitou/netbox_models.py +52 -0
  54. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/__init__.py +4 -0
  55. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/api.py +6 -0
  56. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/apps.py +7 -0
  57. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/engine.py +146 -0
  58. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/migrations/0001_initial.py +41 -0
  59. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/migrations/__init__.py +0 -0
  60. nw_kanseitou-0.2.1/src/nw_kanseitou/notify/models.py +32 -0
  61. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/__init__.py +4 -0
  62. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/api.py +86 -0
  63. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/apps.py +7 -0
  64. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/customer.py +63 -0
  65. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/engine.py +1167 -0
  66. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/fingerprint.py +25 -0
  67. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/forms.py +75 -0
  68. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0001_initial.py +97 -0
  69. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0002_audit_append_only.py +29 -0
  70. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0003_marks.py +22 -0
  71. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0004_lost.py +39 -0
  72. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0005_scope.py +17 -0
  73. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0006_read_kinds.py +31 -0
  74. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0007_contents.py +17 -0
  75. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0008_affiliation.py +17 -0
  76. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/0009_notice_failed.py +32 -0
  77. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/migrations/__init__.py +0 -0
  78. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/models.py +106 -0
  79. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/_fields.html +5 -0
  80. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/_problems.html +1 -0
  81. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/_status.html +44 -0
  82. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/detail.html +57 -0
  83. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/index.html +21 -0
  84. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/new.html +22 -0
  85. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/requester.html +12 -0
  86. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/templates/orders/stuck.html +20 -0
  87. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/urls.py +17 -0
  88. nw_kanseitou-0.2.1/src/nw_kanseitou/orders/views.py +271 -0
  89. nw_kanseitou-0.2.1/src/nw_kanseitou/plugins/__init__.py +12 -0
  90. nw_kanseitou-0.2.1/src/nw_kanseitou/plugins/apps.py +15 -0
  91. nw_kanseitou-0.2.1/src/nw_kanseitou/plugins/loading.py +195 -0
  92. nw_kanseitou-0.2.1/src/nw_kanseitou/py.typed +0 -0
  93. nw_kanseitou-0.2.1/src/nw_kanseitou/repository.py +71 -0
  94. nw_kanseitou-0.2.1/src/nw_kanseitou/settings.py +205 -0
  95. nw_kanseitou-0.2.1/src/nw_kanseitou/static/network_order/htmx.min.js +1 -0
  96. nw_kanseitou-0.2.1/src/nw_kanseitou/templates/base.html +43 -0
  97. nw_kanseitou-0.2.1/src/nw_kanseitou/urls.py +34 -0
  98. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/__init__.py +162 -0
  99. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/attachments.py +62 -0
  100. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/behavior.py +389 -0
  101. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/close.py +193 -0
  102. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/conditions.py +191 -0
  103. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/department.py +375 -0
  104. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/errors.py +5 -0
  105. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/flow.py +361 -0
  106. nw_kanseitou-0.2.1/src/nw_kanseitou/vocab/notices.py +105 -0
  107. nw_kanseitou-0.2.1/src/nw_kanseitou/worker.py +133 -0
  108. nw_kanseitou-0.2.1/src/nw_kanseitou/wsgi.py +7 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rucdev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: nw-kanseitou
3
+ Version: 0.2.1
4
+ Summary: ネットワーク・インフラ部署のための、OSS の合成フレームワーク
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Dist: authlib>=1.9.10
8
+ Requires-Dist: django>=6.1.3
9
+ Requires-Dist: granian>=2.8.8
10
+ Requires-Dist: httpx>=0.28.1
11
+ Requires-Dist: kubernetes>=37.0.3
12
+ Requires-Dist: packaging>=26.3
13
+ Requires-Dist: psycopg[binary]>=3.3.9
14
+ Requires-Dist: pydantic>=2.14.4
15
+ Requires-Dist: pydantic-settings>=2.16.3
16
+ Requires-Dist: pyyaml>=6.0.3
17
+ Requires-Dist: requests>=2.34.2
18
+ Requires-Dist: whitenoise>=6.12.0
19
+ Requires-Python: >=3.14
20
+ Project-URL: Documentation, https://rucdev.gitlab.io/nw-kanseitou/
21
+ Project-URL: Source, https://gitlab.com/rucdev/nw-kanseitou
22
+ Project-URL: Issues, https://gitlab.com/rucdev/nw-kanseitou/-/issues
23
+ Description-Content-Type: text/markdown
24
+
25
+ # nw-kanseitou
26
+
27
+ ネットワーク・インフラ部署のための、OSS の合成フレームワーク。
28
+ 部品は Ansible (機器への変更) と NetBox (台帳) で、機器を変える業務を作業票に載せ、
29
+ フレームワークが固定するのは **背骨** だけにする。それ以外の進め方は、部署が宣言として書く。
30
+
31
+ > **現行の版は 0.2.1 です。** 試作を作り直した実装 ([ADR-0046](docs/adr/0046-delivery-and-technology.md)) は
32
+ > [実装の計画](docs/implementation-plan.md) の M1〜M7 まで完了し、版は [CHANGELOG](CHANGELOG.md) のとおりです。
33
+ > 運用 (バックアップ・復旧・版上げ) は [運用の手引き](docs/guide/operations.md) を参照。
34
+
35
+ 開発者向けのドキュメント: <https://rucdev.gitlab.io/nw-kanseitou/> (`docs/` を Sphinx で組んで GitLab Pages に載せている)
36
+
37
+ ## 背骨
38
+
39
+ 1. 機器か台帳を変える業務は、依頼か自発の作業票に載る
40
+ 2. 変更は、定めた開始時刻より前には始まらない
41
+ 3. 実行中の Ansible が対象に含む機器には、他から触らない
42
+ 4. すべての出来事は、追記専用の監査ログに残る
43
+ 5. 締め中に入った作業票は、締め (台帳への書き込み) が終わるまで終わらない
44
+
45
+ 詳しくは [ADR](docs/adr/README.md) を参照。
46
+
47
+ ## このリポジトリが持つもの
48
+
49
+ このリポジトリは **フレームワークだけ** を持つ。具体的な手順 (サービスと挙動、Playbook、流れの宣言) は一切持たない。
50
+ 部署のものは、部署ごとのリポジトリでフレームワークを取り込んで書く ([ADR-0046](docs/adr/0046-delivery-and-technology.md))。
51
+
52
+ | フレームワーク (このリポジトリ) | 部署のリポジトリ |
53
+ | --- | --- |
54
+ | 背骨、宣言の語彙、投入中・締め中の機械の区間 | 流れの宣言 (段階、人の操作、印) |
55
+ | 台帳 (NetBox) と通知の差し込み口 | サービス × 挙動ごとの要件・割り当て・投入の結果の型 |
56
+ | 資源の仲介、締めの書き込み | 読む・投入の Playbook、締めの宣言 |
57
+ | 画面、監査ログ | モデルの形、NetBox のプラグイン |
58
+
59
+ ## 開発
60
+
61
+ Python 3.14 と [uv](https://docs.astral.sh/uv/) を使う。テストには PostgreSQL が要る。
62
+
63
+ ```sh
64
+ uv sync
65
+ cp .env.example .env # 値は手元の PostgreSQL に合わせる
66
+ uv run pytest
67
+ uv run nw-kanseitou check # Django の manage.py に当たる
68
+
69
+ uv run ruff format . && uv run ruff check .
70
+ uv run ty check
71
+ PYTHONPATH=tests/department uv run lint-imports # コンテキストの境界と、語彙が Django に依存しないこと
72
+ ```
73
+
74
+ ### kind の上の開発用の環境
75
+
76
+ 試験用の部署の生成物 (`tests/department/deploy/base`。すべてを同梱する) を、部署の環境の overlay と同じ形で kind に載せる (ADR-0048 の 7)。
77
+ フレームワーク本体、NetBox、Keycloak、PostgreSQL (CloudNativePG)、機器の代わりの Linux のコンテナ (r1, r2) が動き、
78
+ 前もって要るもの (cert-manager、CloudNativePG と Barman Cloud のプラグイン、Envoy Gateway) も `up.sh` が入れる。
79
+ podman と kind と kubectl が要る。
80
+
81
+ ```sh
82
+ deploy/kind/up.sh # 作る (何度流してもよい。初回は数分かかる)
83
+ NWO_KIND=1 uv run pytest tests/kind # 揃っているか確かめる (端から端までのテストを含む)
84
+ deploy/kind/down.sh # 消す
85
+ ```
86
+
87
+ | | 手元から | 開発用のアカウント |
88
+ | --- | --- | --- |
89
+ | フレームワーク | https://nw.localhost:18443 | Keycloak の alice・carol・dave・rita (パスワードは名前と同じ) |
90
+ | NetBox | https://netbox.localhost:18443 (API は http://localhost:18080 でも) | admin / admin-password、または Keycloak の人 |
91
+ | Keycloak | https://auth.localhost:18443 | realm `nw-kanseitou`。管理の画面は外に出さないので `kubectl port-forward svc/keycloak 8080` で admin / admin |
92
+ | PostgreSQL | localhost:15432 | nw_kanseitou / nw_kanseitou |
93
+
94
+ - 画面は Gateway (Envoy Gateway) を通り、証明書は cert-manager の自己署名である。ブラウザで一度だけ許可する
95
+ - `.env` の `NWO_DB__PORT=15432` にすれば、手元の pytest と `nw-kanseitou` コマンドが kind の PostgreSQL を使う
96
+ - 別のクラスターと並べるときは `NWO_KIND_CLUSTER`、`NWO_KIND_PG_PORT`、`NWO_KIND_NETBOX_PORT` で名前と手元のポートを変えられる (18443 は固定)
97
+ - 前の形 (Gateway の無い kind) のクラスターがあれば、`down.sh` で消してから作り直す
98
+
99
+ 値はすべて開発用で、安全ではない。
100
+
101
+ ## 部署のリポジトリ
102
+
103
+ 部署がフレームワークを取り込み、デプロイするまでの形は [docs/department/](docs/department/index.md) (部署の手引き) を参照。
104
+
105
+ ## 実装の計画
106
+
107
+ [docs/implementation-plan.md](docs/implementation-plan.md) を参照。
108
+
109
+ ## 設計の決定
110
+
111
+ [docs/adr](docs/adr/README.md) を参照。効いている決定は 0001 と 0022 以降である。
112
+
113
+ ## ライセンス
114
+
115
+ [MIT](LICENSE)
@@ -0,0 +1,91 @@
1
+ # nw-kanseitou
2
+
3
+ ネットワーク・インフラ部署のための、OSS の合成フレームワーク。
4
+ 部品は Ansible (機器への変更) と NetBox (台帳) で、機器を変える業務を作業票に載せ、
5
+ フレームワークが固定するのは **背骨** だけにする。それ以外の進め方は、部署が宣言として書く。
6
+
7
+ > **現行の版は 0.2.1 です。** 試作を作り直した実装 ([ADR-0046](docs/adr/0046-delivery-and-technology.md)) は
8
+ > [実装の計画](docs/implementation-plan.md) の M1〜M7 まで完了し、版は [CHANGELOG](CHANGELOG.md) のとおりです。
9
+ > 運用 (バックアップ・復旧・版上げ) は [運用の手引き](docs/guide/operations.md) を参照。
10
+
11
+ 開発者向けのドキュメント: <https://rucdev.gitlab.io/nw-kanseitou/> (`docs/` を Sphinx で組んで GitLab Pages に載せている)
12
+
13
+ ## 背骨
14
+
15
+ 1. 機器か台帳を変える業務は、依頼か自発の作業票に載る
16
+ 2. 変更は、定めた開始時刻より前には始まらない
17
+ 3. 実行中の Ansible が対象に含む機器には、他から触らない
18
+ 4. すべての出来事は、追記専用の監査ログに残る
19
+ 5. 締め中に入った作業票は、締め (台帳への書き込み) が終わるまで終わらない
20
+
21
+ 詳しくは [ADR](docs/adr/README.md) を参照。
22
+
23
+ ## このリポジトリが持つもの
24
+
25
+ このリポジトリは **フレームワークだけ** を持つ。具体的な手順 (サービスと挙動、Playbook、流れの宣言) は一切持たない。
26
+ 部署のものは、部署ごとのリポジトリでフレームワークを取り込んで書く ([ADR-0046](docs/adr/0046-delivery-and-technology.md))。
27
+
28
+ | フレームワーク (このリポジトリ) | 部署のリポジトリ |
29
+ | --- | --- |
30
+ | 背骨、宣言の語彙、投入中・締め中の機械の区間 | 流れの宣言 (段階、人の操作、印) |
31
+ | 台帳 (NetBox) と通知の差し込み口 | サービス × 挙動ごとの要件・割り当て・投入の結果の型 |
32
+ | 資源の仲介、締めの書き込み | 読む・投入の Playbook、締めの宣言 |
33
+ | 画面、監査ログ | モデルの形、NetBox のプラグイン |
34
+
35
+ ## 開発
36
+
37
+ Python 3.14 と [uv](https://docs.astral.sh/uv/) を使う。テストには PostgreSQL が要る。
38
+
39
+ ```sh
40
+ uv sync
41
+ cp .env.example .env # 値は手元の PostgreSQL に合わせる
42
+ uv run pytest
43
+ uv run nw-kanseitou check # Django の manage.py に当たる
44
+
45
+ uv run ruff format . && uv run ruff check .
46
+ uv run ty check
47
+ PYTHONPATH=tests/department uv run lint-imports # コンテキストの境界と、語彙が Django に依存しないこと
48
+ ```
49
+
50
+ ### kind の上の開発用の環境
51
+
52
+ 試験用の部署の生成物 (`tests/department/deploy/base`。すべてを同梱する) を、部署の環境の overlay と同じ形で kind に載せる (ADR-0048 の 7)。
53
+ フレームワーク本体、NetBox、Keycloak、PostgreSQL (CloudNativePG)、機器の代わりの Linux のコンテナ (r1, r2) が動き、
54
+ 前もって要るもの (cert-manager、CloudNativePG と Barman Cloud のプラグイン、Envoy Gateway) も `up.sh` が入れる。
55
+ podman と kind と kubectl が要る。
56
+
57
+ ```sh
58
+ deploy/kind/up.sh # 作る (何度流してもよい。初回は数分かかる)
59
+ NWO_KIND=1 uv run pytest tests/kind # 揃っているか確かめる (端から端までのテストを含む)
60
+ deploy/kind/down.sh # 消す
61
+ ```
62
+
63
+ | | 手元から | 開発用のアカウント |
64
+ | --- | --- | --- |
65
+ | フレームワーク | https://nw.localhost:18443 | Keycloak の alice・carol・dave・rita (パスワードは名前と同じ) |
66
+ | NetBox | https://netbox.localhost:18443 (API は http://localhost:18080 でも) | admin / admin-password、または Keycloak の人 |
67
+ | Keycloak | https://auth.localhost:18443 | realm `nw-kanseitou`。管理の画面は外に出さないので `kubectl port-forward svc/keycloak 8080` で admin / admin |
68
+ | PostgreSQL | localhost:15432 | nw_kanseitou / nw_kanseitou |
69
+
70
+ - 画面は Gateway (Envoy Gateway) を通り、証明書は cert-manager の自己署名である。ブラウザで一度だけ許可する
71
+ - `.env` の `NWO_DB__PORT=15432` にすれば、手元の pytest と `nw-kanseitou` コマンドが kind の PostgreSQL を使う
72
+ - 別のクラスターと並べるときは `NWO_KIND_CLUSTER`、`NWO_KIND_PG_PORT`、`NWO_KIND_NETBOX_PORT` で名前と手元のポートを変えられる (18443 は固定)
73
+ - 前の形 (Gateway の無い kind) のクラスターがあれば、`down.sh` で消してから作り直す
74
+
75
+ 値はすべて開発用で、安全ではない。
76
+
77
+ ## 部署のリポジトリ
78
+
79
+ 部署がフレームワークを取り込み、デプロイするまでの形は [docs/department/](docs/department/index.md) (部署の手引き) を参照。
80
+
81
+ ## 実装の計画
82
+
83
+ [docs/implementation-plan.md](docs/implementation-plan.md) を参照。
84
+
85
+ ## 設計の決定
86
+
87
+ [docs/adr](docs/adr/README.md) を参照。効いている決定は 0001 と 0022 以降である。
88
+
89
+ ## ライセンス
90
+
91
+ [MIT](LICENSE)
@@ -0,0 +1,235 @@
1
+ [project]
2
+ name = "nw-kanseitou"
3
+ version = "0.2.1"
4
+ description = "ネットワーク・インフラ部署のための、OSS の合成フレームワーク"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.14"
9
+ dependencies = [
10
+ "authlib>=1.9.10",
11
+ "django>=6.1.3",
12
+ "granian>=2.8.8",
13
+ "httpx>=0.28.1",
14
+ "kubernetes>=37.0.3",
15
+ "packaging>=26.3",
16
+ "psycopg[binary]>=3.3.9",
17
+ "pydantic>=2.14.4",
18
+ "pydantic-settings>=2.16.3",
19
+ "pyyaml>=6.0.3",
20
+ "requests>=2.34.2",
21
+ "whitenoise>=6.12.0",
22
+ ]
23
+
24
+ [project.urls]
25
+ Documentation = "https://rucdev.gitlab.io/nw-kanseitou/"
26
+ Source = "https://gitlab.com/rucdev/nw-kanseitou"
27
+ Issues = "https://gitlab.com/rucdev/nw-kanseitou/-/issues"
28
+
29
+ [project.scripts]
30
+ nw-kanseitou = "nw_kanseitou.manage:main"
31
+
32
+ [build-system]
33
+ requires = ["uv_build>=0.13,<0.14"]
34
+ build-backend = "uv_build"
35
+
36
+ [dependency-groups]
37
+ dev = [
38
+ "django-types>=0.24.0",
39
+ "import-linter>=2.17",
40
+ "pytest>=9.2.0",
41
+ "pytest-cov>=7.1.0",
42
+ "pytest-django>=4.14.0",
43
+ "ruff>=0.17.6",
44
+ "ty>=0.0.107",
45
+ "types-pyyaml>=6.0.12.20261122",
46
+ ]
47
+ docs = [
48
+ "furo>=2025.12.19",
49
+ "myst-parser>=5.2.0",
50
+ "sphinx>=9.2.0",
51
+ "sphinx-copybutton>=0.5.2",
52
+ ]
53
+
54
+ [tool.ruff]
55
+ target-version = "py314"
56
+ line-length = 100
57
+ extend-exclude = ["docs"]
58
+
59
+ [tool.ruff.lint]
60
+ select = [
61
+ "E",
62
+ "W",
63
+ "F",
64
+ "I",
65
+ "B",
66
+ "UP",
67
+ "SIM",
68
+ "C4",
69
+ "RUF",
70
+ "PT",
71
+ "PERF",
72
+ "PL",
73
+ "TRY",
74
+ "FURB",
75
+ "DTZ",
76
+ "S",
77
+ "N",
78
+ "ANN",
79
+ "PTH",
80
+ "RET",
81
+ "DJ",
82
+ ]
83
+ ignore = [
84
+ "TRY003",
85
+ "PLR0913",
86
+ "RUF001",
87
+ "RUF002",
88
+ "RUF003",
89
+ ]
90
+
91
+ [tool.ruff.lint.isort]
92
+ known-first-party = [
93
+ "nw_kanseitou",
94
+ "department",
95
+ ]
96
+
97
+ [tool.ruff.lint.per-file-ignores]
98
+ "tests/**" = [
99
+ "S101",
100
+ "S105",
101
+ "S106",
102
+ "PLR2004",
103
+ ]
104
+ "{deploy,tests/kind}/**" = [
105
+ "S310",
106
+ "S603",
107
+ "S607",
108
+ "T201",
109
+ ]
110
+ "**/migrations/**" = [
111
+ "ANN",
112
+ "E501",
113
+ "RUF012",
114
+ ]
115
+
116
+ [tool.ty.src]
117
+ exclude = [
118
+ "**/migrations/**",
119
+ "tests/department/netbox",
120
+ "src/nw_kanseitou/execution/job",
121
+ "docs",
122
+ ]
123
+
124
+ [tool.ty.environment]
125
+ extra-paths = ["tests/department"]
126
+
127
+ [tool.ty.rules]
128
+ all = "error"
129
+
130
+ [tool.pytest.ini_options]
131
+ addopts = [
132
+ "--import-mode=importlib",
133
+ "-ra",
134
+ "--strict-markers",
135
+ "--strict-config",
136
+ ]
137
+ testpaths = ["tests"]
138
+ pythonpath = [
139
+ ".",
140
+ "tests/department",
141
+ ]
142
+ DJANGO_SETTINGS_MODULE = "nw_kanseitou.settings"
143
+
144
+ [tool.importlinter]
145
+ root_packages = [
146
+ "nw_kanseitou",
147
+ "department",
148
+ ]
149
+ include_external_packages = true
150
+
151
+ [[tool.importlinter.contracts]]
152
+ name = "試験用の部署は語彙と NetBox の標準のモデルの形だけに触れる (部署が使える公開の API)"
153
+ type = "forbidden"
154
+ source_modules = ["department"]
155
+ forbidden_modules = [
156
+ "django",
157
+ "nw_kanseitou.orders",
158
+ "nw_kanseitou.execution",
159
+ "nw_kanseitou.ledger",
160
+ "nw_kanseitou.notify",
161
+ "nw_kanseitou.plugins",
162
+ "nw_kanseitou.settings",
163
+ ]
164
+
165
+ [[tool.importlinter.contracts]]
166
+ name = "語彙は Django にも、ほかのコンテキストにも依存しない"
167
+ type = "forbidden"
168
+ source_modules = ["nw_kanseitou.vocab"]
169
+ forbidden_modules = [
170
+ "django",
171
+ "nw_kanseitou.orders",
172
+ "nw_kanseitou.execution",
173
+ "nw_kanseitou.ledger",
174
+ "nw_kanseitou.notify",
175
+ "nw_kanseitou.plugins",
176
+ "nw_kanseitou.settings",
177
+ ]
178
+
179
+ [[tool.importlinter.contracts]]
180
+ name = "NetBox の標準のモデルの形は、語彙だけに依存する (部署が import する)"
181
+ type = "forbidden"
182
+ source_modules = ["nw_kanseitou.netbox_models"]
183
+ forbidden_modules = [
184
+ "django",
185
+ "nw_kanseitou.orders",
186
+ "nw_kanseitou.execution",
187
+ "nw_kanseitou.ledger",
188
+ "nw_kanseitou.notify",
189
+ "nw_kanseitou.plugins",
190
+ "nw_kanseitou.settings",
191
+ ]
192
+
193
+ [[tool.importlinter.contracts]]
194
+ name = "orders の中には、orders.api を通してしか触れない"
195
+ type = "protected"
196
+ protected_modules = ["nw_kanseitou.orders.*"]
197
+ allowed_importers = [
198
+ "nw_kanseitou.orders",
199
+ "nw_kanseitou.urls",
200
+ ]
201
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.orders.api"]
202
+ unmatched_ignore_imports_alerting = "none"
203
+
204
+ [[tool.importlinter.contracts]]
205
+ name = "execution の中には、execution.api を通してしか触れない"
206
+ type = "protected"
207
+ protected_modules = ["nw_kanseitou.execution.*"]
208
+ allowed_importers = [
209
+ "nw_kanseitou.execution",
210
+ "nw_kanseitou.urls",
211
+ ]
212
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.execution.api"]
213
+ unmatched_ignore_imports_alerting = "none"
214
+
215
+ [[tool.importlinter.contracts]]
216
+ name = "ledger の中には、ledger.api を通してしか触れない"
217
+ type = "protected"
218
+ protected_modules = ["nw_kanseitou.ledger.*"]
219
+ allowed_importers = [
220
+ "nw_kanseitou.ledger",
221
+ "nw_kanseitou.urls",
222
+ ]
223
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.ledger.api"]
224
+ unmatched_ignore_imports_alerting = "none"
225
+
226
+ [[tool.importlinter.contracts]]
227
+ name = "notify の中には、notify.api を通してしか触れない"
228
+ type = "protected"
229
+ protected_modules = ["nw_kanseitou.notify.*"]
230
+ allowed_importers = [
231
+ "nw_kanseitou.notify",
232
+ "nw_kanseitou.urls",
233
+ ]
234
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.notify.api"]
235
+ unmatched_ignore_imports_alerting = "none"
@@ -0,0 +1,185 @@
1
+ [project]
2
+ name = "nw-kanseitou"
3
+ version = "0.2.1"
4
+ description = "ネットワーク・インフラ部署のための、OSS の合成フレームワーク"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.14"
9
+ dependencies = [
10
+ "authlib>=1.9.10",
11
+ "django>=6.1.3",
12
+ "granian>=2.8.8",
13
+ "httpx>=0.28.1",
14
+ "kubernetes>=37.0.3",
15
+ "packaging>=26.3",
16
+ "psycopg[binary]>=3.3.9",
17
+ "pydantic>=2.14.4",
18
+ "pydantic-settings>=2.16.3",
19
+ "pyyaml>=6.0.3",
20
+ "requests>=2.34.2",
21
+ "whitenoise>=6.12.0",
22
+ ]
23
+
24
+ [project.urls]
25
+ Documentation = "https://rucdev.gitlab.io/nw-kanseitou/"
26
+ Source = "https://gitlab.com/rucdev/nw-kanseitou"
27
+ Issues = "https://gitlab.com/rucdev/nw-kanseitou/-/issues"
28
+
29
+ [project.scripts]
30
+ nw-kanseitou = "nw_kanseitou.manage:main"
31
+
32
+ [build-system]
33
+ requires = ["uv_build>=0.13,<0.14"]
34
+ build-backend = "uv_build"
35
+
36
+
37
+ [dependency-groups]
38
+ dev = [
39
+ "django-types>=0.24.0",
40
+ "import-linter>=2.17",
41
+ "pytest>=9.2.0",
42
+ "pytest-cov>=7.1.0",
43
+ "pytest-django>=4.14.0",
44
+ "ruff>=0.17.6",
45
+ "ty>=0.0.107",
46
+ "types-pyyaml>=6.0.12.20261122",
47
+ ]
48
+ docs = [
49
+ "furo>=2025.12.19",
50
+ "myst-parser>=5.2.0",
51
+ "sphinx>=9.2.0",
52
+ "sphinx-copybutton>=0.5.2",
53
+ ]
54
+
55
+ # ---------------------------------------------------------------- ruff
56
+ [tool.ruff]
57
+ target-version = "py314"
58
+ line-length = 100
59
+ # ADR の本文は承認後に書き換えない (ADR-0026)。Markdown の中の説明用のコードは整形の対象にしない
60
+ extend-exclude = ["docs"]
61
+
62
+ [tool.ruff.lint]
63
+ select = [
64
+ "E", "W", "F", "I", "B", "UP", "SIM", "C4", "RUF", "PT", "PERF", "PL", "TRY",
65
+ "FURB", "DTZ", "S", "N", "ANN", "PTH", "RET", "DJ",
66
+ ]
67
+ ignore = [
68
+ "TRY003", # 例外の文言は長くてよい
69
+ "PLR0913", # 宣言の組み立ては引数が多い (すべてキーワード引数)
70
+ "RUF001", "RUF002", "RUF003", # 日本語の全角記号
71
+ ]
72
+
73
+ [tool.ruff.lint.isort]
74
+ # 試験用の部署 (tests/department) は、どこから見ても同じ並びにする
75
+ known-first-party = ["nw_kanseitou", "department"]
76
+
77
+ [tool.ruff.lint.per-file-ignores]
78
+ "tests/**" = ["S101", "S105", "S106", "PLR2004"]
79
+ # 開発用の環境を作る・確かめるもの。宛先は手元の設定で決まる
80
+ "{deploy,tests/kind}/**" = ["S310", "S603", "S607", "T201"]
81
+ "**/migrations/**" = ["ANN", "E501", "RUF012"]
82
+
83
+ # ---------------------------------------------------------------- ty
84
+ # 規則は厳しくし、すべて error にする (ADR-0039)
85
+ [tool.ty.src]
86
+ exclude = [
87
+ "**/migrations/**", # Django が生成するもの
88
+ "tests/department/netbox", # NetBox のイメージの中でしか import できない
89
+ "src/nw_kanseitou/execution/job", # Job の中 (EE) でしか import できない
90
+ "docs", # Sphinx の設定。ruff と同じく対象にしない
91
+ ]
92
+
93
+ [tool.ty.environment]
94
+ extra-paths = ["tests/department"] # 試験用の部署を department として import する
95
+
96
+ [tool.ty.rules]
97
+ all = "error"
98
+
99
+ # ---------------------------------------------------------------- pytest
100
+ [tool.pytest.ini_options]
101
+ addopts = ["--import-mode=importlib", "-ra", "--strict-markers", "--strict-config"]
102
+ testpaths = ["tests"]
103
+ # tests をパッケージとして、試験用の部署を department として import できるようにする
104
+ pythonpath = [".", "tests/department"]
105
+ DJANGO_SETTINGS_MODULE = "nw_kanseitou.settings"
106
+
107
+ # ---------------------------------------------------------------- import-linter
108
+ # コンテキストのあいだは、公開した入り口 (`<コンテキスト>.api`) からしか触れない (ADR-0039)
109
+ [tool.importlinter]
110
+ root_packages = ["nw_kanseitou", "department"]
111
+ include_external_packages = true
112
+
113
+ [[tool.importlinter.contracts]]
114
+ name = "試験用の部署は語彙と NetBox の標準のモデルの形だけに触れる (部署が使える公開の API)"
115
+ type = "forbidden"
116
+ source_modules = ["department"]
117
+ forbidden_modules = [
118
+ "django",
119
+ "nw_kanseitou.orders",
120
+ "nw_kanseitou.execution",
121
+ "nw_kanseitou.ledger",
122
+ "nw_kanseitou.notify",
123
+ "nw_kanseitou.plugins",
124
+ "nw_kanseitou.settings",
125
+ ]
126
+
127
+ [[tool.importlinter.contracts]]
128
+ name = "語彙は Django にも、ほかのコンテキストにも依存しない"
129
+ type = "forbidden"
130
+ source_modules = ["nw_kanseitou.vocab"]
131
+ forbidden_modules = [
132
+ "django",
133
+ "nw_kanseitou.orders",
134
+ "nw_kanseitou.execution",
135
+ "nw_kanseitou.ledger",
136
+ "nw_kanseitou.notify",
137
+ "nw_kanseitou.plugins",
138
+ "nw_kanseitou.settings",
139
+ ]
140
+
141
+ [[tool.importlinter.contracts]]
142
+ name = "NetBox の標準のモデルの形は、語彙だけに依存する (部署が import する)"
143
+ type = "forbidden"
144
+ source_modules = ["nw_kanseitou.netbox_models"]
145
+ forbidden_modules = [
146
+ "django",
147
+ "nw_kanseitou.orders",
148
+ "nw_kanseitou.execution",
149
+ "nw_kanseitou.ledger",
150
+ "nw_kanseitou.notify",
151
+ "nw_kanseitou.plugins",
152
+ "nw_kanseitou.settings",
153
+ ]
154
+
155
+ [[tool.importlinter.contracts]]
156
+ name = "orders の中には、orders.api を通してしか触れない"
157
+ type = "protected"
158
+ protected_modules = ["nw_kanseitou.orders.*"]
159
+ allowed_importers = ["nw_kanseitou.orders", "nw_kanseitou.urls"]
160
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.orders.api"]
161
+ unmatched_ignore_imports_alerting = "none"
162
+
163
+ [[tool.importlinter.contracts]]
164
+ name = "execution の中には、execution.api を通してしか触れない"
165
+ type = "protected"
166
+ protected_modules = ["nw_kanseitou.execution.*"]
167
+ allowed_importers = ["nw_kanseitou.execution", "nw_kanseitou.urls"]
168
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.execution.api"]
169
+ unmatched_ignore_imports_alerting = "none"
170
+
171
+ [[tool.importlinter.contracts]]
172
+ name = "ledger の中には、ledger.api を通してしか触れない"
173
+ type = "protected"
174
+ protected_modules = ["nw_kanseitou.ledger.*"]
175
+ allowed_importers = ["nw_kanseitou.ledger", "nw_kanseitou.urls"]
176
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.ledger.api"]
177
+ unmatched_ignore_imports_alerting = "none"
178
+
179
+ [[tool.importlinter.contracts]]
180
+ name = "notify の中には、notify.api を通してしか触れない"
181
+ type = "protected"
182
+ protected_modules = ["nw_kanseitou.notify.*"]
183
+ allowed_importers = ["nw_kanseitou.notify", "nw_kanseitou.urls"]
184
+ ignore_imports = ["nw_kanseitou.** -> nw_kanseitou.notify.api"]
185
+ unmatched_ignore_imports_alerting = "none"
@@ -0,0 +1 @@
1
+ """ネットワーク・インフラ部署のための、OSS の合成フレームワーク。"""