feat: implement drive detachment limits and storage quota checks in Proxmox configuration

This commit is contained in:
2025-12-05 06:27:54 -05:00
parent 0d253e4d8b
commit 0ba669340e
2 changed files with 75 additions and 16 deletions

View File

@@ -759,6 +759,12 @@ class Storage extends Component
return;
}
// Check if already at maximum detached drives (2)
if (count($this->unusedDrives) >= 2) {
$this->notify('Maximum of 2 detached drives allowed. Please reattach or delete existing detached drives first.', 'error');
return;
}
$driveKey = $this->detachingDriveKey;
$drive = $this->drives[$driveKey];
@@ -1070,6 +1076,20 @@ class Storage extends Component
$unusedDrive = $this->unusedDrives[$this->reattachingDriveKey];
$targetBus = $this->reattachTargetBus;
// Check if reattaching this drive would exceed the storage quota
// Calculate attached drives total (excluding the detached drive being reattached)
$attachedDrivesTotal = 0;
foreach ($this->drives as $drive) {
$attachedDrivesTotal += $drive['size'] ?? 0;
}
// The drive being reattached is already counted in totalAllocatedStorage (which includes unused drives)
// So we just need to check if the total exceeds the max
if ($this->totalAllocatedStorage > $this->maxAllowedStorage && $this->maxAllowedStorage > 0) {
$this->notify('Storage quota exceeded. Total storage (' . number_format($this->totalAllocatedStorage, 1) . ' GB) exceeds your plan allocation (' . number_format($this->maxAllowedStorage, 1) . ' GB). Please upgrade your service or delete drives to allow this configuration.', 'error');
return;
}
try {
$proxmox = new Proxmox;