Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
Hello everybody, I'm trying to get LUN WWN with PowerShell and I faced with issue.
At PS side:
PS C:\> Get-NaLunSerialNumber /vol/AIX_TEST/AIX_TEST
D0zdE+CP/KHo
PS C:\> Get-NaLunTargetDeviceId -serialnumber "D0zdE+CP/KHo" -Protocol fcp
Get-NaLunTargetDeviceId : Extra input: protocol
At line:1 char:24
+ Get-NaLunTargetDeviceId <<<< -serialnumber "D0zdE+CP/KHo" -Protocol fcp
+ CategoryInfo : InvalidOperation: (xx.xx.xx.xx:NaController) [Get-NaLunTargetDeviceId], EINVALIDINPUTERROR
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.Lun.GetNaLunTargetDeviceId
At controller side:
fas-bottom1> Wed AprWed Apr 10 16:34:37 VOLT 10 16: [fas-bottom1:api.input.invalidSchema:warning]: Error in API input schema validation. API name: lun-get-target-device-id. Detailed error: Extra input: protocol.
34:37 VOLT [fas-bottom1:api.input.invalidSchema:warning]: Error in API input schema validation. API name: lun-get-target-device-id. Detailed error: Extra input: protocol.
As you can see I did mark "Extra input: protocol", because if I try to use Get-NaLunTargetDeviceId without -Protocol I get this:
PS C:\Distr> Get-NaLunTargetDeviceId -serialnumber "D0zdE+CP/KHo"
cmdlet Get-NaLunTargetDeviceId at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
Protocol: fcp
Get-NaLunTargetDeviceId : Extra input: protocol
At line:1 char:24
+ Get-NaLunTargetDeviceId <<<< -serialnumber "D0zdE+CP/KHo"
+ CategoryInfo : InvalidOperation: (xx.xx.xx.xx:NaController) [Get-NaLunTargetDeviceId], EINVALIDINPUTERROR
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.Lun.GetNaLunTargetDeviceId
Suggestions?
Solved! See The Solution
I guess I solve the problem. (with information from this topic https://communities.netapp.com/thread/27473)
$a = Get-NaLunSerialNumber /vol/vol1/lun1;
$b = $a.ToCharArray();
Foreach ($element in $b) {$c = $c + [System.String]::Format("{0:X}", [System.Convert]::ToUInt32($element))}
"naa.60a98000" + $c
There's a definite mismatch between the Powershell cmdlet and the API. The API does not accept a protocol parameter.
Try this as a workaround:
function GetWWN([string] $lunSerialNo)
{
$req = New-Object "System.xml.XmlDocument"
$req.LoadXml("<lun-get-target-device-id><lun-serial-id>$lunSerialNo</lun-serial-id></lun-get-target-device-id>")
$response = Invoke-NaSystemApi $req
$response.results."target-device-id"
}
Call it like this:
Connect-NAController "mycontroller" -RPC
$lun = get-nalun -terse -path "/vol/myvol/myvollun"
GetWWN $lun.SerialNumber
Thanks for your advice!
It seems not working correctly... WWN's for two different LUN's are the same.
PS C:\Scripts> .\LunWWN.ps1
/vol/AIX_TEST/AIX_TEST
D0zdE+CP/KHo
naa.600A098200000675875
PS C:\Scripts> .\LunWWN.ps1
/vol/TClient_PROD_DataStore_02/TClient_PROD_DataStore_02
D0zdE+CP/KHs
naa.600A098200000675875
I guess I solve the problem. (with information from this topic https://communities.netapp.com/thread/27473)
$a = Get-NaLunSerialNumber /vol/vol1/lun1;
$b = $a.ToCharArray();
Foreach ($element in $b) {$c = $c + [System.String]::Format("{0:X}", [System.Convert]::ToUInt32($element))}
"naa.60a98000" + $c
###############################################################################################
## Get-NALunSerialNumberHex: Function that gathers the Hex Serial number of an NALun
###############################################################################################
Function Get-NALunSerialNumberHex {
param (
[parameter(Mandatory=$true)]
$LunPath
)
Write-Host "[Gathering Lun Serial Number]" -ForegroundColor Cyan
$LunSerial = ((Get-NaLunSerialNumber $LunPath).ToCharArray() | % {([byte][char]$_).ToString("X2")}) -join ""
return $LunSerial
}
Ok, folks, same story, but for c-mode?
There is no Get-NcLunSerialNumbercommand.