Automation

 View Only
Expand all | Collapse all

Get-ScsiLunPath and SanID

  • 1.  Get-ScsiLunPath and SanID

    Posted May 19, 2010 11:27 AM

    Hi All, I am trying to get the WWN for the SAN Port for the paths for all Luns on an ESX Server. The problem I have is that the value of the SANID is not in a format I recognise. Is there some convertion I need to do do to get the SANID to a readable format.

    Example:

    Within My script I retrieve the value : 101:96:105:107:104:116:118:98

    Where as I would normally expect it to look like : 50:00:09:74:08:0D:2D:1D

    S69



  • 2.  RE: Get-ScsiLunPath and SanID

    Posted May 19, 2010 12:23 PM

    Hi

    it's a bug, and it is confirmed, but not yet fixed.

    /Allan

    http://doitsmarter.blogspot.com/



  • 3.  RE: Get-ScsiLunPath and SanID

    Posted May 19, 2010 01:45 PM

    Have a look at Get-ScsiLunPath WWN's

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 4.  RE: Get-ScsiLunPath and SanID

    Posted May 19, 2010 02:07 PM

    Hi LucD, thanks for the response. If I am reading it right, is the

    script you have provided in the referenced post getting the WWN of the

    HBA? I am actually looking for the WWN of the target SAN Port not the

    WWN of the HBA.

    Do you have any suggestions?

    S69



  • 5.  RE: Get-ScsiLunPath and SanID

    Posted May 19, 2010 05:07 PM

    Try the following, should give the SAN port.

    $esxName = <esx-name>
    $hbaTab = @{}
    $lunTab = @{}
    
    $esx = Get-VMHost -Name $esxName | Get-View
    $esx.Config.StorageDevice.HostBusAdapter | %{
    	$hbaTab.Add($_.Key, $_.Device)
    }
    
    $esx.Config.StorageDevice.ScsiLun | %{
    	$lunTab.Add($_.Key, $_.CanonicalName)
    }
    
    $report = @()
    
    foreach($hba in $esx.Config.StorageDevice.ScsiTopology.Adapter){
    	if($hba.Adapter -like "*FibreChannelHba*"){
    		foreach($tgt in $hba.Target){
    			foreach($lun in $tgt.Lun){
    				$row = "" | Select hbaName, Lun, NodeWWN
    				$row.hbaName = $hbaTab[http://$hba.Adapter|http://$hba.Adapter]
    				$row.Lun = $lunTab[http://$lun.ScsiLun|http://$lun.ScsiLun]
    				$row.NodeWWN = "{0:x}" -f $tgt.Transport.NodeWorldWideName
    				$report += $row
    			}
    		}
    	}
    }
    $report | Sort-Object -Property hbaName,Lun,NodeWWN -Unique
    

    The -Unique parameter is in there to suppress the duplicate entries.

    The script is attached since it contains some square brackets and the forum SW doesn't like those.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 6.  RE: Get-ScsiLunPath and SanID

    Posted Jun 01, 2010 12:06 PM

    LucD, sorry for the delay, the email went to junk mail. This is perfect and does exactly what I need, thanks again.

    S69



  • 7.  RE: Get-ScsiLunPath and SanID

    Posted Aug 23, 2010 06:26 PM

    I tried using the script and it did return information regarding the FC targets but it was not what I was expecting. For example when I look in the vSphere client Manage Paths screen for a given LUN it displays the target address as follows:

    50:0a:09:80:87:79:7a:9b 50:0a:09:84:87:79:7a:9b (two sets of number)

    However the output of the script is only the first set of numbers. 50:0a:09:80:87:79:7a:9b

    This is a problem since the first set of numbers is the same for every path and the second set of numbers is where I am able to tell what unique port the path is going to on the filer.

    Is the output being truncated? If so how can I use this script to get the second set of numbers or even both?

    thanks



  • 8.  RE: Get-ScsiLunPath and SanID

    Posted Aug 23, 2010 06:33 PM

    I'll posted the answer in your other thread.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 9.  RE: Get-ScsiLunPath and SanID

    Posted Sep 01, 2010 06:55 AM

    I just testen this on PowerCLI and WWN's are back to normal!



  • 10.  RE: Get-ScsiLunPath and SanID

    Posted Nov 26, 2010 03:05 PM

    Hello LucD, your script works very well. Currently, it displays : hbaName, Lun, NodeWWN

    Do you think it could be possible to add the status (Active/Standby) for each Lun as we can see with this command : " Get-VMHost -name $esxName | Get-ScsiLun | Get-ScsiLunPath | select State "

    My programming skills are not good enough to link that information with your script.

    Thank you very much for your help.

    ps : Should I open a newdiscussion for my question ?



  • 11.  RE: Get-ScsiLunPath and SanID

    Posted Nov 26, 2010 04:37 PM

    Sure, try the attached script.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 12.  RE: Get-ScsiLunPath and SanID

    Posted Dec 02, 2010 09:36 AM

    That is very nice, thanks a lot for your help LucD.



  • 13.  RE: Get-ScsiLunPath and SanID

    Posted Dec 21, 2010 09:53 AM

    Hello LucD, sorry about the delay but I was not able to try your new LUN-SAN-WWN-hex-state.ps1 script before today.

    Unfortunatly the state row does not display anything.

    Does it work on your system ?



  • 14.  RE: Get-ScsiLunPath and SanID

    Posted Dec 21, 2010 09:59 AM

    Hi, just ran the script again. And yes, I get the correct State displayed.

    Is it only the State property that is  missing ?

    Are you looking at FC storage ?

    In the vSphere Clienrt I assume everything displays correctly ?



  • 15.  RE: Get-ScsiLunPath and SanID

    Posted Dec 22, 2010 08:46 AM

    Hello LucD, indeed, your script works for our servers running at least Vmware ESX 4.0.0 not previous versions.

    Thanks a lot for your time anyway.



  • 16.  RE: Get-ScsiLunPath and SanID

    Posted Dec 22, 2010 12:42 PM

    In was hoping to find the output that's similar to output of esx command:

    vmware-cim-cmd "hostsvc/summary/scsilun". Its usefull to get the UUID property because that's what my storage team understands when i request a removal of certain LUN.

    Any chance of adding that part to this script.

    running powercli version 4.1

    it should work against api25/esx35 and api41/vSphere 4.1

    thanks