For anyone that’s ever been through the process of provisioning a new datastore to multiple ESX hosts, you know it can take some time. Below are the steps I use
- Create Volume on NetApp
- Set Security Style to Unix
- Enable Storage Efficiency
- Set NFS Export permissions to allow Read/Write + Root Permissions to all applicable hosts
- Mount datastores on ESXi hosts
For a handful of hosts this is fine, but adding it to anything more than 4-5 hosts is reaaally painful in my experience. Below is a script you can use to take care of these steps in one swipe.
The script requires an array of the NFS clients (read ESXi hosts) you want to connect the datastore to.
Example 1 – assign the array to a variable, and manually add it to a parameter
$ESXHosts = @("10.1.1.100","10.1.1.101","10.1.1.102") Add-VolumeAndAddToESXi.ps1 -VolName Volume100 -VolSize 1.5T -filerIP 10.1.1.10 -aggrName aggr0 -ExportedHosts $ESXHosts -vCenter vcenter-site1
Example 2 – Create an array, and pipe it to the script
@("10.1.1.100","10.1.1.101") | Add-VolumeAndAddToESXi.ps1 -VolName Volume101 -VolSize 200G -filerIP 10.1.1.10 -aggrName aggr1 -vCenter vcenter-site1
Enjoy! Let me know if you have any challenges or questions
<# .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.49 Created on: 4/17/2014 10:39 PM Created by: Jon Howe (www.cit3.net) Filename: Add-VolumeAndAddToESXi.ps1 =========================================================================== .DESCRIPTION Create Volume and add to all hosts in a vCenter server .PARAMETER VolName The Name of the Volume you want to create .PARAMETER VolSize The size of the newly created volume. Example: 10G, 1T, 100M .PARAMETER filerIP The IP Address of the filer .PARAMETER aggrName The aggregate that will contain the volume .PARAMETER ExportedHosts An array that contains IP Addresses of the ESXi hosts you want to provide NFS Export permissiosn to .PARAMETER vCenter The DNS or IP Address of the vCenter Server you want to provision the datastore to .LINK