Getting data from NetApp Workflow Automation using Finders and REST

Using the database to get information from Workflow Automation (WFA) and create dynamic vCenter Orchestrator (vCO) workflows is one way to add dynamic data fields to those workflows. However, it just feels dirty. It’s a “backdoor” if you will, and just not very scalable or supportable. Imagine if the WFA database schema changes…you will be responsible for changing all of the SQL queries in the vCO workflows, which make break in non-obvious ways.

A much more robust method is to abstract those queries (and keep them in WFA) then use REST to retrieve the data. WFA provides two mechanisms, filters and finders, for selecting and returning data from the database internally. We can access these through the REST interface, which we can then parse from XML into a more vCO friendly format.

What is a filter?

A filter is simply a SQL select statement that has been validated to return certain fields (the natural keys at a minimum).

What is a finder?

A finder is one or more filters.

Putting them to work

Both of these constructs use SQL to query the WFA cache database (which is periodically updated from the data sources such as OnCommand Unified Manager), however a finder does not have SQL directly in it, only the filter does.

Previously we have been working with a WFA workflow called “Create a Clustered Data ONTAP Volume”. Recall that this workflow has four inputs:

  • Cluster Name – A string with valid values being clustered Data ONTAP systems configured in WFA
  • Storage Virtual Machine Name – A string with valid values being SVMs belonging to the cluster selected above.
  • Volume Name – A string provided by the user.
  • Volume Size (in GB) – A number provided by the user.

Two of those inputs, when viewed in WFA are query types.

wfa_filter_finder_1

If we look at those inputs (by double clicking them from the WFA designer interface) we can view the SQL code that is being executed in order to return data for that input.

wfa_filter_finder_2

Let’s copy that SQL out because we will need it in just a moment. If you are following along, close the existing windows (the SQL input, the variable editor, and the workflow setup editor), then close out of the workflow.

Creating a new filter

You should now be at the main Designer tab. On the left, select the “Filters” option. We want to create a new filter, so click the page with a green plus on it near the top.

wfa_filter_finder_3

Give our new filter a name. Since we are going to be using this to ultimately surface information to vCO, I like to include that in the name…I have used “vCO – Get All Clusters” for the name. Dictionary type is where we select what type of data we are returning by selecting the cache database table. Since we are querying clusters, select “Cluster” in the “cm_storage” schema. Optionally, enter a description for the new filter.

wfa_filter_finder_4

Switch to the Query tab at the top of the input window, then paste the SQL code from the workflow in.

wfa_filter_finder_5

To validate the query click the Test button in the lower left. Keep the check for “Use reservation data in test”, then click the Test button again. When we click the button you should get an error saying that we are not returning all of the natural keys for the dictionary (cm_storage.cluster in our case). Click the Ok button to dismiss the error, then close the test window.

wfa_filter_finder_6

If you read the error carefully and look at our SQL query you will notice that we aren’t actually selecting the data, we are just renaming the primary_address field to “Primary Address”. So, let’s remove that renaming operation. Our SQL should look like this now:

Execute the test again and we should now get valid results:

wfa_filter_finder_7

Close the test window and click the Save button. We’re done with the filter.

Creating a finder from the filter

Change to the Finders view (on the left of the Designer tab) in the WFA interface. We are creating a new Finder, so click the page with a green plus on it.

wfa_filter_finder_8

In the new Finder window, fill in values for the name, type, and optionally description. The “Input Parameters” section will be filled automatically for us when we select finders.

wfa_filter_finder_9

Select the “Filters” tab at the top of the New Finder window. Since we selected “Cluster (cm_storage)” as the type on the first tab we will only see filters that also use that type. Highlight the filter we just created (“vCO – Get All Clusters”) on the left, then click the arrow to move it to the right side.

wfa_filter_finder_10

Finally, switch to the “Returned Attributes” tab and make sure that all of the available attributes (on the left) have been moved to the right (“Selected”).

wfa_filter_finder_11

Click the Save button and we’re done.

Getting the result via REST

Now that we have created the necessary objects in WFA, we can use REST to get the output of the finder. Navigate your browser to the REST documentation url for your host, for example: http://your_wfa_host/rest/docs. Once there, click on the FinderResource link to get a description of the REST operations we can execute against Finders:

wfa_filter_finder_12

We are interested in two operations here:

  1. /finders – This returns a list of all finders, which we will use to find our finder’s UUID.
  2. /finders/{finder_uuid}/test – This executes the finder with reservations and returns the data.

Let’s browse to the /finders URL to get a list of all finders on the system. Once there, use the browser’s find function to locate your finder:

wfa_filter_finder_13

Notice at the bottom we have links provided for testing. Copy that URL and paste it into the address bar to go there. The result will be an XML response that contains the data returned by the SQL query:

wfa_filter_finder_14

Conclusion

Now that we have the first filter/finder defined, and know how to query them via REST, we simply have to take the other SQL queries that we want to use and follow the same procedure. In the next post we will use vCenter Orchestrator actions to execute the REST operation, parse it, and populate data selectors in workflows.

If you want to know more about WFA/vCO integration, if you have questions and/or suggestions about the WFA package for vCO, or if you encounter a bug in the package, please let me know via the comments section here, the NetApp Communities page, or using the NetApp Communities private message function (my username is asulliva). I will also happily respond to emails…my email address is the same as my Communities username at netapp.com.

Questions and comments are always welcome below. If you have any suggestions for, or need help with, NetApp/VMware integration, automation, and solutions, please let me know using the comments!

Leave a Reply

cf7e6140e09b88f3c8afd6390d5afb7b666666666666666666