Using the Data ONTAP PowerShell Toolkit to add vSphere Storage

by on ‎2010-06-09 10:28 AM

Here is a little PS I wrote to create a volume, and add it to all VMware vSphere hosts attached to a particular vCenter instance:

Note, this must be run from the vSphere PowerCLI.

##########################################################
# Create-And-Add-Storage-example.ps1
# Jase McCarty 6/7/2010
# Posh Script to add a volume on a NetApp Filer
# and present it to all vSphere hosts
##########################################################

# Add the vSphere PowerCLI SnapIn and the DATA ONTAP Module
Import-module DataONTAP

# Set my variables
$vCenter = vcenter.domain.com
$Filer = filer.domain.com
$aggr = aggr1
$newvol = volx

# Connect to vCenter and our NetApp Filer
Connect-VIServer $vCenter
Connect-NaController $Filer

# Create a new volume
New-NaVol $newvol $aggr 500g

# 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
$Hosts = Get-VMHost
ForEach ($H in $Hosts) {
       New-Datastore -Nfs -VMHost $_.Name -NAME $newvol -Path /vol/$newvol -NfsHost $Filer;
}

This is also detailed here: http://www.jasemccarty.com/blog/?p=831

Comments
Extraordinary Contributor

Thanks for posting, Jase.  This combination of 3rd party toolkits (Data ONTAP and vSphere) is a great example of the tremendous potential we envision with PowerShell.

Thanks for the kudos.

I've been waiting for this toolkit, as it is going to make my job easier, and hopefully many others.

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.