fix: always allocate VMID as max+1 to prevent reuse of deleted server VMIDs
This commit is contained in:
@@ -830,7 +830,16 @@ class Proxmox extends ClassServer
|
||||
$ipv6 = $this->getAvailableIps($node, $settings['ipv6'], 'ipv6');
|
||||
}
|
||||
|
||||
$vm_id = $this->request('/cluster/nextid')->json()['data'];
|
||||
// Get the next VMID by finding the maximum existing VMID and adding 1
|
||||
// This ensures we never reuse old VMIDs from deleted servers
|
||||
$clusterResources = $this->request('/cluster/resources', 'get', ['type' => 'vm'])->json()['data'] ?? [];
|
||||
$maxVmId = 99; // Default minimum VMID in Proxmox is 100
|
||||
foreach ($clusterResources as $resource) {
|
||||
if (isset($resource['vmid']) && $resource['vmid'] > $maxVmId) {
|
||||
$maxVmId = (int) $resource['vmid'];
|
||||
}
|
||||
}
|
||||
$vm_id = $maxVmId + 1;
|
||||
|
||||
$password = Str::password(16);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user