Active IQ Unified Manager Discussions

Powershell cmdlet to obtain the serial number of a LUN on CDOT.

Alcazar
4,987 Views

Im looking for the Powershell commadlet to obtain the serial number of a LUN On CDOT.  I know you can do it from 7-mode by running Get-NaLunSerialNumber, when I try to run the same command from using Get-NcLunSerialNumber, I get an error message  The term "Get-NCLUNSerialNumber" is not recognized as the sname of a cmdlet, function, script file or operable program.  Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

 

My goal is to incorporate this into WFA so WFA can email me the serial number of the newly created LUN.  I have seen a few posts showing the NCLUNserialnumber command so i believe it exists.  Im open to any other ideas as well

 

 

2 REPLIES 2

DREW_RUSSELL
4,947 Views

This was a tricky one. I ran through the various LUN commands for clustered Data ONTAP but was not able to find anything solid. However, I did find a post from mbeattie that gives the following example. I havent tried it out personally but looks like it should work.
 
Import-Module DataONTAP
$cluster = "cluster1.netapp.com"
$vserver = "vserver1"
$lunPath = "/vol/vol1/luns/lun1"
$identifier = "naa.600a0980"
$credentials = $host.ui.PromptForCredential("Connect to cluster $cluster", "Please enter the user name and password","","")
$cluster = Connect-NcController $cluster -Credential($cred)
$lun = Get-NcLun -Vserver $vserver -Path $lunPath -Controller $cluster
$serialNumber = $lun.SerialNumber
$ca = $serialNumber.ToCharArray();
$naasn = $null
Foreach($byte in $ca){
$naasn = $naasn + [System.String]::Format("{0:x}", [System.Convert]::ToUInt32($byte))
}
Write-Host "LunPath,LunSerial,NaaNumber"
Write-Host "$lunPath,$serialNumber,$identifier$naasn"
The output will look like:

LunPath,LunSerial,NaaNumber
/vol/vol1/luns/lun1,BpEwv$ElzqhW,naa.600a0980427045777624456c7a716857

sinhaa
4,910 Views

This code works Drew, thanks for the post. But to be used with WFA its needs modifications. Also it mainly tried to get NAA identifiers on luns for Vmware ESX system, so most of this code is not useful for this requirement.

 

  1. WFA runs in non-interactive mode. So $credentials = $host.ui.PromptForCredential("Connect to cluster $cluster", "Please enter the user name and password","","") will NOT work. In fact it can possibly hung the command till a command time-out occurs and users won't have a clue what's going on. WFA can detect some interactive cmdlets and prevent being hung , but not all. WFA users need to save the credentials of the cluster in WFA-> Execution -> Credentials . Or enter credentials as Parameters. For those who like interactive inputs, there is Password as User Input feature provided which helps for interactive password inputs during workflow execution.

 

  1. Write-Host also won't display anything in WFA executions. WFA command execution needs Get-WfaLogger.

 

  1. For the requirement of getting the serial number and sending this by email, I would suggest to keep modularity in commands instead of doing everything in 1 large mega command. It helps in a lot of debugging etc. In sense Create Lun and obtain the serial number in command-1 then have a 2nd command which sends email with this Lun info. This requires a feature Passing Dynamic parameters between commands and use cmdlets Add-WfaWorkflowParameter to save the generated parameter( lun serial num in our case) in cmd-1 and then Get-WfaWorkflowParameter in cmd-2 to get this value and send this info in an email.

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public