Active IQ Unified Manager Discussions

Can a WFA function access a WFA dictionary?

korns
4,569 Views

I'm find use-cases where I'd like to write a function that can access data in dictionaries. Is this possible?

7 REPLIES 7

sinhaa
4,569 Views

Functions in WFA are in MVEL and can't connect to the WFA Database to obtain Data. But your commands can. You would need the following:

1. mysql .NET connector. Download and install it . http://dev.mysql.com/downloads/file.php?id=450594

2. Download the attached Powershell script module and save it in lets' say C:\mysql

3. Append the following line in <install_dur>/WFA/PoSH/profile.ps1 file .Not mandatory but just saves you from typing the below line every time in your command.

     Import-Module C:\mysql\GetMySqlData.psm1

Now you can use this command to get any WFA dictionary Data like below

Get-MySqlData -Query "Select name from cm_storage.cluster"

Note: WFA in near future does plan to provide in built features for this and similar requirements.

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

abhit
4,569 Views

Hi Korns:

Can you give an example? Would like to understand the use case.

What I can think of is, you should be able to create an object reference

and access the particular dicitionary entry.

Function can then be applied on top of that.

Another good example to refer to for the previous reply is:

https://communities.netapp.com/docs/DOC-30478

Regards

Abhi

korns
4,569 Views

That is a fair question and I should have provided the problem I was trying to solve at the time I asked it. I can't remember what I was trying to solve when I asked the original question but today I have a  feature I'd like to address in the next version of a workflow that I'm unsure which path to follow (function, object.reference, userInput-query, etc). Here is how I would describe this use-case and problem:

BACKGROUND: I have a workflow that uses Incremental Volume naming. After working to get the SQL for search criteria just right this seems to be working correctly and as advertised. But it has raised two further questions which are related and if I could solve one I should be able to solve the other. Those questions are (note: I'm calling arrays filers in the below, sorry :-):

- Q1: I'd like to be able to present to the user what the new volume name will be in some way on the User Inputs form before the workflow is previewed/executed, or before the planning phase. It is not trivially obvious how to do that ... or if it can be done. The best answer I can give right now is to "preview the workflow once" and it'll show what volume name is going to be computed and used. ANY HINTS HOW TO ACHIEVE THIS?

- Q2: But this is the real requirement: we need another aspect of the User Input form to behave in a particular way based on what the newly created and incrementally named volume's name is going to be. Real example: a convention which we'd like the workflow to enforce is that if the volume name ends in an even number the volume should be placed on a filer that ends in an even number, and vis-versus: if volume ends in odd number it should be placed on a filer ending with an odd number. Today the workflow presents the complete list of eligible filers. They want the user to manually select the filer, but they'd like the list of eligible filers to only contain even-ending, or odd-ending filer names based on the volume that is about to be created. This is a general load balancing scheme.

I could try and upload the workflow related to this problem but it is complex and needs a specific dictionary, data source, and some specially named OCUM resGroups to even begin to work. So it would be easier to use a sample simple workflow to test the simpler 'incremental naming' problem and/or a hint to address Q1 or Q2 above. Maybe just a Create Volume with incremental naming and a filer/array User Input selection via a query based on the about to be created volume name (in anyway, just to demonstrate concept).

abhit
4,569 Views

Thanks for the detailed explanation.

Q1: Preview the workflow once is the best way to achieve to this.

Q2: We tried to build a sample workflow to show the same using a Playground DB.

It will give an idea how to do the same. The trick lies in the dependent user input's SQL query.

In the example,

If the vol name ends with 1,3 then in the dependent user input will show Vol1,Vol3.

If the vol name ends with 0,2 then in the dependent user input will show Vol,Vol2.

Let us know if this helps.

Having problems attaching the backup.

So copy pasting the queries here: UserInput1:

SELECT

    namevalue.Name as 'Name'

FROM

    Playground.namevalue

UserInput 2:

SELECT

    namevalue.name,

    CAST(SUBSTRING(namevalue.name,

    4) AS UNSIGNED) AS id

FROM

    playground.namevalue

WHERE

    CAST(SUBSTRING(namevalue.name,4) AS UNSIGNED) % 2 = (

        SELECT

            DISTINCT CAST(SUBSTRING(namevalue.name,

            4) AS UNSIGNED) % 2

        FROM

            playground.namevalue

        WHERE

            namevalue.name = '${Name}'

    )

User Input 2 is dependent on User Input 1.

A table "namevalue" is created in the Playground DB,

with one column "Name", having entries, Vol0,Vol1,Vol2,Vol3.

Regards

Abhi

abhit
4,569 Views

Attaching the backup.

-Abhi

korns
4,569 Views

Thanks Abhi, I'll dig into this and see if I can use this concept solve our requirement.

korns
4,569 Views

Abhi, I read the SQL code I think I get the idea. However, to test it I get stuck at the part about creating the 'namevalue' table in playground database. I know what the playground database is. I use a SQL tool called DBVisualizer (from dbvis.com) and when I connect to my WFA server I see the playground database with no tables (normal). But I don't see how to add a table. Since I'm using the standard wfa/wfa123 credentials don't I just have a read-only view of things? Do I need to connect with different cred's to have write access?

NOTE: I'm opening another discussion which seems entirely different but is a question I came up with trying to solve the problem another way. I realized that I could have another userinput field that is a QUERY type field that looks up and determines what the current highest volume name is, like: 'volume78' and returns that. I can hide this userInput field form the user in a un-expanded group of userInputs. This gives me a hint to know that the next one which "WFA Incremental naming" will create is going to be 'volume79' and using MOD-2 functions I can determine even/odd'ness of the next volume name. I think this is a simplier apprach that playground DB (for now) but it raised another SQL focused question ... look for separate thread on that topic

Public