Files
proxmox-selfservice/support-provisioning-portal/includes/class-spp-expiration-service.php
Sven Steinert 118809bfae - Added template typing so approved templates can represent either QEMU VMs or LXC containers.
- Added LXC template discovery from Proxmox storage `vztmpl` content in the admin template manager.
- Added live LXC container provisioning through the Proxmox API with configurable rootfs storage and optional DHCP bridge.
- Routed start, stop, delete, expiration, status, and IP refresh operations through typed Proxmox VM/LXC API paths.
- Added Proxmox tags to newly created VMs and containers, including a sanitized per-user tag for easier PVE administration.
- Updated the admin and portal UI to show VM versus LXC template/deployment types and generic Proxmox resource IDs.
- Added schema upgrades for template provisioning type, LXC template references, and deployment resource type.
- Documented LXC setup, storage permissions, and the new Proxmox settings.
2026-04-24 17:11:39 +02:00

32 lines
890 B
PHP

<?php
if (!defined('ABSPATH')) {
exit;
}
final class SPP_Expiration_Service
{
public function __construct(
private SPP_Repository $repository,
private SPP_Proxmox_Client $proxmox
) {
}
public function expire_due_deployments(): void
{
foreach ($this->repository->due_for_expiration() as $deployment) {
$stop_error = null;
if (!empty($deployment['proxmox_vm_id']) && $deployment['status'] !== 'STOPPED') {
try {
$this->proxmox->stop_instance((string) ($deployment['provisioning_type'] ?? 'qemu'), (int) $deployment['proxmox_vm_id']);
} catch (Throwable $error) {
$stop_error = $error->getMessage();
}
}
$this->repository->mark_deployment_expired((int) $deployment['id'], $stop_error);
}
}
}