diff --git a/extensions/Servers/Proxmox/Livewire/Storage.php b/extensions/Servers/Proxmox/Livewire/Storage.php index 154981183..e9609aabb 100644 --- a/extensions/Servers/Proxmox/Livewire/Storage.php +++ b/extensions/Servers/Proxmox/Livewire/Storage.php @@ -15,6 +15,11 @@ class Storage extends Component */ public array $drives = []; + /** + * List of detached/unused drives. + */ + public array $unusedDrives = []; + /** * Total allocated storage size in GB. */ @@ -121,6 +126,13 @@ class Storage extends Component public bool $showDeleteModal = false; public ?string $deletingDriveKey = null; + /** + * Form state for reattach modal. + */ + public bool $showReattachModal = false; + public ?string $reattachingDriveKey = null; + public string $reattachTargetBus = 'scsi'; + /** * Storage name for cephpool. */ @@ -225,6 +237,53 @@ class Storage extends Component $this->drives = $drives; $this->totalAllocatedStorage = $totalSize; + + // Parse unused/detached drives + $unusedDrives = []; + foreach ($config as $key => $value) { + if (!preg_match('/^unused(\d+)$/', $key, $matches)) { + continue; + } + + // Skip excluded disks + if ($this->isExcludedDisk($value)) { + continue; + } + + $unusedIndex = (int) $matches[1]; + $unusedInfo = $this->parseUnusedDiskString($value, $unusedIndex); + if ($unusedInfo) { + $unusedDrives[$key] = $unusedInfo; + } + } + + // Sort unused drives by index + uksort($unusedDrives, function ($a, $b) { + preg_match('/^unused(\d+)$/', $a, $matchA); + preg_match('/^unused(\d+)$/', $b, $matchB); + return (int) $matchA[1] <=> (int) $matchB[1]; + }); + + $this->unusedDrives = $unusedDrives; + } + + /** + * Parse an unused disk configuration string. + */ + protected function parseUnusedDiskString(string $value, int $unusedIndex): ?array + { + // Example: cephpool:vm-100-disk-1 + // Unused disks typically just have the volume reference + $volume = trim($value); + + // Try to extract size from volume name or fetch from storage + // For now, we'll mark size as unknown until reattached + return [ + 'key' => 'unused' . $unusedIndex, + 'index' => $unusedIndex, + 'volume' => $volume, + 'label' => 'Detached Disk ' . $unusedIndex, + ]; } /** diff --git a/extensions/Servers/Proxmox/views/storage.blade.php b/extensions/Servers/Proxmox/views/storage.blade.php index efd6a7b10..812adc769 100644 --- a/extensions/Servers/Proxmox/views/storage.blade.php +++ b/extensions/Servers/Proxmox/views/storage.blade.php @@ -280,10 +280,12 @@ @@ -527,7 +529,7 @@ @endif - + @if($showMoveDriveModal && $movingDriveKey && isset($drives[$movingDriveKey])) @php $moveDrive = $drives[$movingDriveKey]; @endphp
@@ -535,7 +537,7 @@
-

Move Drive - {{ $moveDrive['label'] }}

+

Change Device Bus - {{ $moveDrive['label'] }}

@@ -566,7 +568,7 @@ @if($status && $status->status !== 'stopped')
- VM must be stopped to move drives. + VM must be stopped to change device bus.
@endif
@@ -581,8 +583,8 @@ class="px-4 py-2 text-sm font-medium rounded-lg bg-primary text-white hover:bg-primary/90 disabled:opacity-50 transition-colors" @if($status && $status->status !== 'stopped') disabled @endif> - Move Drive - Moving... + Change Bus + Changing...