feat: add unused drives handling and update device bus modal labels for clarity
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user