Microsoft Virtualization Discussions

Luns under volumes

justin_smith
12,425 Views

Is there a way to script something that will show what LUNS are under which volumes?

I know you can do it with Systems Manager, but I'd like to see something more like a tree hierarchy...

Volume Name

     -Luna

     -Lunb

     -Lunc

Volume Name

     -Luna

     -Lunb

Etc

Make sense?

1 ACCEPTED SOLUTION

vinith
11,557 Views

Hello Justin,

Can you try this out, it might point you to the correct direction..

Just copy and paste the below scriptlet to your powershell window.

function LunName

{

    [CmdletBinding()]

    Param

    (

        # Param1 help description

        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,Position=0)]

        $vol       

    )

$luninfo = Get-NaLun | ?{$_.path -match "/vol/$vol/" } | ForEach-Object {$_.Path.replace("/vol/$vol/","")}

return $luninfo

}

Get-NaVol | select @{l='VolumeName';e={$_.name}},@{l='ContainedLunNames';e={([string]::Join(",",(LunName -vol $_.name)))}}

You can also export to csv as below

Get-NaVol | select @{l='VolumeName';e={$_.name}},@{l='ContainedLunNames';e={([string]::Join(",",(LunName -vol $_.name)))}} | Export-Csv "c:\volluninfo.csv"

View solution in original post

17 REPLIES 17

JGPSHNTAP
11,978 Views

Please do a search for one of my posts.  We wrote something a while ago that should give you what you want

JGPSHNTAP
11,978 Views

Here, I'll save you the trouble - https://communities.netapp.com/thread/23684

justin_smith
11,980 Views

I actually saw that script, but it doesnt seem to output the info I was hoping/looking for....

I would like to see the volume name and then the specific LUNS associated to that volume under it. Preferably exported to XLS or a CSV file.

JGPSHNTAP
11,980 Views

If I get some time, I will try to come up with a little bit of a sample... Not much free time these days.. 

RAVI_PALADUGU
11,978 Views

Hi Justin,

Yes, you can do it, But it can get little tricky, you can use awk script to run against it. Can you please paste the output of qtree status?

Thanks

RK

JGPSHNTAP
11,978 Views

*cough* awk *cough*  🙂

native powershell is the way to go....

RAVI_PALADUGU
11,978 Views

I see what u mean .. but with very little effort it will give the result Justin wanted.

JGPSHNTAP
11,978 Views

I have to be honest.. Not that i'm against it, but onCommand Reporting 1.1 seems to do a really nice job at it.

I love powershell, but heck, I can't compete with Cognos Developers...

justin_smith
11,978 Views

We do a lot of cloning of volumes from Prod to test/QA. The volumes contain a tun (spelled it like that on purpose) of luns that are un-needed when we do the clone, so we go in and delete the un-needed luns.

Long story short, the DBA's ask to refresh a DB, which is usually one or 2 luns and since we clone the whole volume, and each volume has a tun of luns, its kind of a pain to find the volume...

With a script that populates what Volume has which Luns, I could go in and filter the LUN name and bingo bango.... easy.

JGPSHNTAP
11,121 Views

Justin,

Give onCommand Report a shot..

I just went into our environment and created the report with data in it in 5 minutes. 

I'm decent in powershell, but I can't compete with that.

justin_smith
11,121 Views

Are you talking about Ops Manager?

justin_smith
11,121 Views

Installing OnCommand Report now... waiting for a eval license from my sales guy....

JGPSHNTAP
11,121 Views

How did you make out?

vinith
11,558 Views

Hello Justin,

Can you try this out, it might point you to the correct direction..

Just copy and paste the below scriptlet to your powershell window.

function LunName

{

    [CmdletBinding()]

    Param

    (

        # Param1 help description

        [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,Position=0)]

        $vol       

    )

$luninfo = Get-NaLun | ?{$_.path -match "/vol/$vol/" } | ForEach-Object {$_.Path.replace("/vol/$vol/","")}

return $luninfo

}

Get-NaVol | select @{l='VolumeName';e={$_.name}},@{l='ContainedLunNames';e={([string]::Join(",",(LunName -vol $_.name)))}}

You can also export to csv as below

Get-NaVol | select @{l='VolumeName';e={$_.name}},@{l='ContainedLunNames';e={([string]::Join(",",(LunName -vol $_.name)))}} | Export-Csv "c:\volluninfo.csv"

RAVI_PALADUGU
11,121 Views

Hi Vinith,

That is pretty neat, but it takes very longtime (50min) to generate output. I have like 34 volumes with 7 luns each,

Thanks

Ravi

JGPSHNTAP
9,818 Views

Ravi - Which script, mine or his?

RAVI_PALADUGU
9,818 Views

JGP,

Yours ran like a horse (2minutes), but Vivin's gives a different kind of output than yours. Vivin's is more for what Justin is looking for I guess.

Thanks

Ravi

Public