Active IQ Unified Manager Discussions

Return parameters for operation results

MPARDINIRTP
11,708 Views

I'm working on a custom command in WFA for polling two controllers for option differences. I have the results in an array, but I'm having a hard time figuring out how to get that output to the workflow user. I see the return parameters tab in the workflow results window and I'm wondering how I can get the results into that tab so the user can see the differences. Any ideas?

24 REPLIES 24

jauling_chou
3,585 Views

Thank you @mbeattie and @sinhaa for your responses. Looks like this is putting me on the right track.

 

In response to @mbeattie:

So I took the PowerShell, then created a WFA command from it:

$snaplist = $vol | Get-NcSnapshot | select Name,Created,Dependency
$snaplist_txt = $snaplist | Out-String
Get-WFALogger -Info -message $("Vserver: " + $VserverName + " Volume: " + $VolumeName + " Snapshots:" + $snaplist_txt)

 

The output when I test the WFA command truncates the snapshot name, which is the same behavior if I run it from CLI:

01:39:02.036 INFO  [get volume snapshot list] ### Command 'get volume snapshot list' in 'POWER_SHELL' ###
01:39:03.177 INFO  [get volume snapshot list] Using cached cluster connection
01:39:04.115 INFO  [get volume snapshot list] Vserver: VSERVER_HOSTNAME Volume: VOL1 Snapshots:
Name                       Created                    Dependency               
----                       -------                    ----------               
snapmirror.8e0fd5c2-e74... 4/4/2017 1:05:20 AM                                 
snapmirror.37f0555f-cb2... 4/4/2017 1:05:22 AM                                 
snapmirror.62cc231c-1c0... 4/4/2017 1:05:24 AM                                 
snapmirror.03af9c87-bde... 4/4/2017 1:06:06 AM        busy                     
01:39:04.161 INFO  [get volume snapshot list] Command completed, took 2125 milliseconds

So I piped the first line of code to Format-Table -AutoSize, but any table formating results in an empty list to WFA for some reason. Also, not really sure how to process a output in table format if I call the WFA workflow via REST (which is my primary use case)

 

 

With regards to @sinhaa:

 

Is there a way to pass XML as the output parameter without exporting/importing via a temporary file? We've only used WFA via REST, so I'm not sure what you mean in the second code snippet where you wrote "Now get the object in the destination command"

 

EDIT:

What I'm ultimately trying to do is to create a workflow that returns a list of snapshots for a given volume in XML form (much like a filter would). Not sure if that's really possible though.

 

Much appreciated guys, thanks!

 

 

Jau

 

sinhaa
3,549 Views

@jauling_chou

 

 

 

We've only used WFA via REST, so I'm not sure what you mean in the second code snippet where you wrote "Now get the object in the destination command"

 

-----

 

Jau,

 

The main purpose of cmdlet Add-WfaWorkflowParameter is to save a dynamically obtained data into a variable and then pass this value to another command to process further. Example: cmd-1 (source) creates a job on ontap and a job-id is returend, now I use Add-WfaWorkflowParameter to save this job-id into a variable 'jobId'. Now another cmd-2(destination) in the same workflow can get this job-ID using Get-WfaWorkflowParameter and then process further. 

 

Add-WfaWorkflowParameter also has parameter -AddAsReturnParameter which when set to true can provide the value of this dynamic data as 'Return Parameter' of the workflow excution.

 

Now this cmdlet has a major limitation that it can only save simple text values. If I have obtained a powershell object, I can't transfer it to the cmd-2. In your example, the snaplist is an object and hence Add-WfaWorkflowParameter can't transfer it to next cmd.

 

 

What I'm ultimately trying to do is to create a workflow that returns a list of snapshots for a given volume in XML form (much like a filter would). Not sure if that's really possible though.

 

----

 

If its powershell  + WFA then everything is possible ( well almost).

 

Once you get this list of snaplist, create your XML like @mbeattie gave in your example. You need to decide which attributes of a given snapshot you want .

 

 

Then do this.

 

 

$xmlDoc = [xml] $lines
$xmlValue = $xmlDoc.OuterXml

Add-WfaWorkflowParameter -Name "Snaplist" -Value $xmlValue -AddAsReturnParameter $True

 

Now when this workflow executes ( via REST as you want) , the workflow execution job will return the XML formatted list of snapshots as Return Parameters.

 

sinhaa

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

jauling_chou
3,506 Views

Thanks so much @sinhaa!

 

I struggled a bit, since the XML that I built with @mbeattie's instructions were imbedded inside the value field in the return parameters when I process the REST output, but once I grabbed that field and then processed it as its own XML doc, then I was able to extract the data I needed. Great stuff guys, thanks so much!

 

MPARDINIRTP
7,296 Views

Thanks for the info. I'll run an upgrade and try it out!

Public