Custom SATP Claim Rule-Script for ESXi Host’s connecting to HPE 3PAR

Disclaimer:- The script below is from the Vmware community folks which is tweaked a little to suit my purpose, Also please test before running in production. Reboot is required to claim the LUN’s. 

FYI:- In certain cases,  if the LUN is not RR already, running directly the Rule/script and rebooting the Host is not claiming the LUN’s and so the RR will be checked and persistantly applied within the script.

Script:- 

$vmhosts = Get-cluster "Cluster-Name" | get-vmhost
foreach( $ESXHost in $vmhosts) {
Get-VMHost $ESXHost | Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun -LunType "disk" | where{$_.MultipathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin
$esxcli = Get-ESXcli -vmhost $ESXHost

try {
$esxcli.storage.nmp.satp.rule.add($null,"tpgs_on",
"HPE 3PAR custom SATP Claimrule", $null, $null, $null, "VV",
$null,"VMW_PSP_RR","iops=1", "VMW_SATP_ALUA", $null,
$null,"3PARdata")
Write-output "SATP List Succesfully added to ESXi Host $ESXHost`n"
}
catch {
write-host "SATP Rule Failed on Host $ESXHost" -ForegroundColor Red
if (($esxcli.storage.nmp.satp.rule.list() |
where-Object { $_.description -like "*3PAR*" }).count -ge 1) {
write-host "SATP Rule for 3Par already exists on $ESXHost" -ForegroundColor Magenta
}
}
}

One-Liners:- 

  • esxcli storage nmp satp rule add -s "VMW_SATP_ALUA" -P "VMW_PSP_RR" -O iops=1 -c "tpgs_on" -V "3PARdata" -M "VV" -e "HPE 3PAR custom SATP Claimrule"
  • esxcli storage nmp satp rule list | grep HPE
  • esxcli storage nmp satp rule remove -s "VMW_SATP_ALUA" -P "VMW_PSP_RR" -O iops=1 -c "tpgs_on" -V "3PARdata" -M "VV" -e "HPE 3PAR custom SATP Claimrule"
  • esxcli storage nmp device list | grep iops  #List the No  of lines with Iops Value seen in storage adapters, the output should show iops=1 for the LUN's that applied with the claim rule