VM Storage (migration phase)
| VM | Legacy Host | Destination Host | VHDX Storage | VNX Luns | SVC Luns | ";
$rendered_luns = []; // Array to track what has been rendered
if (!empty($luns)) {
foreach ($luns as $lun) {
$lun_name = ($type === 'VNX' && str_contains($lun['name'], '_')) ? explode("_", $lun['name'])[1] : $lun['name'];
$lun_size = $lun['size'];
// Create a unique key for this LUN to detect duplicates
$unique_key = $lun_name . ':' . $lun_size;
// If we have already rendered this exact LUN, skip it
if (in_array($unique_key, $rendered_luns)) {
continue;
}
// Render the LUN and add its key to our tracking array
$html .= htmlspecialchars($lun_name) . " : " . htmlspecialchars($lun_size) . "GB \n"; $rendered_luns[] = $unique_key; } } $html .= " | ";
return $html;
}
// Render rows for VMs
foreach ($vms as $vm) {
echo "|
|---|---|---|---|---|---|---|---|
| " . htmlspecialchars($vm['Name']) . " | "; if (str_contains($vm['Owner'], "SYN") || str_contains($vm['Owner'], "MIG")) { echo "" . htmlspecialchars($vm['Owner']) . " | "; } else { echo "" . htmlspecialchars($vm['Owner']) . " | "; } // --- CORRECTED VHDX RENDERING --- $vhdx_parts = []; if (!empty($vm['VHDXs'])) { // 1. Split the string into an array of individual VHDX entries $vhdx_entries = explode('|', $vm['VHDXs']); foreach ($vhdx_entries as $entry) { // 2. Replace the first comma (after .vhdx) with " : " and add "GB" // The limit parameter '2' ensures we only replace the first occurrence. $formatted_entry = preg_replace('/\.vhdx,/', ' : ', $entry, 1) . 'GB'; $vhdx_parts[] = $formatted_entry; } } // 3. Join all formatted parts with a comma and a space echo " | " . implode(' ', $vhdx_parts) . " | ";
if ($vm['WWPNs'] != "") {
$hostname = $vm['Name'];
$vnx_luns = $luns_by_hostname[$hostname]['VNX'] ?? [];
$svc_luns = $luns_by_hostname[$hostname]['SVC'] ?? [];
echo renderLuns($vnx_luns, 'VNX');
echo renderLuns($svc_luns, 'SVC');
} else {
echo ""; } echo " | ||
| " . htmlspecialchars($hostname) . " (Cluster) | "; echo ""; // Empty cells for Legacy, Destination, VHDX $vnx_luns = $luns_by_hostname[$hostname]['VNX'] ?? []; $svc_luns = $luns_by_hostname[$hostname]['SVC'] ?? []; echo renderLuns($vnx_luns, 'VNX'); echo renderLuns($svc_luns, 'SVC'); echo " |