Working with NetApp using PowerShell

NetApp, among many things, manufactures Storage Area Networks or SAN. A SAN is a critical piece of any large enterprise, particularly when you are working with clusters. SAN's provide (among many things) the ability to share disks between servers. With Server 2008 and Hyper-V, a 16 Node cluster is absolutely a possibility. In the world of Netapp, you have an aggregate, which consists of volumes, and volumes consist of LUN's.  LUNS are the things that show up as disk in Disk Management when you connect to Netapp.

There is a new project up on CodePlex called PowerShell OnTap which is a set of PowerShell scripts that can be used to manage a NetApp storage device. Once you dot source the two scripts, you will have access to a bunch of functions that have a noun of NA. There is even a function called get-nahelp which walks you through some basic commands to get you up and running.

Once you create your NetApp Server Object, you can run the Get-NaSystemAPIs command to see all stuff you can party with.

Here, I filtered it down to just the commands I can do with LUN's

153 >  Get-NaSystemAPIs -server  $server | ?{$_.Name -like "lun*"} | select Name

Name
----
lun-clone-split-start
lun-clone-split-status-list-info
lun-clone-split-stop
lun-clone-start
lun-clone-status-list-info
lun-clone-stop
lun-config-check-cfmode-info
lun-config-check-info
lun-config-check-single-image-info
lun-create-by-size
lun-create-clone
lun-create-from-file
lun-create-from-snapshot
lun-create-vld-metadir-entry
lun-delete-vld-metadir-entry
lun-destroy
lun-get-attribute
lun-get-comment
lun-get-geometry
lun-get-inquiry-info
lun-get-maxsize
lun-get-minsize
lun-get-occupied-size
lun-get-select-attribute
lun-get-serial-number
lun-get-space-reservation-info
lun-has-scsi-reservations
lun-initiator-list-map-info
lun-initiator-logged-in
lun-list-info
lun-map
lun-map-list-info
lun-move
lun-offline
lun-online
lun-port-has-scsi-reservations
lun-read-raw
lun-reset-stats
lun-resize
lun-restore-status
lun-set-attribute
lun-set-comment
lun-set-select-attribute
lun-set-serial-number
lun-set-share
lun-set-space-reservation-info
lun-snap-usage-list-info
lun-stats-list-info
lun-unmap
lun-unset-attribute
lun-write-raw


154 >

 

All kinds of goodness !!

 

Here are a few more functions I came up

 

function Get-NtapVolume
{
    param ( [string]$filer, 
            [System.Management.Automation.PSCredential]$credential
            ) 
    
    $server = New-NaServer -server $filer -credentials $credential
    $request = New-NaRequest -name "volume-list-info"
    $result = Get-NaResult -server   $server -request  $request
    $sizeUsed = @{Name="SizeUsed";Expression =  {[int64]($_."size-used"/1GB)}}
    $sizeAvailable = @{Name="SizeAvailable"; Expression = {[int64]($_."size-available"/1GB)}}
    $percentageUsed = @{Name = "PercentageUsed";Expression = {[int64]$_."percentage-used"}}
    $volumes = $result.volumes."volume-info" | select name,$sizeUsed,$sizeAvailable,$percentageUsed
    
    return $volumes

}

function Get-NtapLun {
    param ( [string]$filer, [System.Management.Automation.PSCredential]$credential) 
    
    $server = New-NaServer -server $filer -credentials $credential
    $request = New-NaRequest -name "lun-list-info"
    $result = Get-NaResult -server   $server -request  $request
    $size = @{Name="Size";Expression =  {[int64]($_."size"/1GB)}}
    $luns = $result.luns."lun-info" | select path,$size,online,mapped
    
    return $luns
    
}


function New-NtapLun {
    
    param (    [string]$filer, 
            [System.Management.Automation.PSCredential]$credential, 
            [string]$path, 
            [int]$size
            )
            
            $server = New-NaServer -server $filer -credentials $credential
            $request = New-NaRequest -name "lun-create-by-size"
            $request.Parameters += New-NaRequestParameter -name "path" -value $fullPath
            $request.Parameters += New-NaRequestParameter -name "size" -value $size
            $result = Get-NaResult -server   $server -request  $request
            $returnObject = "" | select Name,Size
            $returnObject.Name = $path
            $returnObject.Size = $result."actual-size"
            return $returnObject

}

Comments (1) -

I really liked the way they came off

Comments are closed