### SECTION HEADER ############################################################# # TYPE : # # DESCRIPTION : # # PARMS PASSED : # # RESULT : # # VERSIONS : 1.0 03/11/2009 SC First version. # ################################################################################ function enumerateHostStorage() { param( [VMware.VimAutomation.Types.VMHost] $vihost = $null ) [VMware.VimAutomation.Types.VMHost] $Local:objHost = $vihost; [VMware.Vim.HostSystem] $Local:objHostView = $null; [VMware.Vim.HostStorageSystem] $Local:objHostStorageSystemView = $null; [String] $Local:strCurrentAdapter = ""; [Int] $Local:intLunCount = 0; [Int] $Local:intLunIndex = 0; [Int] $Local:intPathCount = 0; [Int] $Local:intPathIndex = 0; [VMware.Vim.HostMultipathInfoLogicalUnit] $Local:objScsiLun = $null; [VMware.Vim.HostMultipathInfoPath] $Local:objScsiPath = $null; [VMware.Vim.HostFibreChannelHba] $Local:objHBA = $null; [VMware.Vim.HostScsiDisk] $Local:objScsiDisk = $null; # # # if ( $objHost -eq $null ) { $intRc = -1; } #if # # Get a .NET view for the host. # if ( $intRc -eq 0 ) { $objHostView = Get-View -id $objHost.id if ( ! $? ) { logError -line "ERROR : Failed to get .NET host view." $intRc = -2; break; } else { logLine -line "Got .NET view for host..." } #else-if } #if # # Get a .NET view for the host. # if ( $intRc -eq 0 ) { $objHostStorageSystemView = Get-View -id $objHostView.ConfigManager.StorageSystem if ( ! $? ) { logError -line "ERROR : Failed to get .NET host storage system view." $intRc = -3; break; } else { logLine -line "Got .NET view for host storage..." } #else-if } #if # # Enumerate the Fibre Channel HBAs. # if ( $intRc -eq 0 ) { $objVMHostStorageView.StorageDeviceInfo.HostBusAdapter | Where-Object{ $_.Key -like "*FibreChannelHba*" } | ForEach-Object { $objHBA = $_; $strCurrentAdapter = $objHBA.Key logLine -line ( "Processing Adapter [" + $objHBA.Device + "]..." ) # # Now enumerate the SCSI paths, looking for active paths involving the current adapter. # # # Enumerate the LUNs. # $intLunCount = $objVMHostStorageView.StorageDeviceInfo.MultiPathInfo.Lun.Length for ( $intLunIndex = 0; $intLunIndex -lt $intLunCount; $intLunIndex++ ) { $objScsiLun = $objVMHostStorageView.StorageDeviceInfo.MultiPathInfo.Lun[$intLunIndex]; #logLine -line ( "Processing LUN..." ) # [" + $objScsiLun.Lun + "]..." ) # # Now enumerate the paths for the current LUN. # $intPathCount = $objScsiLun.Path.Length for ( $intPathIndex = 0; $intPathIndex -lt $intPathCount; $intPathIndex++ ) { $objScsiPath = $objVMHostStorageView.StorageDeviceInfo.MultiPathInfo.Lun[$intLunIndex].Path[$intPathIndex] if ( ($objScsiPath.PathState -eq "active") -and ($objScsiPath.Adapter -eq $strCurrentAdapter) ) { # # Now pull some info from StorageDeviceInfo.ScsiLun. # $objScsiDisk = $objVMHostStorageView.StorageDeviceInfo.ScsiLun | Where-Object{ ($_.Uuid -eq $objScsiLun.Id) -and ($_.DeviceType -eq "disk") } if ( $objScsiDisk -ne $null ) { Write-Host ( "Active Path to LUN:" ) Write-Host ( " objScsiLun.Key : " + $objScsiLun.Key ) Write-Host ( " objScsiLun.Id : " + $objScsiLun.Id ) Write-Host ( " objScsiLun.Lun : " + $objScsiLun.Lun ) Write-Host ( " objScsiDisk.DevicePath : " + $objScsiDisk.DevicePath ) Write-Host ( " objScsiDisk.Vendor : " + $objScsiDisk.Vendor ) Write-Host ( " objScsiDisk.Model : " + $objScsiDisk.Model ) Write-Host ( " objScsiDisk.CanonicalName : " + $objScsiDisk.CanonicalName ) Write-Host ( " objScsiDisk.DisplayName : " + $objScsiDisk.DisplayName ) Write-Host ( "" ) } #if } #if } #for (path) } #for (lun) } #ForEach-Object } #if return; } ### END OF SECTION #############################################################