Active IQ Unified Manager Discussions

Delete Volume after all LUNs are unmapped

rogerhinson
4,123 Views

Hi all,

 

I'm try to create a workflow that deletes LUNs, as specified, and then deletes the volume only if there are no additional LUNs mapped in the volume.  I'm using WFA 2.2 and Clustered Mode

 

Example would be:

 

Volume:  volume1

 

LUNs in Volume:  lun1, lun2, lun3

 

lun1 mapped to host1

lun2 mapped to host2

lun3 mapped to host1 and host2

 

If the user wants to delete lun1, they would enter the lun_path to delete.  The workflow checks in lun1 is mapped and fails if mapped.  It deletes the lun if no mapping exists.  I have that part working.

 

If the user unmapped lun1 and ran the delete workflow, I only want that LUN deleted, but not the volume because other luns and mapped and in use.

 

If the user unmapped all luns and ran the delete workflow, I want to delete the LUNs and then delete the volume.

 

This the query I use to find the igroup mapping for a particular LUN, but can't figure out how to modify to find any mapped luns in a volume.

 

SELECT
    lun.full_path as 'lun.full_path',
    igroup.name as 'name',
    vserver.name as 'vserver.name',
    cluster.name as 'vserver.cluster.primary_address'
FROM
    cm_storage.igroup igroup,
    cm_storage.vserver vserver,
    cm_storage.lunmap lunmap,
    cm_storage.lun lun,
    cm_storage.cluster cluster
WHERE
    lunmap.lun_id = lun.id
    AND lunmap.igroup_id = igroup.id
    AND vserver.name = '${vserver_name}'
    AND lun.full_path = '${lun_path}'
    AND igroup.protocol = 'iscsi'
    AND cluster.name = '${cluster_name}'
ORDER BY
    igroup.name

 

Thanks,

Roger

 

 

 

1 ACCEPTED SOLUTION

trentino123
4,060 Views
Hi Roger,
Only the LUN_ID is mapped to an IGROUP ID.
But the cm_storage.lun database also has the VOLUME_ID ( besides the LUN_ID, QTREE_ID,VSERVER_ID and FULL_PATH ).
In order to find VOLUMES with MAPPED LUNs I would try to modify the following :
SELECT
volume.name,
lun.id,
lunmap.lun_id,
lun.volume_id,
lun.vserver_id,
lun.full_path
FROM
cm_storage.volume,
cm_storage.lunmap,
cm_storage.lun
WHERE
volume.id = lun.volume_id AND
lunmap.lun_id = lun.id
Hope it helps.
Thanks,

Trentin123.

 

View solution in original post

3 REPLIES 3

trentino123
4,061 Views
Hi Roger,
Only the LUN_ID is mapped to an IGROUP ID.
But the cm_storage.lun database also has the VOLUME_ID ( besides the LUN_ID, QTREE_ID,VSERVER_ID and FULL_PATH ).
In order to find VOLUMES with MAPPED LUNs I would try to modify the following :
SELECT
volume.name,
lun.id,
lunmap.lun_id,
lun.volume_id,
lun.vserver_id,
lun.full_path
FROM
cm_storage.volume,
cm_storage.lunmap,
cm_storage.lun
WHERE
volume.id = lun.volume_id AND
lunmap.lun_id = lun.id
Hope it helps.
Thanks,

Trentin123.

 

rogerhinson
4,034 Views

Thanks very much.  This worked for me.

trentino123
4,006 Views

Glad to know it helped, thanks Roger!

Public