workload-profile-controller 0.1.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 (34) hide show
  1. workload_profile_controller-0.1.0/LICENSE +21 -0
  2. workload_profile_controller-0.1.0/PKG-INFO +500 -0
  3. workload_profile_controller-0.1.0/README.md +470 -0
  4. workload_profile_controller-0.1.0/pyproject.toml +57 -0
  5. workload_profile_controller-0.1.0/setup.cfg +4 -0
  6. workload_profile_controller-0.1.0/src/workload_profile_controller/application.py +13 -0
  7. workload_profile_controller-0.1.0/src/workload_profile_controller/backend.py +21 -0
  8. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/__init__.py +0 -0
  9. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/__init__.py +0 -0
  10. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/auth.py +15 -0
  11. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/backend.py +97 -0
  12. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/config.py +16 -0
  13. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/config_loader.py +46 -0
  14. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/discovery.py +54 -0
  15. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/errors.py +13 -0
  16. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/factory.py +43 -0
  17. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/http_client.py +107 -0
  18. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/inventory.py +52 -0
  19. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/resource_client.py +87 -0
  20. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/task.py +16 -0
  21. workload_profile_controller-0.1.0/src/workload_profile_controller/backends/proxmox/task_waiter.py +53 -0
  22. workload_profile_controller-0.1.0/src/workload_profile_controller/cli.py +154 -0
  23. workload_profile_controller-0.1.0/src/workload_profile_controller/config.py +21 -0
  24. workload_profile_controller-0.1.0/src/workload_profile_controller/config_loader.py +40 -0
  25. workload_profile_controller-0.1.0/src/workload_profile_controller/config_validator.py +106 -0
  26. workload_profile_controller-0.1.0/src/workload_profile_controller/controller.py +154 -0
  27. workload_profile_controller-0.1.0/src/workload_profile_controller/errors.py +26 -0
  28. workload_profile_controller-0.1.0/src/workload_profile_controller/policy.py +67 -0
  29. workload_profile_controller-0.1.0/src/workload_profile_controller.egg-info/PKG-INFO +500 -0
  30. workload_profile_controller-0.1.0/src/workload_profile_controller.egg-info/SOURCES.txt +32 -0
  31. workload_profile_controller-0.1.0/src/workload_profile_controller.egg-info/dependency_links.txt +1 -0
  32. workload_profile_controller-0.1.0/src/workload_profile_controller.egg-info/entry_points.txt +2 -0
  33. workload_profile_controller-0.1.0/src/workload_profile_controller.egg-info/requires.txt +7 -0
  34. workload_profile_controller-0.1.0/src/workload_profile_controller.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Caue Tragante
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,500 @@
1
+ Metadata-Version: 2.4
2
+ Name: workload-profile-controller
3
+ Version: 0.1.0
4
+ Summary: Safe and configurable workload profile controller
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/lack0fcode/workload-profile-controller
7
+ Project-URL: Issues, https://github.com/lack0fcode/workload-profile-controller/issues
8
+ Keywords: proxmox,virtualization,workload,profiles,infrastructure,automation
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Topic :: System :: Systems Administration
19
+ Classifier: Topic :: System :: Distributed Computing
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: PyYAML>=6.0
24
+ Requires-Dist: python-dotenv>=1.2
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: ruff>=0.12; extra == "dev"
28
+ Requires-Dist: build>=1.2; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # Workload Profile Controller
32
+
33
+ [![CI](https://github.com/lack0fcode/workload-profile-controller/actions/workflows/ci.yml/badge.svg)](https://github.com/lack0fcode/workload-profile-controller/actions/workflows/ci.yml)
34
+
35
+ A safe and configurable workload profile controller for orchestrating mutually exclusive resource states across infrastructure backends.
36
+
37
+ The project was designed around a simple problem: different workloads may compete for the same infrastructure resources, making manual switching between operational configurations error-prone.
38
+
39
+ Instead of manually starting and stopping resources, the controller defines **profiles** describing the desired state of the infrastructure and performs deterministic, validated transitions between them.
40
+
41
+ The first supported infrastructure backend is **Proxmox VE**.
42
+
43
+ ---
44
+
45
+ ## Overview
46
+
47
+ A workload profile describes which resources must be running and which must be stopped.
48
+
49
+ For example:
50
+
51
+ ```yaml
52
+ profiles:
53
+ profile1:
54
+ description: "Normal operation"
55
+ running:
56
+ - monitoring
57
+ - application
58
+ stopped:
59
+ - compute
60
+
61
+ profile2:
62
+ description: "Compute workload"
63
+ running:
64
+ - compute
65
+ stopped:
66
+ - monitoring
67
+ - application
68
+ ```
69
+
70
+ The controller can then transition between these profiles:
71
+
72
+ ```text
73
+ Workload Profile Controller
74
+
75
+ Profile
76
+
77
+
78
+ Policy
79
+
80
+
81
+ Transition Plan
82
+
83
+
84
+ Controller
85
+
86
+
87
+ Backend API
88
+
89
+
90
+ Proxmox
91
+ ```
92
+
93
+ The core logic is intentionally independent of Proxmox. Proxmox is implemented as a backend, allowing other infrastructure providers to be added in the future.
94
+
95
+ ---
96
+
97
+ ## Why?
98
+
99
+ Manually switching infrastructure between different workload configurations can introduce dangerous situations.
100
+
101
+ For example:
102
+
103
+ * starting a resource before another resource has stopped;
104
+ * assuming that a shutdown completed when it did not;
105
+ * starting a workload while another conflicting workload is still running;
106
+ * recovering automatically from an unexpected partial transition;
107
+ * losing track of the actual infrastructure state.
108
+
109
+ The controller therefore treats profile transitions as **stateful and deterministic operations**.
110
+
111
+ A transition only proceeds when its preconditions are satisfied.
112
+
113
+ If a transition fails after infrastructure changes have started, the controller enters a locked state rather than pretending that the desired profile was reached.
114
+
115
+ ---
116
+
117
+ ## Core principles
118
+
119
+ The controller is designed around several safety invariants.
120
+
121
+ ### Validate before mutating
122
+
123
+ The controller validates the current state and resolves the target resources before performing the first state-changing operation.
124
+
125
+ ### Stop before start
126
+
127
+ When resources conflict between profiles, resources from the previous profile are stopped and confirmed stopped before new resources are started.
128
+
129
+ ### Confirm every operation
130
+
131
+ After requesting a resource transition, the controller verifies its resulting state.
132
+
133
+ ### Never force-stop
134
+
135
+ The controller does not use destructive forced shutdown operations.
136
+
137
+ ### Fail closed
138
+
139
+ If a transition cannot be completed reliably, the controller enters a locked state instead of assuming success.
140
+
141
+ ### Reconcile is observational
142
+
143
+ Reconciliation observes the infrastructure and determines which configured profile matches the current state.
144
+
145
+ It does not automatically start or stop resources.
146
+
147
+ ### Exact resource resolution
148
+
149
+ Backends must resolve configured resource identifiers deterministically.
150
+
151
+ For the Proxmox backend, resource names are matched exactly. Ambiguous names are rejected rather than resolved arbitrarily.
152
+
153
+ ---
154
+
155
+ ## Profiles
156
+
157
+ Profiles are completely configurable.
158
+
159
+ A profile contains:
160
+
161
+ * a name;
162
+ * an optional description;
163
+ * resources that must be running;
164
+ * resources that must be stopped.
165
+
166
+ Every configured resource must have exactly one state in every profile.
167
+
168
+ For example:
169
+
170
+ ```yaml
171
+ resources:
172
+ monitoring:
173
+ description: "Monitoring workload"
174
+
175
+ compute:
176
+ description: "Compute workload"
177
+
178
+ application:
179
+ description: "Application workload"
180
+ ```
181
+
182
+ Profiles then describe the desired state of those resources.
183
+
184
+ This separation between **resource identity** and **infrastructure-specific identifiers** allows the same profile model to remain independent of the underlying provider.
185
+
186
+ ---
187
+
188
+ ## Supported backend
189
+
190
+ ### Proxmox VE
191
+
192
+ The current backend supports:
193
+
194
+ * QEMU virtual machines;
195
+ * LXC containers;
196
+ * Proxmox API authentication using API tokens;
197
+ * TLS certificate verification;
198
+ * configurable TLS server names;
199
+ * resource discovery;
200
+ * exact resource-name resolution;
201
+ * start and stop operations;
202
+ * asynchronous task monitoring;
203
+ * shutdown timeouts.
204
+
205
+ The core controller does not need to know whether a resource is a QEMU VM or an LXC container.
206
+
207
+ That information remains inside the Proxmox backend.
208
+
209
+ ---
210
+
211
+ ## Installation
212
+
213
+ Clone the repository and create a virtual environment:
214
+
215
+ ```bash
216
+ git clone https://github.com/lack0fcode/workload-profile-controller.git
217
+ cd workload-profile-controller
218
+
219
+ python -m venv .venv
220
+ ```
221
+
222
+ Activate the virtual environment and install the project with its development dependencies:
223
+
224
+ ```bash
225
+ python -m pip install -e ".[dev]"
226
+ ```
227
+
228
+ The CLI is then available as:
229
+
230
+ ```bash
231
+ wpc
232
+ ```
233
+
234
+ Check the installation:
235
+
236
+ ```bash
237
+ wpc --help
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Configuration
243
+
244
+ The controller uses a YAML configuration file to define resources and profiles.
245
+
246
+ An example configuration is available at:
247
+
248
+ ```text
249
+ config/examples/config.example.yaml
250
+ ```
251
+
252
+ Backend-specific connection settings are kept separately from the profile configuration.
253
+
254
+ For the Proxmox backend, credentials and connection parameters are provided through environment variables.
255
+
256
+ Secrets should never be committed to the repository.
257
+
258
+ See:
259
+
260
+ * [CONFIGURATION.md](config/CONFIGURATION.md)
261
+ * [SECURITY.md](SECURITY.md)
262
+
263
+ for details.
264
+
265
+ ---
266
+
267
+ ## CLI
268
+
269
+ The current CLI provides four main operations.
270
+
271
+ ### List profiles
272
+
273
+ ```bash
274
+ wpc --config config.yaml profiles
275
+ ```
276
+
277
+ Lists the profiles defined in the configuration.
278
+
279
+ ### Show status
280
+
281
+ ```bash
282
+ wpc --config config.yaml status
283
+ ```
284
+
285
+ Shows the current state of configured resources.
286
+
287
+ ### Plan a transition
288
+
289
+ ```bash
290
+ wpc --config config.yaml plan profile2
291
+ ```
292
+
293
+ Builds and displays the transition plan without changing infrastructure.
294
+
295
+ ### Perform a transition
296
+
297
+ ```bash
298
+ wpc --config config.yaml transition profile2
299
+ ```
300
+
301
+ Executes the transition to the selected profile.
302
+
303
+ ---
304
+
305
+ ## Safety model
306
+
307
+ A simplified transition looks like this:
308
+
309
+ ```text
310
+ Current Profile
311
+
312
+
313
+ Validate current state
314
+
315
+
316
+ Resolve target resources
317
+
318
+
319
+ Build transition plan
320
+
321
+
322
+ Stop conflicting resources
323
+
324
+
325
+ Confirm stopped
326
+
327
+
328
+ Start target resources
329
+
330
+
331
+ Confirm running
332
+
333
+
334
+ Validate complete target profile
335
+
336
+
337
+ Transition complete
338
+ ```
339
+
340
+ If an operation fails after the transition has started:
341
+
342
+ ```text
343
+ Transition
344
+
345
+ ├── success ───────► target profile
346
+
347
+ └── failure ───────► LOCKED
348
+ ```
349
+
350
+ The locked state prevents subsequent transitions from proceeding until the situation has been explicitly investigated.
351
+
352
+ ---
353
+
354
+ ## Architecture
355
+
356
+ The project separates infrastructure-independent policy from backend-specific operations.
357
+
358
+ ```text
359
+ Configuration
360
+
361
+
362
+ Policy
363
+
364
+
365
+ TransitionPlan
366
+
367
+
368
+ Controller
369
+
370
+
371
+ Backend
372
+
373
+ ├──────── Proxmox
374
+
375
+ ├──────── AWS (future)
376
+
377
+ └──────── GCP (future)
378
+ ```
379
+
380
+ The main components are:
381
+
382
+ ### Configuration
383
+
384
+ Loads and validates resources and profiles.
385
+
386
+ ### Policy
387
+
388
+ Determines what must change between two profiles and generates a deterministic transition plan.
389
+
390
+ ### Controller
391
+
392
+ Enforces the safety rules and executes the transition through the backend interface.
393
+
394
+ ### Backend
395
+
396
+ Provides an infrastructure-independent interface for querying, starting and stopping resources.
397
+
398
+ ### Proxmox backend
399
+
400
+ Implements the backend interface using the Proxmox API and handles provider-specific resource discovery, resolution and asynchronous tasks.
401
+
402
+ More details are available in [ARCHITECTURE.md](ARCHITECTURE.md).
403
+
404
+ ---
405
+
406
+ ## Development
407
+
408
+ Install the development dependencies:
409
+
410
+ ```bash
411
+ python -m pip install -e ".[dev]"
412
+ ```
413
+
414
+ Run the test suite:
415
+
416
+ ```bash
417
+ pytest
418
+ ```
419
+
420
+ Run Ruff:
421
+
422
+ ```bash
423
+ ruff check src tests
424
+ ```
425
+
426
+ The project is developed with a strong emphasis on deterministic behavior and testable state transitions.
427
+
428
+ ---
429
+
430
+ ## Project status
431
+
432
+ The project is currently in active development.
433
+
434
+ The Proxmox backend and core profile transition logic are functional and covered by automated tests.
435
+
436
+ Current priorities include:
437
+
438
+ * strengthening configuration and safety validation;
439
+ * improving the CLI;
440
+ * expanding integration testing;
441
+ * adding additional backend implementations;
442
+ * developing a WebUI for profile management and operational visibility;
443
+ * establishing the packaging and release workflow.
444
+
445
+ ---
446
+
447
+ ## Roadmap
448
+
449
+ ### Core
450
+
451
+ * [x] Configurable resources
452
+ * [x] Configurable profiles
453
+ * [x] Profile validation
454
+ * [x] Deterministic transition plans
455
+ * [x] Backend abstraction
456
+ * [x] Proxmox backend
457
+ * [x] QEMU support
458
+ * [x] LXC support
459
+ * [x] Resource discovery
460
+ * [x] Exact resource resolution
461
+ * [x] Asynchronous task monitoring
462
+ * [x] Transition locking
463
+ * [x] Reconciliation
464
+
465
+ ### CLI
466
+
467
+ * [x] Profile listing
468
+ * [x] Resource status
469
+ * [x] Transition plan
470
+ * [x] Profile transitions
471
+
472
+ ### Documentation
473
+
474
+ * [x] Configuration guide
475
+ * [x] Architecture documentation
476
+ * [x] Security documentation
477
+ * [x] Contribution guide
478
+
479
+ ### Future
480
+
481
+ * [ ] WebUI
482
+ * [ ] Additional infrastructure backends
483
+ * [ ] Integration test environment
484
+ * [ ] Improved transition diagnostics
485
+
486
+ ---
487
+
488
+ ## License
489
+
490
+ This project is licensed under the MIT License.
491
+
492
+ See [LICENSE](LICENSE) for the full license text.
493
+
494
+ ---
495
+
496
+ ## Contributing
497
+
498
+ Contributions, bug reports and architectural discussions are welcome.
499
+
500
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.