Cloud Articles and Resources

Using the Data ONTAP PowerShell Toolkit to add vSphere Storage

jasemccarty
views-count 2359 Views

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

Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with 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 (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.

Replies
cknight

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.

jasemccarty

Thanks for the kudos.

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

All Community Forums
Public