this project has been depreciated, please get the official toolkit availiable:http://communities.netapp.com/community/interfaces_and_tools/data_ontap_powershell_toolkit

PoshOnTap

PoshOnTap brings Manage OnTap to PowerShell in the form of a PowerShell Module containing over 220 Cmdlets. This project aims to bridge the management gap, and bring the power and flexibility of PowerShell to the storage administrator.

Installation

  • You must have PowerShell V2 installed in order to use this module.
  • Download PoshOnTap and run the PoshOnTap.msi, or download the PoshOnTap.zip for xcopy deploy.
  • Run Import-Module PoshOnTap from within powershell.

Quick Hints

  • To get a list of cmdlet in the module type: Get-Command -module PoshOnTap
  • Once your ready to look around connect to destination NetApp Filer with the Connect-NaServer cmdlet.
Connect-NaServer -Server NetApp3
The above command will attempt to connect via RPC to NetApp3 using the credssp credentials of the current Shell. You can also connect via HTTP, and HTTPS. vFiler tunneling is also supported, although that functionality hasn't been fully tested.
  • Help, Every cmdlet has Full V2 Comment based help.
  • ShouldProcess, For those of you who don't know ShouldProcess enables the administrator to explore what may happen if they were to execute a command. PoshOnTap takes ShouldProcess to a step further. When you add -whatif or -Confirm to any supported cmdlet you will get a meaningful message. For instance if you wanted to delete all snapshots on a volume named vol1, you could preview the outcome by adding whatif.
PS> Get-NaVol Vol1 | Get-NaSnapshot | Remove-NaSnapshot -Whatif
What if: Performing operation "Deleting snapshot test6 from vol0" on Target "netapp1".
What if: Performing operation "Deleting snapshot test5 from vol0" on Target "netapp1".
What if: Performing operation "Deleting snapshot test4 from vol0" on Target "netapp1".
What if: Performing operation "Deleting snapshot test3 from vol0" on Target "netapp1".

As you can see we didn't simply echo that we where deleting a snapshot. Instead we tell you what snapshot we would have deleted on what filer... a meaningful message. While this proved to be difficult at times we couldn't be happier with the outcome.
  • Has-a binding! Every cmdlet in the project makes some use of the PowerShell pipeline, and 99% of that binding is done by property name. We did this for one simple reason, we know you're not going to live in our little sandbox. By property name binding enables you to glue our functionality into anything!

What's missing

Currently we haven't implemented any cmdlets to handle:
  • NFS
  • CIFS
  • SnapVault
  • FCP
  • User/Role Management
Alas hope is not lost, the NaServer object returned by New-NaServer can be used to execute raw ZAPI calls. AKA roll your own!
$Server = New-NaServer NetApp3 -NoSSL -Credentials (Get-Credentials root)
$Server.invoke("you-api-goes-here")

We hope to close in on these glaring holes, but in the meantime see http://get-admin.com/blog/?tag=ontap-sdk for more information on PowerShell and the OnTap API.

Examples

real basic present an ISCSI Lun from scratch.
Connect-NaServer Netapp1 -NoSSL
# create a new aggragate 
New-NaAggr aggr1 -DiskCount 10
# create a new Volume in our aggregate
New-NaVol vol1 -Aggregate aggr1 -size 1gb
# Create a new Lun in our new volume
New-NaLun /vol/vol1/lun1 -Size 500mb
# Create a new IGroup to map our lun
New-NaIGroup igrp0 -Type iscsi -OSType windows
# Add initiators to our IGroup
Get-NaIGroup igrp0 | Add-NaInitiator iqn.1991-05.com.microsoft:GetAdmin
# Map our Lun
Add-NaLunMap /vol/vol1/lun1 -IGroup igrp0 -LunID 0

Add a new RaidGroup to Aggr0 with 10 disks
PS> Get-NaAggr aggr1 | Add-NaDisk -DiskCount 10 -GroupSelectionMode new
Name         Status     Avalable   Used      Total Disks RaidType RaidSize      Files   MaxFiles Root
----             ------      --------     ----        -----   -----  --------     --------        -----   -------     ----
aggr1         online       2.3 GB    30%       3.3 GB  20  raid_...      16               107    31.14 k

Configure SnapMirror
# Connect to Snapmirror Source and Destination
$SrcFiler = New-NaServer NetApp1 -NoSSL
$DestFiler = new-NaServer NetApp2 -NoSSL
# License Snapmirror
Add-NaLicense DFVXFJJ -server $DestFiler
Add-NaLicense DFVXFJJ -server $SrcFiler
# Authorize Netapp2 to mirror NetApp1
Set-NaOption -Name snapmirror.access  -Value host=netapp2 -Server $SrcFiler
# Create our destination volume
Get-NaVol vol1 | New-NaVol -server $DestFiler | Set-NaSnapshotReserve -Percentage 0 -server $DestFiler
Set-NaVol vol1 -Restrict -server $DestFiler
# Enable snapmirror
Enable-NaSnapMirror -Server $SrcFiler
Enable-NaSnapMirror -Server $DestFiler
# Create Snapmirror relationship
Set-NaSnapMirrorSchedule -Source netapp1:vol1 -Destination netapp2:vol1 -Schedule "- - - -" -server $DestFiler
# Initialize Snapmirror
Get-NaSnapMirrorSchedule -server $DestFiler|Initialize-NaSnapMirror -server $DestFiler

Configure A-SIS across the board.
Get-NaVol | Set-NaSIS -Schedule auto | Enable-NaSIS | Start-NaSIS

NFS
# Get Any exports off vol1
Get-Navol vol1 | Get-NaExportfs

# Export /vol/vol2/old as /vol/vol2 granting 192.168.1.25 root access, and readonly access to 192.168.1.26, and 192.1681.27.
New-NaExportfs -Pathname /vol/vol2 -ActualPathname /vol/vol2/old `
    -Root 192.168.1.25 -ReadOnly 192.168.1.26,192.168.1.27 -Persistent

# Overwrite the root exports for /vol/vol1 allowing any host on the 192.168.1.0 subnet except 192.168.1.25.
Set-NaExportfs -Pathname  /vol/vol1 -Root -192.1681.25,192.168.1.0/24

# Permanently remove any /vol/vol2 exports.
Remove-NaExportfs -Pathname /vol/vol2 -Persistent

# Return $True if 192.168.1.5 has root permission on /vol/vol1
Test-NaExportFS -Pathname /vol/vol1 -Permission root -IPAddress 192.168.1.5	

Last edited Oct 23, 2010 at 6:05 PM by glnsize, version 31