Active IQ Unified Manager Discussions

WWID list in WFA

Sebastiaan
5,848 Views

Hi,

 

I have a WFA script to create LUN's now i want the script to include the WWID's of the created LUN's so i can deliver them to the Linux administrators. Or if this isn't possible a script to generate the WWID after the lun's we're created.

 

Thanks,

7 REPLIES 7

mbeattie
5,702 Views

Hi Sebastian,

 

You can use the "Add-WFAWorkflowParameter" cmdlet to add the value of any attribute you'd like as a WFA return parameter.

Here is an example of a WFA command to create a LUN and return the LUN's Serial Number, NAA Number and Path.

 

Hope that helps

 

/Matt

 

Param(
  [Parameter(Mandatory=$True, HelpMessage="The Cluster IP address or name")]
  [String]$Cluster,
  [Parameter(Mandatory=$True, HelpMessage="The vserver name")]
  [String]$VserverName,
  [Parameter(Mandatory=$True, HelpMessage="The volume name")]
  [String]$VolumeName,
  [Parameter(Mandatory=$False, HelpMessage="The Qtree name")]
  [String]$QtreeName,
  [Parameter(Mandatory=$True, HelpMessage="The LUN name")]
  [String]$LunName,
  [Parameter(Mandatory=$False, HelpMessage="The LUN Comment")]
  [String]$LunComment,
  [Parameter(Mandatory=$True, HelpMessage="The operating system type for the LUN")]
  [ValidateSet("solaris", "windows", "hpux", "xen", "aix", "linux", "netware", "vmware", "openvms", "hyper_v", "image", "solaris_efi", "windows_2008", "windows_gpt")]
  [String]$OSType,
  [Parameter(Mandatory=$False, HelpMessage="The space reservation mode")]
  [Bool]$SpaceReserved = $True,
  [Parameter(Mandatory=$True, HelpMessage="The LUN size in MB")]
  [Alias("LunSize_Capacity")]
  [Int]$LunSize,
  [Parameter(Mandatory=$False, HelpMessage="The size of the prefix stream in Bytes")]
  [Alias("PrefixSize_Capacity")]
  [Int]$PrefixSize = -1,
  [Parameter(Mandatory=$False, HelpMessage="The name of the QoS policy group to be attached to the LUN. This parameter is valid for clusters with ONTAP version 8.2.0 onwards.")]
  [String]$QoSPolicyGroupName
)
#'------------------------------------------------------------------------------
Function Get-AsciiToHex{
   <#
   .SYNOPSIS
   This function converts an ASCII string to Hexadecimal string.
   .DESCRIPTION
   converts an ASCII string to Hexadecimal string.
   .PARAMETER
   AsciiValue Accepts an ASCII string containing the value to be converted to Hexadecimal
   .EXAMPLE
   Get-AsciiToHex -AsciiValue "W-XPe4ctkQhp"
   #>
   [CmdletBinding()]
   Param(
      [Parameter(Position=0,
         Mandatory=$True,
         ValueFromPipeLine=$True,
         ValueFromPipeLineByPropertyName=$True)]
      [String]$AsciiValue
   )
   [Array]$hexValues = @()
   For($i = 1; $i -le $AsciiValue.Length; $i++){
      [String]$stringValue = $AsciiValue.SubString(($i -1), 1)
      [Array]$hexValues   += "{0:X}" -f [Byte][Char]$stringValue
   }
   Return [String]::join("", $hexValues).ToLower();
}#End Function
#'------------------------------------------------------------------------------
#'Connect to the cluster and vserver.
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Connecting to cluster ""$cluster"""
Connect-WfaCluster $Cluster
#'------------------------------------------------------------------------------
#'Check the ONTAP version if a QoS Policy Group is provided.
#'------------------------------------------------------------------------------
If($QoSPolicyGroupName){
   [String]$command = "Get-NcSystemVersionInfo -ErrorAction Stop"
   Try{
      $versionInfo = Invoke-Expression -Command $command -ErrorAction Stop
      Get-WFALogger -Info -Message "Executed Command`: $command"
   }Catch{
      Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
      Throw "Failed Executing Command`: $command"
   }
   $version             = $versionInfo.VersionTuple.ToString()
   $versionCompareValue = Compare-OntapVersions $version "8.2.0"
   If($versionCompareValue -lt 0){
      Throw "The QoS policy group can be set on LUNs only on clusters with ONTAP version 8.2.0 onwards."
   }
}
#'------------------------------------------------------------------------------
#'Set the LUN Path.
#'------------------------------------------------------------------------------
If($QtreeName){
   [String]$lunPath = "/vol/$VolumeName/$QtreeName/$LunName"
}Else{
   [String]$lunPath = "/vol/$VolumeName/$LunName"
}
#'------------------------------------------------------------------------------
#'Set the command to create the LUN.
#'------------------------------------------------------------------------------
$size    = [String]$LunSize + "m"
$command = "New-NcLun -Path $lunPath -Size $size -OsType $OSType -VserverContext $VserverName"
If($LunComment){
   $command += " -Comment $LunComment"
}
If($PrefixSize -ge 0){ 
   $command += " -PrefixSize $PrefixSize"
}
If(-Not($SpaceReserved)){
   $command += " -Unreserved"
}
If($QoSPolicyGroupName){
   $command += " -QosPolicyGroup $QoSPolicyGroupName"
}
[String]$command += " -ErrorAction Stop"
#'------------------------------------------------------------------------------
#'Create the LUN.
#'------------------------------------------------------------------------------
Try{
   Invoke-Expression -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed Command`: $command"
}Catch{
   Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
   Throw "Failed Executing Command`: $command"
}
#'------------------------------------------------------------------------------
#'Enumerate the LUN
#'------------------------------------------------------------------------------
[String]$command = "Get-NcLun -Path $lunPath -VserverContext $VserverName -ErrorAction Stop"
Try{
   $lun = Invoke-Expression -Command $command -ErrorAction Stop
   Get-WFALogger -Info -Message "Executed Command`: $command"   
}Catch{
   Get-WFALogger -Error -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
   Throw "Failed Executing Command`: $command"
}
[String]$lunSerial = $lun.SerialNumber
Get-WFALogger -Info -Message "The Serial Number for LUN ""$lunPath"" is ""$lunSerial"""
#'------------------------------------------------------------------------------
#'Enumerate the LUN Serial number.
#'------------------------------------------------------------------------------
If($lunSerial -eq ""){
   Throw "Failed enumerating LUN Serial Number"
}
#'------------------------------------------------------------------------------
#'Enumerate the LUN NAA number.
#'------------------------------------------------------------------------------
[String]$identifier   = "naa.600a0980"
[String]$LUNNaaNumber = $identifier + (Get-AsciiToHex -AsciiValue $lunSerial)
#'------------------------------------------------------------------------------
#'Set return parameters
#'------------------------------------------------------------------------------
Add-WfaWorkflowParameter -Name "LUNSerialNumber" -Value $lunSerial    -AddAsReturnParameter $True
Add-WfaWorkflowParameter -Name "LUNNaaNumber"    -Value $LUNNaaNumber -AddAsReturnParameter $True
Add-WfaWorkflowParameter -Name "LUNPath"         -Value $lunPath      -AddAsReturnParameter $True
#'------------------------------------------------------------------------------

 

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

abhit
5,666 Views

You can also refresh OCUM ( Get data from ONTAP) and WFA ( get data from OCUM) cache and generate a report

of the lun.serial_number.

 

Mathew's suggestion is also good. You can also write into a .csv file and mail it to the person who needs it.

 

Regards,

Abhi

PNAGASUBRAMANYA
5,386 Views

Tue May  9 18:24:13 2017: Job 423 failed.  Started at May 9, 2017 5:24:01 PM and ended at May 9, 2017 5:24:04 PM.  Error message was: Failed to evaluate workflow return parameter value '$LUNNaaNumber'

 

while executing i get this message

Please help

mbeattie
5,373 Views

Hi,

 

Can you please specifiy which WFA version are you using? It could be an issue with the "Add-WfaWorkflowParameter" CmdLet

To test that i would recommend logging what the return parameter variable values are. If the values are correct the issue is caused by the "Add-WfaWorkflowParameter" cmdlet

 

#'------------------------------------------------------------------------------
#'Enumerate the LUN NAA number.
#'------------------------------------------------------------------------------
[String]$identifier   = "naa.600a0980"
[String]$LUNNaaNumber = $identifier + (Get-AsciiToHex -AsciiValue $lunSerial)
#'------------------------------------------------------------------------------
#'Log the return paramater values.
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message "Adding WFA return parameter ""LUNSerialNumber""`: $lunSerial"
Get-WFALogger -Info -Message "Adding WFA return parameter ""LUNNaaNumber""`: $LUNNaaNumber"
Get-WFALogger -Info -Message "Adding WFA return parameter ""LUNPath""`: $lunPath"
#'------------------------------------------------------------------------------
#'Set return parameters
#'------------------------------------------------------------------------------
Add-WfaWorkflowParameter -Name "LUNSerialNumber" -Value $lunSerial    -AddAsReturnParameter $True
Add-WfaWorkflowParameter -Name "LUNNaaNumber"    -Value $LUNNaaNumber -AddAsReturnParameter $True
Add-WfaWorkflowParameter -Name "LUNPath"         -Value $lunPath      -AddAsReturnParameter $True
#'------------------------------------------------------------------------------

/Matt

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

PNAGASUBRAMANYA
5,335 Views

Thank you for your reply Matt,

 

iam using wfa ver 4.1.0.0.2

i used the code you mentioned and i can see the values in the execution status (pic attached)

 

i am using the CLI wfa_workflow_cli - Linux 32bit executable. >> http://community.netapp.com/t5/OnCommand-Storage-Management-Software-Articles-and-Resources/wfa-workflow-cli-run-any-WFA-workflow-any-number-of-times-...

 

 

i was expecting that the script would return the values. please let me know if my understanding was wrong

 

Alternatively,

is there a way i can query and get the lun WWID from WFA to be used for our end to end automation to enable us to mount on teh server too

 

THANK YOU FOR YOUR TIME >> YOUR POST ON THE SCRIPT FOR WWID IS VERY USEFUL AND WAS THE TRIGGER FOR ME TO EXPLORE FURTHER

 

 

 

 

Sebastiaan
5,649 Views

Hi i'm a newbee on WFA so how do i get your script in wfa?

 

Thanks

abhit
5,645 Views

There are many precanned workflows in WFA which can give you the direction.

If you look into the tutorials you will be able to do it.

Best is to contact your account team for NetApp Professional Services help.

They will be able to help you initially.

 

Regards

Abhi

 

Public