NetApp has released a fantastic PowerShell kit to automate operations with their filers.
To get started, download the DataOntap.zip and install.ps1 from the NetApp NOW site, and place them in c:\temp\ on a Windows box with PowerShell ( I am using 2008 R2 with PowerShell Version 2 )
Start PowerShell, and type the following:
cd c:\temp\
./install.ps1
after that, start PowerShell again and type
to make sure you see DataONTAP installed.
Now you can type
To access the DataONTAP cmdlets in your session. You will need to do this each time you start PowerShell, or you can add the above command to your PowerShell profile to automatically load them.
To see help and examples, you can use the following command:
For detailed help on a cmdlet, use get-help as you normally would with PowerShell:
There are MANY great cmdlets available to automate common NetApp administration tasks.
A great example is a script mixing both NetApp and VMware PowerShell automation by Jase McCarty here which automatically provisions and mounts storage on all ESX hosts.
I modified Jase’s script slightly to work with PowerShell 2.0 and to use root access instead of AD credentials. This script must be ran from VMware PowerCLI to work:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # Add the DATA ONTAP Module Import-module DataONTAP # Set my variables. Change for your site ########################## $vCenter = "192.168.15.70" $Filer = "192.168.15.3" $aggr = "aggrx" $newvol = "volx" $narootpasswd = "netapprootpasshere" ######################### #Connect to NetApp as root $password = ConvertTo-SecureString $narootpasswd -AsPlainText -Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "root",$password Connect-NaController $Filer -Credential $cred # Create a new 6GB volume New-NaVol $newvol $aggr 6g # Set some options for the new volume Set-NaVolOption $newvol no_atime_update yes Set-NaVolOption $newvol fractional_reserve 0 # Set the SnapShot Reserve to 0 Set-NaSnapshotreserve $newvol 0 Set-NaSnapshotschedule $newvol -Weeks 0 -Days 0 -Hours 0 # Add an NFS export Add-NaNfsExport /vol/$newvol -Persistent -ReadWrite all-hosts -NoSuid -SecurityFlavors sys,krb5 # Get all the vSphere Hosts and add the NFS export. This requires VMware PowerCLI # Connect to vCenter Connect-VIServer $vCenter $Hosts = Get-VMHost ForEach ($h in $Hosts) { New-Datastore -Nfs -VMHost $h.Name -NAME $newvol -Path /vol/$newvol -NfsHost $Filer; } |
