Using PowerCLI to manage multipath polices for SCSI devices

I was recently looking into multi path policies for all hosts in my clusters to firstly ensure that they were configured as expected. Firstly, I wanted to check if there were any SCSI devices that were not configured with the multipath policy of Round Robin using the Get-SCSILun cmdlet.

Get-Cluster | Get-VMHost | Get-ScsiLun -LunType Disk | Where-Object {$_.MultiPathPolicy -ne "RoundRobin"} 

I noticed that the above returned any SCSI Devices which were local storage on the host, therefore I was further required to filter the above command to not include any SCSI devices where the IsLocal property is equal to True

Get-Cluster | Get-VMHost | Get-ScsiLun -LunType Disk | Where-Object {$_.IsLocal -ne "True" -and $_.MultiPathPolicy -ne "RoundRobin"} 

This then returned any devices which were not configured with a PSP of Robin Robin.  For these devices, which were required to be modified we can run the above and pass the output to the Set-SCSILun cmdlet to configure the multipath policy  to be Round Robin.

Get-Cluster | Get-VMHost | Get-ScsiLun -LunType Disk | Where-Object {$_.IsLocal -ne "True"-and $_.MultiPathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin

So, what if there was different storage arrays in the cluster which required different multipath policy to be configured, how would you retrieve those settings?

Well the Get-SCSILun cmdlet retrieves the vendor and model of the device so we could use this to only set the multipath policy for those devices, in the next example I will only use the model to further filter the devices retrieved.

Get-Cluster | Get-VMHost | Get-ScsiLun -LunTypeDisk | Where-Object {$_.Model -eq "<Model Name>" -and $_.IsLocal -ne "True" -and $_.MultiPathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin

Depending on the storage array and the vendors recommendation you may want to specify the maximum number of I/O requests to be issued on a given path before the system tries to select a different path, this can be performed by setting the CommandsToSwitchPath property as below:

Get-Cluster | Get-VMHost | Get-ScsiLun- LunType Disk | Where-Object {$_.IsLocal -ne "True" -and $_.MultiPathPolicy -eq "RoundRobin"} | Set-ScsiLun -CommandsToSwitchPath 10
Advertisements

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