Subscribe
Accepted Solution

Passing values from one command to another in a workflow

Hi

I want to write a workflow, which has multiple commands.

For one of the commands, I need to get the ID of the snapMirror relationship from the OnCommand server and for this purpose I need to invoke the OnCommand API.

After getting the relationship-id, I need to use this ID to do some other operations in the next command.

My question is how do I pipeline variable values between the various commands in a workflow? I can access the OnCommand database to obtain the information.

Thanks

Dhrumin

Re: Passing values from one command to another in a workflow

Hi Dhrumin,

unfortunately it's not possible to pass information between commands but this functionality has been requested by several people before ;-)

I see two possible workarounds. You can either write information to a file or database in the first command and then read it out again it the second command or you can build one large command instead of several smaller commands. Both solutions are ugly but I'd prefer the second option (and did this in one case already).

Regards

Hendrik

Re: Passing values from one command to another in a workflow

Thanks Hendrik for the reply.

I am kind of using the second option as well, but will need the variable passing moving forward.

I wanted to know how to write the information in the WFA database? Is there a wiki or a document that I can follow somewhere?

Thanks.

Dhrumin

Re: Passing values from one command to another in a workflow

Can I create a temporary schema and write to it as a part of a WFA command, and then delete the schema at the end of the workflow as a part of another command?

Thanks

Dhrumin

Re: Passing values from one command to another in a workflow

I came across another scenario, where I would require variable passing from one command to another.

I modified the Create CM volume command to always choose a unique name for the volume to be created.

So I have a workflow with the following commands

1. Create CM volume - copy with unique volume name

2. Create SM relationship between source and destination volumes

3. Refresh the DFM monitors

4. Find the relationship ID on the DFM

So in the 1st command, I am creating the volume name for the destination volume to be created, in the command itself, by making sure that no other volume exists in the vserver on the same cluster.

Now I need this volumeName of the destination volume, to be used in command 2 and 4, for creating the SM relationship and for finding the relationship ID on the DFM server.

I am not sure how to achieve this functionality in WFA 2.0.

Any thoughts?

Thanks

Dhrumin

Re: Passing values from one command to another in a workflow

Hi,

     Can we do the unique-volume-name creation logic in the workflow itself, not in the command?

This way, we can store this value in a workflow variable.

--

Thanks and Regards,

Bestin Jose.

Re: Passing values from one command to another in a workflow

Hi Bestin,

Yes, definitely.  There are several ways to set volume names in a workflow.  When defining the volume here are some possibilities:

  • Constants -  name: "volume_x"
  • User Inputs - name: $volName  (where the name the Operator uses as user-input will be the volume name)
  • Calculated - name: nextName(find_Volume.name)  - Where a volume name found by the workflow in the environment is passed into a WFA function to produce the next name in sequence

It is also possible to use a combination of these methods.

Hope this helps,

Kevin

Re: Passing values from one command to another in a workflow

Instead of using the database, a simpler alternative may be to use environment variables. You can set it in the first command like so:

[Environment]::SetEnvironmentVariable("foovar", "foovalue", "User")

Or

[Environment]::SetEnvironmentVariable("foovar", "foovalue", "Machine")

Note that you will not be able to use process-level environment variables since every command spawns a new instance of powershell.

In the second command, you can retrieve it using:

[Environment]::GetEnvironmentVariable("foovar","User")

To avoid contamination of future runs, you may also want to clean up the variable in the second command using:

[Environment]::SetEnvironmentVariable("foovar", $null, "User")

Re: Passing values from one command to another in a workflow

While this method may work (As some other methods mentioned in this thread), we see this one as a little risky,
and may be potentially harmful.

At the moment we don't have a "formal" mechanism for passing parameters and info between commands nor we "formally" endorse any of the methods mentioned.

There are thoughts on the matter and we will surely update as soon as we will have something concrete.

Best,

Yaron Haimsohn

WFA team

Re: Passing values from one command to another in a workflow

Hi hiyer,

Your idea is creative. I like the out-of-box thinking. A few things to consider.

If you set permanent environment variables (or registry entries Smiley Wink ) on the WFA server, you run the risk of another workflow overwriting it. Also, there could be issues with cleanup later, especially if workflows don't complete successfully.  Remember that WFA doesn't have automatic rollback or cleanup.

Cheers,

Dave