Subscribe
Accepted Solution

Find volumes with less than 3 LUNs in it...

Hey guys,

In a pretty standard flow for creating VMFS datastore (with volume, lun....) there's a request from a customer that I'm struggling to get my head on and appreciate any thought:

- convention for LUNs in a volume is 3 LUNs in a volume.

- let's say naming convention is na_w2k8_X and current X is vol number 1

- if there are 3 LUNs already in that vol 1, then create a new volume numbered 2 with the same convention.

- if there are less than 3 in the first volume of that convention, then resize that volume and create the 3rd LUN in it.

Now, how do I do that search for that convention to search for number of LUNs in it to know if I should create a LUN in an existing volume matching the convention or create a new one.

of course, if there are 5 volume, vols 1-4 might be full, 5 might be with only 1 or 2... then i'll put new lun in 5.

thanks in advance!

Soli.

Re: Find volumes with less than 3 LUNs in it...

Ah, one of the secret caveats and the holy grail of WFA :-)

So here's one of the best kept and least known secrets of WFA:

You can actually extend SPECIFIC objects based on information returned in the filter.

Let me explain:

Let's say you use finder F1 with the basic filter "Find Volume by key" to fill up variable Vol1 => Vol1 will have regular volume fields

Let's assume a new filter "Volume with lun count" that looks like this:

SELECT volume.name, array.ip AS 'array.ip', count(lun.id) AS lun_count

FROM storage.volume

JOIN storage.array ON volume.array_id = array.id

LEFT JOIN storage.lun ON lun.volume_id = volume.id

GROUP BY volume.id

  HAVING lun_count < ${max_luns}

That query is simple one, running on ALL the volumes in the cache, listing them,

and counting for each the numbers of luns each holds (Here under a certain maximum).

Note that the list is not bound by anything else.

Now lets create finder F2 with 2 filters:

1) Volume by key

2) Volume by lun count

The first filter returns a single result and the second a whole list.

Combined they would return a single volume object BUT with a twist:

An additional field holding the number of luns inside.

So if that variable is called Vol2 you can (and will) reference Vol2.lun_count

and have the current number of luns in it.

Do note that only variables filled by this new finder F2 will have that extra half-hidden field!!

Hope that was clear enough and gave you an idea how to proceed.

Best,

Yaron Haimsohn

OnCloud Team

Re: Find volumes with less than 3 LUNs in it...

Haimsohn,

As always - a pleasure!!

Thanks.

Soli.