Set the Path Selection Policy for every device path of every host in your vSphere 5.0/5.1 cluster using PowerCLI

I created a new cluster with 4 hosts and forgot to set the default Path Selection Policy (PSP). To fix this I’ll use PowerCLI. In my case I want to use the PSP RoundRobin for all my device paths to disks. Change the PSP according to your preferrence.

First get all device paths that do not use the Round Robin PSP:

Get-Cluster [ClusterName] | Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -ne “RoundRobin”}

which gave me this output:

CanonicalN ConsoleDeviceName LunType CapacityMB MultipathPolicy
ame
———- —————– ——- ———- —————
naa.600… /vmfs/devices/disks/naa.600… disk 768000 Fixed
naa.600… /vmfs/devices/disks/naa.600… disk 768000 Fixed
naa.600… /vmfs/devices/disks/naa.600… disk 768000 Fixed
naa.600… /vmfs/devices/disks/naa.600… disk 768000 Fixed
naa.600… /vmfs/devices/disks/naa.600… disk 768000 Fixed
etc.

After this, just set the PSP for those device paths with the command:

Get-Cluster [ClusterName] | Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “RoundRobin”

Which gave me what I wanted:

CanonicalN ConsoleDeviceName LunType CapacityMB MultipathPolicy
ame
———- —————– ——- ———- —————
naa.600… /vmfs/devices/disks/naa.600… disk 768000 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 768000 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 768000 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 768000 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 768000 RoundRobin
etc.

Now to prevent future misconfigured PSP’s, I want to set the default PSP for my default Storage Array Type to Round Robin. I’ll use the following script to get the available SATP’s of all my hosts (normally, they should be the same on all hosts):

Get-Cluster [ClusterName]| Get-VMHost | ForEach-Object {
$esxcli = Get-EsxCli -VMHost $_
$esxcli.storage.nmp.satp.list()
}

Output (of 1 host):

PowerCLI D:\get_all_satp_available.ps1

DefaultPSP Description Name
———- ———– —-
VMW_PSP_MRU Placeholder (plugin not loaded) VMW_SATP_MSA
VMW_PSP_MRU Placeholder (plugin not loaded) VMW_SATP_ALUA
VMW_PSP_MRU Placeholder (plugin not loaded) VMW_SATP_DEFAULT_AP
VMW_PSP_FIXED Placeholder (plugin not loaded) VMW_SATP_SVC
VMW_PSP_FIXED Placeholder (plugin not loaded) VMW_SATP_EQL
VMW_PSP_FIXED Placeholder (plugin not loaded) VMW_SATP_INV
VMW_PSP_FIXED Placeholder (plugin not loaded) VMW_SATP_EVA
VMW_PSP_RR Placeholder (plugin not loaded) VMW_SATP_ALUA_CX
VMW_PSP_RR Placeholder (plugin not loaded) VMW_SATP_SYMM
VMW_PSP_MRU Placeholder (plugin not loaded) VMW_SATP_CX
VMW_PSP_MRU Placeholder (plugin not loaded) VMW_SATP_LSI
VMW_PSP_RR Supports non-specific active/active … VMW_SATP_DEFAULT_AA
VMW_PSP_FIXED Supports direct attached devices VMW_SATP_LOCAL

VMW_SATP_DEFAULT_AA is what SATP is in use. I’ll use that one to set the default PSP on.

And a list of all available PSP’s:

Get-Cluster [ClusterName]| Get-VMHost | ForEach-Object {
$esxcli = Get-EsxCli -VMHost $_
$esxcli.storage.nmp.psp.list()
}

Output (of 1 host):

PowerCLI D:\get_all_psp_available.ps1

Description Name
———– —-
Most Recently Used Path Selection VMW_PSP_MRU
Round Robin Path Selection VMW_PSP_RR
Fixed Path Selection VMW_PSP_FIXED

PowerCLI D:\>

In my case, I want to make VMW_PSP_RR the default PSP for SATP VMW_SATP_DEFAULT_AA. So I use the script to set it:

Get-Cluster [ClusterName]| Get-VMHost | ForEach-Object {
$esxcli = Get-EsxCli -VMHost $_
$esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_DEFAULT_AA”)
}

And that gives mw what I want. Because there are 4 hosts in my cluster, the output is repeated 4 times:

PowerCLI > D:\set_all_satp_to_psp.ps1
Default PSP for VMW_SATP_DEFAULT_AA is now VMW_PSP_RR
Default PSP for VMW_SATP_DEFAULT_AA is now VMW_PSP_RR
Default PSP for VMW_SATP_DEFAULT_AA is now VMW_PSP_RR
Default PSP for VMW_SATP_DEFAULT_AA is now VMW_PSP_RR
PowerCLI > D:\

Have a good one 🙂

Advertisements

About Yuri de Jager
Technology Addict

4 Responses to Set the Path Selection Policy for every device path of every host in your vSphere 5.0/5.1 cluster using PowerCLI

  1. Tony W says:

    Outstanding! Thanks for this!

  2. David Ralston says:

    Do you know if you can also set the default IOPS using this method?

  3. Pingback: Automating the 3PAR ESXi SATP Rule Creation with PowerCli

  4. vmrulz says:

    We have a cluster that we setup (ESXi 5.5u3) (HP G9 blades via Virtual Connect Flex Fab via FC to EMC ExtremIO array). Ran the one liner script to change 4 LUN’s from Fixed to RR. The script hung after the host CPU’s pegged at 100%. All the guests on the host became unresponsive and I had to pull the rip cord to get HA to failover the guests. I tested the script in pre-prod and it worked fine. Now I’m walking around with sticky egg on my face. I can’t figure out why that simple amount of work would overwhelm a host. Luckily I ran it against one host and not the full cluster or I may have been out looking for work next week.

    get-VMHost -name | Get-VMHostHba -Type “FibreChannel” | Get-ScsiLun -LunType “disk” | where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy RoundRobin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: