Subscribe
Accepted Solution

How to select vFiler which meets certain criteria

In my Workflow, the first command is "Create Volume". I need to select a vFiler which has lowest number of Volumes in a particular Filer (toaster1).

The vFiler name should start with toasterv and options ldap.enable should be "off" for that vFiler.

I could get this ($vfilername) from powershell script but wondering how do I fit it in the parameters for "Create Volume" command ?

Get-Item 'C:\Program Files\NetApp\WFA\PoSH\Modules\*' | Import-Module
Connect-NaController toaster1

$vfilerlist = get-navfiler | sort-object vfstorecount | Select-String toasterv*
$numberofvfilers = $vfilerlist.count

for ($i=0; $i -lt $numberofvfilers; $i++)
{
$vfilername = $vfilerlist[$i]
connect-nacontroller toaster1 -vfiler $vfilername

if ((Get-NaOption ldap.enable).value -eq "off")
{
#Do nothing
break
}
}

My workflow working fine with $vFilerName as user input but I need the WFA to select vFiler with above criteria.

Any help would be much appreciated.

Re: How to select vFiler which meets certain criteria

You could write your own filter with the appropriate SQL query to select that vFiler. The only problem I see is that vFiler options does get cached in the database, so you could not make LDAP status part of the query.

This is the syntax you should use when creating the new Filter, and reference that filter in a new Finder that you can use in the "No-op Storage" into the vFiler tab

select

    array.ip as "array.ip",

    vfiler.name

from

    storage.vfiler

LEFT JOIN

    storage.volume

        ON vfiler.id = storage.volume.vfiler_id

LEFT JOIN

    storage.array

        ON volume.array_id = array.id

WHERE

    array.name="${filerName}"

    AND vfiler.name like 'toasterv%'

GROUP BY

    vfiler.id

ORDER BY

    COUNT(volume.name) LIMIT 1;

Re: How to select vFiler which meets certain criteria

Hi,

As Yann mentioned, we dont have "ldap.enable" option cached for vfiler objects. So, criteria based on that is not possible currently.

Regarding the filter for volume count, I thought I will share another similar way to what Yann mentioned above.

Here, volume count criteria is considered only in the design of a specific workflow and not in the filter.

Filter query for vFiler: (Only difference: volume_count returned in the filter and there is no ORDER BY clause)

---------------------

SELECT

    array.ip as "array.ip",

    vfiler.name,

    COUNT(volume.name) AS volume_count

FROM

    storage.vfiler,

    storage.array

LEFT JOIN

    storage.volume

        ON vfiler.id = storage.volume.vfiler_id

WHERE

    (array.name='${array_name_or_ip}' OR array.ip = '${array_name_or_ip}')

    AND volume.array_id = array.id

    AND vfiler.name like 'toasterv%'

GROUP BY

    vfiler.id

In Create Volume command:

-------------------------

- When selecting the vfiler for the volume, use the above filter in the resource selector and in advanced tab use volume_count as the criteria for deciding between vfilers from the same array where the vfiler with the minimum volume count is picked.

Screenshot of Resource Selector for vFiler in "Create volume" command:

Screenshot of Advanced tab where volume_count is the deciding factor for choosing among the vFilers from the filer.

Hope this helps.

Thanks,

Shailaja

Re: How to select vFiler which meets certain criteria

Thanks Yann and Shailaja !

This was a great help.