<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Return LunId from Map LUN in WFA in Active IQ Unified Manager Discussions</title>
    <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/139215#M25374</link>
    <description>&lt;P&gt;Thank you!&amp;nbsp; That works.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Mar 2018 19:50:23 GMT</pubDate>
    <dc:creator>Paul_Yu</dc:creator>
    <dc:date>2018-03-28T19:50:23Z</dc:date>
    <item>
      <title>Return LunId from Map LUN in WFA</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138732#M25244</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm writing a WFA to create a new Volume/LUN and map it to existing igroup. User have an option to specify LunID.&amp;nbsp; 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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I copied certified command "Map LUN" to "Map LUN_verify_lunID" to have an option to edit it a little bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Select
    lunmap.lun_id,
    lunmap.lun_map_value,
    lun.name
from
    cm_storage.lunmap,
    cm_storage.igroup,
    cm_storage.lun,
    cm_storage.vserver
where
    igroup.id = lunmap.igroup_id
    AND igroup.name = '${IgroupName}'
    AND lunmap.lun_map_value = '${LunId}'
    AND lunmap.lun_id = lun.id
    AND lun.vserver_id = vserver.id
    AND vserver.name = '${VserverName}'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(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...') ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm trying to achieve is to &lt;STRONG&gt;return&lt;/STRONG&gt; host LUN id.&amp;nbsp; I kind of succeeded, by modyfying my powershell code for "Map LUN_verify_lunID" to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[...]

Get-WFALogger -Info -message $("Mapping LUN : " +  $LunName)
if($LunId -ne "")
{&lt;BR /&gt;
	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&lt;/PRE&gt;
&lt;P&gt;I'm assuming the scenario where User does not specify any LunID in the entry parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LunID is successfuly returned after &lt;STRONG&gt;workflow execution&lt;/STRONG&gt;. However is it possible to get the LunID during &lt;STRONG&gt;workflow preview &lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 13:56:46 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138732#M25244</guid>
      <dc:creator>tomekp</dc:creator>
      <dc:date>2025-06-04T13:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Return LunId from Map LUN in WFA</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138766#M25249</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use some MVEL wizardy to invoke SQL queries within your command to map the LUN to next available LUN ID&lt;/P&gt;
&lt;P&gt;Here is an example of how to create an MVEL function that returns the next LUN ID for a vserver.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;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 = igroup.id and igroup.vserver_id = vserver.id and vserver.name = \'' + 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=; 
   while(rs.next()){
      s = rs.getString('lunmax');
   }
   return s;
}&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Sun, 11 Mar 2018 23:55:56 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138766#M25249</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2018-03-11T23:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Return LunId from Map LUN in WFA</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138777#M25253</link>
      <description>&lt;P&gt;Thanks Matt! I will try to play with that a little bit &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 11:26:13 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138777#M25253</guid>
      <dc:creator>tomekp</dc:creator>
      <dc:date>2018-03-12T11:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Return LunId from Map LUN in WFA</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138897#M25294</link>
      <description>&lt;P&gt;Hi tomekp,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing this!&amp;nbsp; I am new to WFA.&amp;nbsp; How would I access this return value in the next function?&amp;nbsp; I am creating a workflow which will create the datastore with the new LUN and it requires LUN ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Paul&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 19:51:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/138897#M25294</guid>
      <dc:creator>Paul_Yu</dc:creator>
      <dc:date>2018-03-15T19:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Return LunId from Map LUN in WFA</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/139126#M25351</link>
      <description>&lt;P&gt;Hi Paul, &lt;BR /&gt;&lt;BR /&gt;Apologies for delayed answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Assuming You have 'exported' Your lunID with powershell:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Add-WfaWorkflowParameter -Name "LunId" -Value $LunId -AddAsReturnParameter $True&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;In your next powershell code, you can retrieve this parameter by command:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;$YourVariableForLUNid = Get-WfaWorkflowParameter -Name LunId
&lt;/PRE&gt;
&lt;P&gt;best regards,&lt;/P&gt;
&lt;P&gt;tomek&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 08:44:12 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/139126#M25351</guid>
      <dc:creator>tomekp</dc:creator>
      <dc:date>2018-03-26T08:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Return LunId from Map LUN in WFA</title>
      <link>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/139215#M25374</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; That works.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 19:50:23 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Active-IQ-Unified-Manager-Discussions/Return-LunId-from-Map-LUN-in-WFA/m-p/139215#M25374</guid>
      <dc:creator>Paul_Yu</dc:creator>
      <dc:date>2018-03-28T19:50:23Z</dc:date>
    </item>
  </channel>
</rss>

