Configuring HP EVA Recommended Settings for ESXi via PowerCLI

The HP Enterprise Virtual Array Family with VMware vSphere 4.0 , 4.1 AND 5.0 Configuration Best Practises Guide, available here, contains many recommendations for ESXi configuration. There are a number of recommended settings in this document to enhance the storage performance, a subset of which I have picked as appropriate for the environment and then needed to configure them on all ESXi hosts.

They can be implemented via PowerCLI and the below script demonstrates how these different types of settings can be configured. The most interesting one for me was setting the default Path Selection Policy to VMW_PSP_RR. The guide recommends you use the following command from the ESXi console:

esxcli nmp satp setdefaultpsp -satp VMW_SATP_ALUA -psp VMW_PSP_RR

With the introduction of the Get-ESXCLI cmdlet we can now carry out the equivalent from PowerCLI. Get-EsxCLI requires a direct connection to the ESXi host rather than from vCenter, so all the settings in this script are configured via a direct connection to the ESXi host

Warning: Before carrying out any of these types of changes make sure you talk to your Storage Adminstrator to confirm what is appropriate for your own environment. Other array vendors offer different recommendations so be sure to check their documentation for similar settings.

<# .SYNOPSIS Implement HP Recommended Settings for EVA SAN

.DESCRIPTION Implement HP Recommended Settings for EVA SAN

.PARAMETER  HostName Name of the ESXi host to configure the settings on

.EXAMPLE PS C:\\> ./Set-HPEVAESXiConfig.ps1 -Hostname ESX01

.EXAMPLE PS C:\\> Get-Content ESXServers.txt | ./Set-HPEVAESXiConfig.ps1

.NOTES Author: Jonathan Medd Date: 21/12/2011 #>

\[CmdletBinding()\] param( \[Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the ESXi host to configure the settings on", ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)\] \[Alias('IPAddress','Server','ComputerName')\] \[System.String\] $HostName )

begin {

Write-Host "Please enter credentials to connect to the ESXi hosts" -ForegroundColor:Yellow $Credential = Get-Credential $UserName = $Credential.GetNetworkCredential().UserName $Password = $Credential.GetNetworkCredential().Password }

process {

Connect-VIServer $Hostname -User $Username -Password $Password | Out-Null

Write-Host "Setting Disk.DiskMaxIOSize Advanced Option" Set-VMHostAdvancedConfiguration -VMHost $Hostname -Name Disk.DiskMaxIOSize -Value 128 | Out-Null

Write-Host "Changing any LUNs with MultipathPolicy set to MostRecentlyUsed to be RoundRobin instead" Get-ScsiLun -VmHost $Hostname -LunType "disk" | Where-Object {$\_.MultipathPolicy –eq "MostRecentlyUsed"} | Set-ScsiLun -MultipathPolicy "RoundRobin" | Out-Null

Write-Host "Setting the default PSP to be VMW\_PSP\_RR" $esxCli = Get-EsxCli –Server $Hostname $esxCli.nmp.satp.setdefaultpsp("VMW\_PSP\_RR", "VMW\_SATP\_ALUA")

Write-Host "Disconnecting from Host" $DefaultVIServer | Disconnect-VIServer -Confirm:$false } ```