- 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.
This commit is contained in:
@@ -6,7 +6,7 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
final class SPP_Activator
|
||||
{
|
||||
private const DB_VERSION = '0.6.0';
|
||||
private const DB_VERSION = '0.7.0';
|
||||
|
||||
public static function activate(): void
|
||||
{
|
||||
@@ -15,6 +15,8 @@ final class SPP_Activator
|
||||
|
||||
add_option('spp_proxmox_mode', 'mock');
|
||||
add_option('spp_proxmox_node', 'pve-01');
|
||||
add_option('spp_lxc_rootfs_storage', '');
|
||||
add_option('spp_lxc_bridge', 'vmbr0');
|
||||
add_option('spp_mock_next_vm_id', 10000);
|
||||
add_option('spp_quota_user_memory_mb', 0);
|
||||
add_option('spp_quota_global_memory_mb', 0);
|
||||
@@ -63,7 +65,9 @@ final class SPP_Activator
|
||||
memory_mb int unsigned NOT NULL,
|
||||
disk_gb int unsigned NOT NULL,
|
||||
default_ttl_hours int unsigned NOT NULL,
|
||||
provisioning_type varchar(16) NOT NULL DEFAULT 'qemu',
|
||||
proxmox_template_id int unsigned NOT NULL,
|
||||
proxmox_template_ref varchar(255) NULL,
|
||||
is_active tinyint(1) NOT NULL DEFAULT 1,
|
||||
created_at datetime NOT NULL,
|
||||
updated_at datetime NOT NULL,
|
||||
@@ -75,6 +79,7 @@ final class SPP_Activator
|
||||
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
name varchar(160) NOT NULL,
|
||||
status varchar(32) NOT NULL,
|
||||
provisioning_type varchar(16) NOT NULL DEFAULT 'qemu',
|
||||
proxmox_vm_id int unsigned DEFAULT NULL,
|
||||
ip_addresses longtext NULL,
|
||||
error_message text NULL,
|
||||
@@ -92,6 +97,10 @@ final class SPP_Activator
|
||||
|
||||
$wpdb->query("ALTER TABLE {$deployments} MODIFY expires_at datetime NULL");
|
||||
|
||||
self::add_column_if_missing($templates, 'provisioning_type', "ALTER TABLE {$templates} ADD COLUMN provisioning_type varchar(16) NOT NULL DEFAULT 'qemu' AFTER default_ttl_hours");
|
||||
self::add_column_if_missing($templates, 'proxmox_template_ref', "ALTER TABLE {$templates} ADD COLUMN proxmox_template_ref varchar(255) NULL AFTER proxmox_template_id");
|
||||
self::add_column_if_missing($deployments, 'provisioning_type', "ALTER TABLE {$deployments} ADD COLUMN provisioning_type varchar(16) NOT NULL DEFAULT 'qemu' AFTER status");
|
||||
|
||||
$ip_column = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM {$deployments} LIKE %s", 'ip_addresses'));
|
||||
if ($ip_column === null) {
|
||||
$wpdb->query("ALTER TABLE {$deployments} ADD COLUMN ip_addresses longtext NULL AFTER proxmox_vm_id");
|
||||
@@ -138,6 +147,16 @@ final class SPP_Activator
|
||||
return $wpdb->prefix . 'spp_' . $name;
|
||||
}
|
||||
|
||||
private static function add_column_if_missing(string $table, string $column, string $sql): void
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$exists = $wpdb->get_var($wpdb->prepare("SHOW COLUMNS FROM {$table} LIKE %s", $column));
|
||||
if ($exists === null) {
|
||||
$wpdb->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
private static function seed_templates(): void
|
||||
{
|
||||
global $wpdb;
|
||||
@@ -154,7 +173,9 @@ final class SPP_Activator
|
||||
'memory_mb' => 2048,
|
||||
'disk_gb' => 24,
|
||||
'default_ttl_hours' => 72,
|
||||
'provisioning_type' => 'qemu',
|
||||
'proxmox_template_id' => 9001,
|
||||
'proxmox_template_ref' => null,
|
||||
],
|
||||
[
|
||||
'template_key' => 'windows-support-client',
|
||||
@@ -165,7 +186,9 @@ final class SPP_Activator
|
||||
'memory_mb' => 8192,
|
||||
'disk_gb' => 80,
|
||||
'default_ttl_hours' => 48,
|
||||
'provisioning_type' => 'qemu',
|
||||
'proxmox_template_id' => 9002,
|
||||
'proxmox_template_ref' => null,
|
||||
],
|
||||
[
|
||||
'template_key' => 'linux-utility-vm',
|
||||
@@ -176,7 +199,9 @@ final class SPP_Activator
|
||||
'memory_mb' => 2048,
|
||||
'disk_gb' => 32,
|
||||
'default_ttl_hours' => 168,
|
||||
'provisioning_type' => 'qemu',
|
||||
'proxmox_template_id' => 9003,
|
||||
'proxmox_template_ref' => null,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user