VMware Cloud Community
scottg69
Contributor
Contributor

Get-ScsiLunPath and SanID

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

Reply
0 Kudos
15 Replies
AllanChristians
Enthusiast
Enthusiast

Hi

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

/Allan

http://doitsmarter.blogspot.com/

/Allan http://doitsmarter.blogspot.com
Reply
0 Kudos
LucD
Leadership
Leadership

Have a look at Get-ScsiLunPath WWN's

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
scottg69
Contributor
Contributor

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

Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
scottg69
Contributor
Contributor

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

S69

Reply
0 Kudos
admin
Immortal
Immortal

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

Reply
0 Kudos
LucD
Leadership
Leadership

I'll posted the answer in your other thread.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
BoerLowie
Contributor
Contributor

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

Blog: http://boerlowie.wordpress.org
Reply
0 Kudos
BESANCON
Contributor
Contributor

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 ?

Reply
0 Kudos
LucD
Leadership
Leadership

Sure, try the attached script.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
BESANCON
Contributor
Contributor

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

Reply
0 Kudos
BESANCON
Contributor
Contributor

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 ?

Reply
0 Kudos
LucD
Leadership
Leadership

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 ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
BESANCON
Contributor
Contributor

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.

Reply
0 Kudos
A_S
Enthusiast
Enthusiast

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

Reply
0 Kudos