Active IQ Unified Manager Discussions

Return LunId from Map LUN in WFA


Hi all,


I'm writing a WFA to create a new Volume/LUN and map it to existing igroup. User have an option to specify LunID.  I want to be able to verify if the LunID is available on the 'preview' level, to prevent wofklow execution fails if user specify the lunID that is already used.


I copied certified command "Map LUN" to "Map LUN_verify_lunID" to have an option to edit it a little bit.


Everything works fine, if user specify LunID that is already used, WFA returns error, because I have put verification in my command "Map LUN_verify_lunID":


where = lunmap.igroup_id
    AND = '${IgroupName}'
    AND lunmap.lun_map_value = '${LunId}'
    AND lunmap.lun_id =
    AND lun.vserver_id =
    AND = '${VserverName}'


(By the way, is there any option to modify the 'Planning failed' message to something more specific than 'element existance issue detected during validation of command...') ? 🙂



What I'm trying to achieve is to return host LUN id.  I kind of succeeded, by modyfying my powershell code for "Map LUN_verify_lunID" to:




Get-WFALogger -Info -message $("Mapping LUN : " +  $LunName)
if($LunId -ne "")
Add-NcLunMap -Path $LunPath -InitiatorGroup $IgroupName -VserverContext $VserverName -Id $LunId } else { Add-NcLunMap -Path $LunPath -InitiatorGroup $IgroupName -VserverContext $VserverName $Lundetails = Get-NcLunMap -Path $LunPath -VserverContext $VserverName | where-object InitiatorGroup -eq $IgroupName $LunId = $lundetails.LunId } Get-WFALogger -Info -message $("Lun ID : " + $LunId) #'------------------------------------------------------------------------------ #' return LunID to WFA #'------------------------------------------------------------------------------ Add-WfaWorkflowParameter -Name "LunId" -Value $LunId -AddAsReturnParameter $True

I'm assuming the scenario where User does not specify any LunID in the entry parameters.


LunID is successfuly returned after workflow execution. However is it possible to get the LunID during workflow preview ?


Re: Return LunId from Map LUN in WFA




You can use some MVEL wizardy to invoke SQL queries within your command to map the LUN to next available LUN ID

Here is an example of how to create an MVEL function that returns the next LUN ID for a vserver.


function get_next_lun_id(svm_name){
   import java.sql.*;  
   //Connect to local WFA DB using the built-in credentials
   String query= 'select max (lunmap.lun_map_value) + 1 as lunmax from cm_storage.lunmap, cm_storage.igroup, cm_storage.vserver where lunmap.igroup_id = and igroup.vserver_id = and = \'' + svm_name + '\'';
   Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/","wfa","Wfa123");
   Statement stmt=con.createStatement();  
   ResultSet rs=stmt.executeQuery(query);  
   //Query is executed, loop over every row and fetch the columns.
   String s=; 
      s = rs.getString('lunmax');
   return s;

Setting the credentials within the function isn't ideal although it is a read-only user. Thought this might give you some ideas or options.



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

Re: Return LunId from Map LUN in WFA


Thanks Matt! I will try to play with that a little bit 🙂

Re: Return LunId from Map LUN in WFA


Hi tomekp,


Thank you for sharing this!  I am new to WFA.  How would I access this return value in the next function?  I am creating a workflow which will create the datastore with the new LUN and it requires LUN ID.




Re: Return LunId from Map LUN in WFA


Hi Paul,

Apologies for delayed answer 🙂 Assuming You have 'exported' Your lunID with powershell:


Add-WfaWorkflowParameter -Name "LunId" -Value $LunId -AddAsReturnParameter $True

In your next powershell code, you can retrieve this parameter by command:

$YourVariableForLUNid = Get-WfaWorkflowParameter -Name LunId

best regards,


Re: Return LunId from Map LUN in WFA


Thank you!  That works.

2021 NetApp Partner Experience Survey
PES Banner
All Community Forums