Quick Installation
- Purchase the module and download
haikhavan_proxmox_ve-ioncube-8.2-1.0.0-install.zipfrom your VPSrv Client Area Downloads. - Upload and extract the ZIP into your WHMCS root directory so files land in
modules/addons/haikhavan_proxmox_ve/andmodules/servers/haikhavan_proxmox_ve/. - Verify PHP 8.2–8.4 with ionCube PHP Loader 14+ / 15.5+ is enabled on your server.
- Go to System Settings → Addon Modules in WHMCS Admin, click Activate next to Haikhavan Proxmox VE VPS & Cloud, and assign administrator role access.
All-in-one Proxmox VE 8.x & 9.x KVM & LXC provisioning suite for WHMCS — unifying single-VM VPS products and multi-instance Cloud Resource Pools with a live Cluster Capacity Planner & Overcommit Guard, Visual Cloud-Init Builder, Proxmox Backup Server (PBS) deduplicated incremental backups, SDN/IPv4/IPv6 pools, 1-click Rescue ISO boot, and audited noVNC/Xterm.js/SPICE consoles.
Haikhavan Proxmox VE VPS & Cloud — Technical Documentation (v1.0.0)
Authoritative engineering specification for haikhavan_proxmox_ve covering the dual Server + Addon architecture, all 9 MySQL tables, AES-256-CBC + HMAC-SHA256 credential vault, Proxmox VE 8.x/9.x REST API client, Live Cluster Capacity Planner & Thermal/Overcommit Guard algorithm, Visual Cloud-Init YAML generator, WHMCS Server Module callbacks, WHMCS Hooks, and AJAX API endpoints.
1. Dual-Module Architecture
modules/
├── addons/haikhavan_proxmox_ve/
│ ├── haikhavan_proxmox_ve.php # Addon lifecycle (_config, _activate, _deactivate, _upgrade, _output, _clientarea)
│ ├── hooks.php # 5 WHMCS hooks (Navbar, Sidebar, AdminHomeWidget, AdminClientServicesTabFields, DailyCronJob)
│ ├── whmcs.json # Addon manifest
│ ├── lib/
│ │ ├── Database.php # 9-table Capsule schema DDL, AES-256-CBC+HMAC vault, UPID task/audit logger, default seeder
│ │ ├── ProxmoxApiClient.php # Native cURL Proxmox VE /api2/json client (PVEAPIToken + PVE/PAM ticket auth)
│ │ ├── ClusterPlanner.php # Live Capacity Planner, Thermal/Overcommit Guard & weighted headroom scorer
│ │ ├── CloudInitBuilder.php # Visual #cloud-config YAML generator & stack presets (Docker, WireGuard, LAMP, CIS)
│ │ ├── ProvisioningService.php # Shared VPS/Cloud provisioning, IP allocation, power, Rescue ISO, PBS/Snapshots, consoles
│ │ ├── SandboxSimulator.php # Deterministic 3-node PVE 9.x + PBS + RRD + Console simulator
│ │ ├── AdminController.php # 7-tab Admin Orchestrator + 19-op CSRF-protected AJAX router
│ │ └── ClientController.php # 8-tab Client Portal & Server ClientArea builder + 18-op CSRF-protected AJAX router
│ ├── templates/
│ │ ├── admin/dashboard.php # Admin Orchestrator view
│ │ └── client/portal.tpl # Smarty Client Portal (shared by Addon & Server module)
│ └── assets/
│ ├── css/haikhavan_proxmox_ve.css # Scoped .hk-pve-* stylesheet with Light + Proxmox Dark Slate theme support
│ └── js/haikhavan_proxmox_ve.js # Zero-CDN HTML5 Canvas RRD renderer + Admin/Client AJAX controller
└── servers/haikhavan_proxmox_ve/
├── haikhavan_proxmox_ve.php # WHMCS Server Provisioning module (MetaData, ConfigOptions, TestConnection, Create/Suspend/Unsuspend/Terminate, ChangePackage, ChangePassword, AdminCustomButtonArray, AdminServicesTabFields, ClientArea, UsageUpdate)
├── templates/clientarea.tpl # Includes shared Client Portal template
└── whmcs.json # Server module manifest
Both modules share the PSR-4-style ProxmoxVePro\ autoloader pointing to modules/addons/haikhavan_proxmox_ve/lib/, ensuring zero duplicated business logic.
2. Database Schema (9 Custom Tables)
Created idempotently in ProxmoxVePro\Database::install() via WHMCS\Database\Capsule::schema(). All tables are preserved on module deactivation.
| Table | Purpose | Key Columns & Indexes |
|---|---|---|
mod_hk_pve_clusters |
Proxmox VE 8.x/9.x cluster registry, encrypted API credentials, PBS datastore, Overcommit Guard caps & cached node metrics | id (PK), name (UNIQUE), hostname, port (8006), auth_type (api_token|pve|pam), username, token_id, secret_encrypted, default_storage, backup_storage, console_proxy_url, pbs_endpoint, pbs_datastore, vmid_min, vmid_max, cpu_overcommit_max, ram_limit_pct, disk_limit_pct, maintenance_mode, nodes_cache_json |
mod_hk_pve_instances |
Provisioned KVM (qemu) VMs & lxc containers mapped to WHMCS clients & services |
id (PK), userid (IDX), service_id (IDX), cluster_id (IDX), product_mode (vps|cloud), virt_type (qemu|lxc), vmid (IDX), node (IDX), hostname, status, sockets, vcpus, ram_mb, swap_mb, disk_gb, bandwidth_gb, bandwidth_used_gb, primary_ipv4, primary_ipv6, private_ip, vlan_tag, template_slug, rescue_mode, qemu_agent, ha_enabled, ssh_public_key, cloudinit_userdata, extra_disks_json, pool_limits_json |
mod_hk_pve_ip_pools |
Public IPv4/IPv6 & Private Proxmox SDN/VXLAN IP allocations | id (PK), cluster_id (IDX), pool_name, pool_type (public|private|sdn), ip_version (4|6), ip_address (IDX), cidr, gateway, netmask, bridge, vlan_tag, mac_address, status (IDX), instance_id (IDX), service_id (IDX), UNIQUE(cluster_id, ip_address) |
mod_hk_pve_templates |
OS templates, App Stacks, KVM/LXC archives & Rescue ISOs | id (PK), slug (UNIQUE), name, app_group, category (os|app|iso|archive), virt_type (qemu|lxc|both), source_vmid, iso_volid, default_user, min_cpu, min_ram_mb, min_disk_gb, ha_recommended, enabled |
mod_hk_pve_cloudinit_profiles |
Reusable Cloud-Init visual profiles (global userid=0 or client-owned) |
id (PK), userid (IDX), name, preset_stack, default_user, ssh_keys, ipv4_mode, ipv6_mode, dns_servers, search_domain, packages_csv, runcmd_script, rendered_yaml |
mod_hk_pve_snapshots |
Live VM/RAM snapshots & PBS deduplicated incremental backups | id (PK), instance_id (IDX), kind (snapshot|backup|pbs), name, volid, storage, size_mb, dedup_ratio, include_ram, protected, description, status, created_at |
mod_hk_pve_backup_schedules |
Automated hourly/daily/weekly snapshot & PBS retention policies | id (PK), instance_id (IDX), kind, frequency (hourly|daily|weekly), keep_last, storage, enabled, last_run_at, next_run_at |
mod_hk_pve_firewall_rules |
Per-VM / LXC Ingress & Egress firewall rules | id (PK), instance_id (IDX), pos, direction (IN|OUT), action (ACCEPT|DROP|REJECT), proto (tcp|udp|icmp|any), source, dest, dport, sport, comment, enabled |
mod_hk_pve_tasks_log |
Complete Proxmox UPID task log & Console session compliance audit trail | id (PK), userid (IDX), adminid (IDX), service_id (IDX), instance_id (IDX), cluster_id (IDX), upid, action (IDX), console_protocol (novnc|xtermjs|spice), status, summary, details_json, ip_address, created_at |
3. Security & Cryptographic Architecture
3.1 Credential Encryption at Rest (AES-256-CBC + HMAC-SHA256)
Implemented in Database::encryptSecret() / Database::decryptSecret():
- Key Derivation: Derives independent 256-bit encryption (
pve_pro_enc_v1) and MAC (pve_pro_mac_v1) keys viahash_hmac('sha256', ...)from WHMCS$cc_encryption_hash. - Encrypt-then-MAC: Fresh 16-byte CSPRNG IV (
random_bytes(16)),AES-256-CBC(OPENSSL_RAW_DATA), 32-byte HMAC-SHA256 overIV || ciphertext, versioned envelopev1:<base64(iv + mac + ciphertext)>. - Constant-Time Verification:
hash_equals($mac, $calcMac)verified prior to decryption.
3.2 CSRF, Tenant Isolation & Output Escaping
- CSRF Tokens: Independent 48-hex-char session tokens (
$_SESSION['hk_pve_admin_csrf'],$_SESSION['hk_pve_client_csrf']) verified withhash_equals()on every mutating POST/AJAX request (HTTP403on mismatch). - Client Ownership Enforcement:
ClientController::requireOwnedInstance($userId)requires bothidANDuserid = $_SESSION['uid']. - Protected Backups: Server-side guard refuses deletion (HTTP
403) on any snapshot/PBS backup withprotected = 1. - Output Escaping: Every admin output passes through
$e()(htmlspecialchars(..., ENT_QUOTES, 'UTF-8')); every Smarty variable uses|escape.
4. Proxmox VE REST API Integration (ProxmoxApiClient)
Connects over HTTPS (https://<host>:<port>/api2/json):
- API Token Auth (Recommended):
Authorization: PVEAPIToken=<user@realm>!<tokenid>=<secret> - PVE / PAM Ticket Auth:
POST /access/ticket-> attachesCookie: PVEAuthCookie=...+CSRFPreventionToken: ...on mutations. - Endpoints Implemented:
- Cluster & Nodes:
GET /version,GET /nodes,GET /cluster/resources,GET /cluster/nextid - KVM & LXC:
POST /nodes/{node}/qemu/{tpl}/clone,POST /nodes/{node}/qemu,POST /nodes/{node}/lxc,POST /nodes/{node}/{type}/{vmid}/status/{action},PUT /nodes/{node}/{type}/{vmid}/config,PUT /nodes/{node}/{type}/{vmid}/resize,DELETE /nodes/{node}/{type}/{vmid},POST /nodes/{node}/{type}/{vmid}/migrate - Snapshots & PBS:
GET/POST /nodes/{node}/{type}/{vmid}/snapshot,POST .../snapshot/{name}/rollback,DELETE .../snapshot/{name},POST /nodes/{node}/vzdump - Firewall & RRD:
GET/POST/DELETE /nodes/{node}/{type}/{vmid}/firewall/rules,GET /nodes/{node}/{type}/{vmid}/rrddata - Consoles:
POST .../vncproxy,POST .../termproxy,POST .../spiceproxy
- Cluster & Nodes:
5. Live Cluster Capacity Planner & Thermal/Overcommit Guard
ClusterPlanner::evaluateCluster() and ClusterPlanner::selectBestNode() evaluate every node before Auto-Node provisioning or live migration:
- Hard Exclusion Guards: A node is marked Guarded (Ineligible) if any condition triggers:
- Node offline or Maintenance Mode enabled
- Projected vCPU-to-pCPU ratio
>= cpu_overcommit_max(default4.0x) - Projected RAM utilization
>= ram_limit_pct(default88%) - Projected Storage utilization
>= disk_limit_pct(default85%) - Hypervisor CPU temperature
>= 78°C(Thermal Guard)
- Weighted Headroom Placement Score (
0–100):
Eligible nodes are sorted descending by headroom score; Auto-Node selects the highest-headroom node that still satisfies all caps after adding the new VM's vCPU/RAM/Disk.score = (100 - ram_pct) * 0.40 + (100 - disk_pct) * 0.30 + (100 - cpu_ratio / cpu_cap * 100) * 0.20 + (100 - iops_load_pct) * 0.10
6. WHMCS Hooks & Server Module Callbacks
6.1 Registered Addon Hooks (hooks.php)
ClientAreaPrimaryNavbar— Adds Proxmox VE Cloud & VPS (index.php?m=haikhavan_proxmox_ve) under Services.ClientAreaPrimarySidebar— Adds Proxmox VE Control Panel shortcut to Service Details Actions.AdminHomeWidgets— Registers Proxmox VE Cluster Capacity & Health widget (Running VMs, Eligible Nodes, Guarded Nodes, Cluster RAM %, PBS Backups, Failed Tasks).AdminClientServicesTabFields— Displays VMID, Node, Status, Specs, IPv4 & direct Orchestrator link on Admin Service profiles.DailyCronJob— Executes due rows inmod_hk_pve_backup_schedules(hourly/daily/weekly PBS backups & snapshots) and advancesnext_run_at.
6.2 WHMCS Server Provisioning Callbacks (modules/servers/haikhavan_proxmox_ve/haikhavan_proxmox_ve.php)
haikhavan_proxmox_ve_MetaData,haikhavan_proxmox_ve_ConfigOptions(15 fields),haikhavan_proxmox_ve_TestConnection,haikhavan_proxmox_ve_CreateAccount,haikhavan_proxmox_ve_SuspendAccount,haikhavan_proxmox_ve_UnsuspendAccount,haikhavan_proxmox_ve_TerminateAccount,haikhavan_proxmox_ve_ChangePackage,haikhavan_proxmox_ve_ChangePassword,haikhavan_proxmox_ve_AdminCustomButtonArray(8 custom actions: Start, Reboot, Shutdown, Stop, Toggle Rescue ISO, Create Snapshot, Create PBS Backup, Migrate to Best Node),haikhavan_proxmox_ve_AdminServicesTabFields,haikhavan_proxmox_ve_ClientArea,haikhavan_proxmox_ve_UsageUpdate.
7. AJAX API Endpoints Reference
7.1 Admin AJAX (admin/addonmodules.php?module=haikhavan_proxmox_ve&ajax=1, CSRF-Protected)
save_cluster, delete_cluster, test_cluster, toggle_node_maintenance, provision_vm, power_action, migrate_vm, toggle_rescue, terminate_vm, launch_console, add_ip_pool, delete_ip, save_template, delete_template, save_cloudinit, delete_cloudinit, create_snapshot, toggle_protect_snapshot, delete_snapshot.
7.2 Client AJAX (index.php?m=haikhavan_proxmox_ve&ajax=1, CSRF-Protected Writes)
power_action, launch_console, rrd_stats (GET), toggle_rescue, reinstall, update_cloudinit, create_snapshot, rollback_snapshot, toggle_protect_snapshot, delete_snapshot, save_schedule, delete_schedule, add_fw_rule, delete_fw_rule, add_extra_disk, deploy_cloud_vm, delete_cloud_vm.
8. Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
| Overcommit Guard blocks Auto-Node placement | All cluster nodes exceed cpu_overcommit_max, ram_limit_pct, disk_limit_pct, 78°C thermal guard, or are in Maintenance Mode. |
Exit Maintenance Mode on an eligible node, live-migrate workloads, add cluster capacity, or adjust Overcommit Guard thresholds in Module Settings. |
| Proxmox API returns HTTP 401/403 | API Token lacks PVEAdmin / PVEVMAdmin privileges or Privilege Separation is enabled without ACL grants. |
In Proxmox Datacenter -> Permissions, grant the token VM.Allocate, VM.Audit, VM.Console, VM.PowerMgmt, VM.Snapshot, Datastore.AllocateSpace, and SDN.Use. |
| Protected backup deletion rejected (HTTP 403) | Expected safety lock (protected = 1) prevents accidental purge. |
Click the Lock icon to unprotect the archive before deleting. |
| Sandbox nodes shown in production | sandbox_mode is still enabled. |
Uncheck Local Dev Sandbox / Demo Mode under Addon Module settings and register your production PVE cluster. |