proxsync 2.0.0__tar.gz → 2.0.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 (66) hide show
  1. {proxsync-2.0.0/proxsync.egg-info → proxsync-2.0.1}/PKG-INFO +12 -14
  2. {proxsync-2.0.0 → proxsync-2.0.1}/README.md +11 -13
  3. {proxsync-2.0.0 → proxsync-2.0.1/proxsync.egg-info}/PKG-INFO +12 -14
  4. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/models.py +4 -0
  5. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/tasks.py +6 -4
  6. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/pvesyncjob.html +77 -48
  7. {proxsync-2.0.0 → proxsync-2.0.1}/pyproject.toml +1 -1
  8. {proxsync-2.0.0 → proxsync-2.0.1}/MANIFEST.in +0 -0
  9. {proxsync-2.0.0 → proxsync-2.0.1}/config.py +0 -0
  10. {proxsync-2.0.0 → proxsync-2.0.1}/pbs_sync.py +0 -0
  11. {proxsync-2.0.0 → proxsync-2.0.1}/proxsync.egg-info/SOURCES.txt +0 -0
  12. {proxsync-2.0.0 → proxsync-2.0.1}/proxsync.egg-info/dependency_links.txt +0 -0
  13. {proxsync-2.0.0 → proxsync-2.0.1}/proxsync.egg-info/requires.txt +0 -0
  14. {proxsync-2.0.0 → proxsync-2.0.1}/proxsync.egg-info/top_level.txt +0 -0
  15. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync.py +0 -0
  16. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/__init__.py +0 -0
  17. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/api/__init__.py +0 -0
  18. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/api/serializers.py +0 -0
  19. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/api/urls.py +0 -0
  20. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/api/views.py +0 -0
  21. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/apps.py +0 -0
  22. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/choices.py +0 -0
  23. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/filtersets.py +0 -0
  24. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/forms.py +0 -0
  25. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/management/__init__.py +0 -0
  26. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/management/commands/__init__.py +0 -0
  27. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/management/commands/pve_sync.py +0 -0
  28. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/management/commands/run_scheduled_syncs.py +0 -0
  29. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0001_initial.py +0 -0
  30. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0002_pvepluginsettings.py +0 -0
  31. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0003_netboxmodel_timestamps.py +0 -0
  32. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0004_model_verbose_names.py +0 -0
  33. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0005_align_netboxmodel_timestamps.py +0 -0
  34. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0006_pbsserverconfig_and_more.py +0 -0
  35. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0007_rename_verbose_names_to_proxmox_sync.py +0 -0
  36. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0008_pbsserverconfig_sync_schedule.py +0 -0
  37. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0009_add_every_3h_schedule.py +0 -0
  38. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0010_pvedriftevent.py +0 -0
  39. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0011_pveclusterconfig_notify_on_sync.py +0 -0
  40. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0012_pvedriftevent_tags_and_index_renames.py +0 -0
  41. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/0013_pluginsettings_log_retention.py +0 -0
  42. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/migrations/__init__.py +0 -0
  43. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/navigation.py +0 -0
  44. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/signals.py +0 -0
  45. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/sync/__init__.py +0 -0
  46. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/sync/config_bridge.py +0 -0
  47. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/sync/engine.py +0 -0
  48. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/tables.py +0 -0
  49. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/template_content.py +0 -0
  50. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/dashboard.html +0 -0
  51. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/inc/vm_sync_button.html +0 -0
  52. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/pbsserverconfig.html +0 -0
  53. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/pvebackupstatus.html +0 -0
  54. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/pveclusterconfig.html +0 -0
  55. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/pvedriftevent.html +0 -0
  56. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/pvewebhookevent.html +0 -0
  57. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templates/pve_sync/settings.html +0 -0
  58. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templatetags/__init__.py +0 -0
  59. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/templatetags/pve_sync_tags.py +0 -0
  60. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/urls.py +0 -0
  61. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/utils.py +0 -0
  62. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/view_helpers.py +0 -0
  63. {proxsync-2.0.0 → proxsync-2.0.1}/pve_sync_plugin/views.py +0 -0
  64. {proxsync-2.0.0 → proxsync-2.0.1}/setup.cfg +0 -0
  65. {proxsync-2.0.0 → proxsync-2.0.1}/state_db.py +0 -0
  66. {proxsync-2.0.0 → proxsync-2.0.1}/tests/test_plugin_contracts.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxsync
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: NetBox plugin for Proxmox VE inventory synchronization
5
5
  Author-email: lixiujie85 <lixiujie85@gmail.com>
6
6
  License-Expression: MIT
@@ -114,7 +114,7 @@ Requires-Dist: pytest-cov>=4.0; extra == "dev"
114
114
  ### 1. 安裝插件
115
115
 
116
116
  ```bash
117
- /opt/netbox/venv/bin/pip install -e /opt/proxsync
117
+ /opt/netbox/venv/bin/pip install proxsync
118
118
  ```
119
119
 
120
120
  ### 2. 啟用插件
@@ -125,14 +125,6 @@ Requires-Dist: pytest-cov>=4.0; extra == "dev"
125
125
  PLUGINS = [
126
126
  "pve_sync_plugin",
127
127
  ]
128
-
129
- PLUGINS_CONFIG = {
130
- "pve_sync_plugin": {
131
- # 也可在 Web UI Settings 頁面設定,此處為預設值
132
- "netbox_url": "http://localhost:8001",
133
- "netbox_token": "your-netbox-api-token",
134
- },
135
- }
136
128
  ```
137
129
 
138
130
  ### 3. 建立資料表
@@ -149,12 +141,12 @@ cd /opt/netbox/netbox
149
141
  sudo systemctl restart netbox netbox-rq
150
142
  ```
151
143
 
152
- ### 5. 設定排程自動同步(推薦)
144
+ ### 5. 設定排程自動同步
153
145
 
154
- 在 root crontab 加入以下排程,每 15 分鐘檢查一次是否有到期的同步任務:
146
+ 在 crontab 加入以下排程,每 15 分鐘檢查一次是否有到期的同步任務:
155
147
 
156
148
  ```bash
157
- sudo crontab -e
149
+ crontab -e
158
150
  ```
159
151
 
160
152
  加入:
@@ -163,7 +155,13 @@ sudo crontab -e
163
155
  */15 * * * * cd /opt/netbox/netbox && /opt/netbox/venv/bin/python manage.py run_scheduled_syncs >> /var/log/netbox-pve-scheduled-sync.log 2>&1
164
156
  ```
165
157
 
166
- > 設定好 cron 後,只需在 Web UI 各叢集設定中選擇同步週期,系統即會自動執行。
158
+ ### 6. 在 Web UI 完成設定
159
+
160
+ 前往 `Plugins → Proxmox Sync → Settings`,填入 NetBox URL、API Token,以及 Telegram 通知設定(可選)。
161
+
162
+ 接著前往 `Plugins → Proxmox Sync → PVE Clusters → Add` 新增第一個 PVE 叢集連線。
163
+
164
+ > 設定好 cron 後,只需在各叢集設定中選擇同步週期,系統即會自動執行。
167
165
 
168
166
  ---
169
167
 
@@ -78,7 +78,7 @@
78
78
  ### 1. 安裝插件
79
79
 
80
80
  ```bash
81
- /opt/netbox/venv/bin/pip install -e /opt/proxsync
81
+ /opt/netbox/venv/bin/pip install proxsync
82
82
  ```
83
83
 
84
84
  ### 2. 啟用插件
@@ -89,14 +89,6 @@
89
89
  PLUGINS = [
90
90
  "pve_sync_plugin",
91
91
  ]
92
-
93
- PLUGINS_CONFIG = {
94
- "pve_sync_plugin": {
95
- # 也可在 Web UI Settings 頁面設定,此處為預設值
96
- "netbox_url": "http://localhost:8001",
97
- "netbox_token": "your-netbox-api-token",
98
- },
99
- }
100
92
  ```
101
93
 
102
94
  ### 3. 建立資料表
@@ -113,12 +105,12 @@ cd /opt/netbox/netbox
113
105
  sudo systemctl restart netbox netbox-rq
114
106
  ```
115
107
 
116
- ### 5. 設定排程自動同步(推薦)
108
+ ### 5. 設定排程自動同步
117
109
 
118
- 在 root crontab 加入以下排程,每 15 分鐘檢查一次是否有到期的同步任務:
110
+ 在 crontab 加入以下排程,每 15 分鐘檢查一次是否有到期的同步任務:
119
111
 
120
112
  ```bash
121
- sudo crontab -e
113
+ crontab -e
122
114
  ```
123
115
 
124
116
  加入:
@@ -127,7 +119,13 @@ sudo crontab -e
127
119
  */15 * * * * cd /opt/netbox/netbox && /opt/netbox/venv/bin/python manage.py run_scheduled_syncs >> /var/log/netbox-pve-scheduled-sync.log 2>&1
128
120
  ```
129
121
 
130
- > 設定好 cron 後,只需在 Web UI 各叢集設定中選擇同步週期,系統即會自動執行。
122
+ ### 6. 在 Web UI 完成設定
123
+
124
+ 前往 `Plugins → Proxmox Sync → Settings`,填入 NetBox URL、API Token,以及 Telegram 通知設定(可選)。
125
+
126
+ 接著前往 `Plugins → Proxmox Sync → PVE Clusters → Add` 新增第一個 PVE 叢集連線。
127
+
128
+ > 設定好 cron 後,只需在各叢集設定中選擇同步週期,系統即會自動執行。
131
129
 
132
130
  ---
133
131
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxsync
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: NetBox plugin for Proxmox VE inventory synchronization
5
5
  Author-email: lixiujie85 <lixiujie85@gmail.com>
6
6
  License-Expression: MIT
@@ -114,7 +114,7 @@ Requires-Dist: pytest-cov>=4.0; extra == "dev"
114
114
  ### 1. 安裝插件
115
115
 
116
116
  ```bash
117
- /opt/netbox/venv/bin/pip install -e /opt/proxsync
117
+ /opt/netbox/venv/bin/pip install proxsync
118
118
  ```
119
119
 
120
120
  ### 2. 啟用插件
@@ -125,14 +125,6 @@ Requires-Dist: pytest-cov>=4.0; extra == "dev"
125
125
  PLUGINS = [
126
126
  "pve_sync_plugin",
127
127
  ]
128
-
129
- PLUGINS_CONFIG = {
130
- "pve_sync_plugin": {
131
- # 也可在 Web UI Settings 頁面設定,此處為預設值
132
- "netbox_url": "http://localhost:8001",
133
- "netbox_token": "your-netbox-api-token",
134
- },
135
- }
136
128
  ```
137
129
 
138
130
  ### 3. 建立資料表
@@ -149,12 +141,12 @@ cd /opt/netbox/netbox
149
141
  sudo systemctl restart netbox netbox-rq
150
142
  ```
151
143
 
152
- ### 5. 設定排程自動同步(推薦)
144
+ ### 5. 設定排程自動同步
153
145
 
154
- 在 root crontab 加入以下排程,每 15 分鐘檢查一次是否有到期的同步任務:
146
+ 在 crontab 加入以下排程,每 15 分鐘檢查一次是否有到期的同步任務:
155
147
 
156
148
  ```bash
157
- sudo crontab -e
149
+ crontab -e
158
150
  ```
159
151
 
160
152
  加入:
@@ -163,7 +155,13 @@ sudo crontab -e
163
155
  */15 * * * * cd /opt/netbox/netbox && /opt/netbox/venv/bin/python manage.py run_scheduled_syncs >> /var/log/netbox-pve-scheduled-sync.log 2>&1
164
156
  ```
165
157
 
166
- > 設定好 cron 後,只需在 Web UI 各叢集設定中選擇同步週期,系統即會自動執行。
158
+ ### 6. 在 Web UI 完成設定
159
+
160
+ 前往 `Plugins → Proxmox Sync → Settings`,填入 NetBox URL、API Token,以及 Telegram 通知設定(可選)。
161
+
162
+ 接著前往 `Plugins → Proxmox Sync → PVE Clusters → Add` 新增第一個 PVE 叢集連線。
163
+
164
+ > 設定好 cron 後,只需在各叢集設定中選擇同步週期,系統即會自動執行。
167
165
 
168
166
  ---
169
167
 
@@ -93,6 +93,10 @@ class PveSyncJob(NetBoxModel):
93
93
  "partial": "warning",
94
94
  }.get(self.status, "secondary")
95
95
 
96
+ @property
97
+ def is_pbs_job(self):
98
+ return self.cluster_name.startswith("pbs:")
99
+
96
100
  @property
97
101
  def error_message(self):
98
102
  if not self.details:
@@ -252,18 +252,20 @@ def run_pbs_sync_job(job_id, pbs_server_pk):
252
252
  syncer.sync()
253
253
 
254
254
  # Write backup records to PveBackupStatus
255
+ backup_updated, backup_skipped = None, None
255
256
  try:
256
257
  backup_records = _fetch_pbs_snapshots(pbs)
257
- updated, skipped = _apply_pbs_backup_status(backup_records)
258
- job.details["backup_updated"] = updated
259
- job.details["backup_skipped"] = skipped
260
- logger.info("PBS backup status: %d updated, %d no VM match", updated, skipped)
258
+ backup_updated, backup_skipped = _apply_pbs_backup_status(backup_records)
259
+ logger.info("PBS backup status: %d updated, %d no VM match", backup_updated, backup_skipped)
261
260
  except Exception as exc:
262
261
  logger.warning("PBS backup status sync failed (non-fatal): %s", exc)
263
262
 
264
263
  job.refresh_from_db()
265
264
  job.status = "success"
266
265
  job.end_time = timezone.now()
266
+ if backup_updated is not None:
267
+ job.details["backup_updated"] = backup_updated
268
+ job.details["backup_skipped"] = backup_skipped
267
269
  job.details.pop("heartbeat", None)
268
270
  job.save()
269
271
 
@@ -68,8 +68,12 @@
68
68
  {% if object.status == "success" %}
69
69
  <div class="alert alert-success" role="alert">
70
70
  <i class="mdi mdi-check-circle"></i>
71
- 同步成功完成!共處理 <strong>{{ object.total_vms }}</strong> 台 VM,
72
- 成功 <strong>{{ object.success_vms }}</strong> 台,耗時 {{ object.duration|floatformat:0 }} 秒。
71
+ {% if object.is_pbs_job %}
72
+ PBS 同步成功完成!備份記錄更新 <strong>{{ object.details.backup_updated|default:0 }}</strong> 筆,耗時 {{ object.duration|floatformat:0 }} 秒。
73
+ {% else %}
74
+ 同步成功完成!共處理 <strong>{{ object.total_vms }}</strong> 台 VM,
75
+ 成功 <strong>{{ object.success_vms }}</strong> 台,耗時 {{ object.duration|floatformat:0 }} 秒。
76
+ {% endif %}
73
77
  </div>
74
78
  {% endif %}
75
79
 
@@ -131,52 +135,77 @@
131
135
  <div class="card">
132
136
  <h5 class="card-header">Statistics</h5>
133
137
  <table class="table table-hover attr-table">
134
- <tr>
135
- <th scope="row">Total VMs</th>
136
- <td>
137
- {% if object.total_vms > 0 %}
138
- {{ object.total_vms }}
139
- {% elif object.status == "running" %}
140
- <span class="text-muted">同步完成後顯示</span>
141
- {% else %}
142
- 0
143
- {% endif %}
144
- </td>
145
- </tr>
146
- <tr>
147
- <th scope="row">Success</th>
148
- <td><span class="text-success">{{ object.success_vms }}</span></td>
149
- </tr>
150
- <tr>
151
- <th scope="row">Failed</th>
152
- <td><span class="text-danger">{{ object.failed_vms }}</span></td>
153
- </tr>
154
- <tr>
155
- <th scope="row">Success Rate</th>
156
- <td>
157
- {% if object.total_vms > 0 %}
158
- {{ object.success_rate|floatformat:1 }}%
159
- {% else %}
160
- —
161
- {% endif %}
162
- </td>
163
- </tr>
164
- <tr>
165
- <th scope="row">Nodes Offline</th>
166
- <td>{{ object.nodes_offline }}</td>
167
- </tr>
168
- <tr>
169
- <th scope="row">Config Drifts</th>
170
- <td>{{ object.config_drifts }}</td>
171
- </tr>
172
- <tr>
173
- <th scope="row">Tag Changes</th>
174
- <td>{{ object.tag_changes }}</td>
175
- </tr>
176
- <tr>
177
- <th scope="row">Resource Alerts</th>
178
- <td>{{ object.resource_alerts }}</td>
179
- </tr>
138
+ {% if object.is_pbs_job %}
139
+ <tr>
140
+ <th scope="row">Device Synced</th>
141
+ <td>
142
+ {% if object.status == "running" %}
143
+ <span class="text-muted">同步完成後顯示</span>
144
+ {% elif object.status == "success" %}
145
+ <span class="text-success">1</span>
146
+ {% else %}—{% endif %}
147
+ </td>
148
+ </tr>
149
+ <tr>
150
+ <th scope="row">Backup Records Updated</th>
151
+ <td>
152
+ {% if object.details.backup_updated is not None %}
153
+ <span class="text-success">{{ object.details.backup_updated }}</span>
154
+ {% elif object.status == "running" %}
155
+ <span class="text-muted">同步完成後顯示</span>
156
+ {% else %}—{% endif %}
157
+ </td>
158
+ </tr>
159
+ <tr>
160
+ <th scope="row">No VM Match (Skipped)</th>
161
+ <td>
162
+ {% if object.details.backup_skipped is not None %}
163
+ {{ object.details.backup_skipped }}
164
+ {% else %}—{% endif %}
165
+ </td>
166
+ </tr>
167
+ {% else %}
168
+ <tr>
169
+ <th scope="row">Total VMs</th>
170
+ <td>
171
+ {% if object.total_vms > 0 %}
172
+ {{ object.total_vms }}
173
+ {% elif object.status == "running" %}
174
+ <span class="text-muted">同步完成後顯示</span>
175
+ {% else %}0{% endif %}
176
+ </td>
177
+ </tr>
178
+ <tr>
179
+ <th scope="row">Success</th>
180
+ <td><span class="text-success">{{ object.success_vms }}</span></td>
181
+ </tr>
182
+ <tr>
183
+ <th scope="row">Failed</th>
184
+ <td><span class="text-danger">{{ object.failed_vms }}</span></td>
185
+ </tr>
186
+ <tr>
187
+ <th scope="row">Success Rate</th>
188
+ <td>
189
+ {% if object.total_vms > 0 %}{{ object.success_rate|floatformat:1 }}%{% else %}—{% endif %}
190
+ </td>
191
+ </tr>
192
+ <tr>
193
+ <th scope="row">Nodes Offline</th>
194
+ <td>{{ object.nodes_offline }}</td>
195
+ </tr>
196
+ <tr>
197
+ <th scope="row">Config Drifts</th>
198
+ <td>{{ object.config_drifts }}</td>
199
+ </tr>
200
+ <tr>
201
+ <th scope="row">Tag Changes</th>
202
+ <td>{{ object.tag_changes }}</td>
203
+ </tr>
204
+ <tr>
205
+ <th scope="row">Resource Alerts</th>
206
+ <td>{{ object.resource_alerts }}</td>
207
+ </tr>
208
+ {% endif %}
180
209
  </table>
181
210
  </div>
182
211
  </div>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "proxsync"
7
- version = "2.0.0"
7
+ version = "2.0.1"
8
8
  description = "NetBox plugin for Proxmox VE inventory synchronization"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes