VMware Cloud Community
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Need to create a claim rule and modify IOPS=1 for all hosts in a cluster

Hi all,

Not sure if this is much easier or harder than I am making this appear. I have an urgent requirement to modify the claim rules and the IOPs settings for all hosts in a cluster. The commands are simple enough and can be run by puttying into each host, but to get this done faster I would like to script it. Here are the two commands:

 

esxcli storage nmp satp rule add -s "VMW_SATP_ALUA" -V "NETAPP" -M "LUN C-Mode" -P "VMW_PSP_RR" -O "iops=1" -e "NetApp ONTAP SATP Rule"
for i in `esxcfg-scsidevs -c | awk '{print $1}' | grep -E "naa.6008|naa.600a" `; do esxcli storage nmp psp roundrobin deviceconfig set --type=iops --iops=1 --device=$i; done

 

 

I have never done anything like this, but I believe this is similar to a command we use to change host passwords regularly:

Could I do something like this?

$vmhosts = Get-Datacenter -Name MYCLUSTER | Get-VMHost

Foreach ($vmhost in $vmhosts) {
$esxcli = get-esxcli -vmhost $vmhost -v2

### Insert my the above commands here?? ###
}

You can see where I'm not sure how to proceed, I not sure how to actually execute the two commands. Can anyone help point me in the right direction?

 

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Based on your script, that could be something like this

Get-Datacenter -Name MYCLUSTER | Get-VMHost -PipelineVariable esx |
Foreach-Object -Process {
  $esxcli = Get-Esxcli -VMHost $esx -V2

  $rule = @{
    vendor = 'NETAPP'
    model = 'LUN C-Mode'
    satp = 'VMW_SATP_ALUA'
    psp = 'VMW_PSP_RR'
    description = 'NetApp ONTAP SATP Rule'
    option = 'iops=1'
  }
  $esxcli.storage.nmp.satp.rule.add.Invoke($rule)

  $esxcli.storage.core.device.list.invoke() |
  Where-Object { $_.Device -match '^naa.6008|^naa.600a' } |
  Foreach-Object -Process {
    $set = @{
      device = $_.device
      type = 'iops'
      iops = [long]1
    }
    $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set.Invoke($set)
  }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

8 Replies
LucD
Leadership
Leadership
Jump to solution

The object returned by Get-EsxCli has a CreateArgs() method, that show you which arguments to pass in the hash table.

$esxcli.storage.nmp.satp.rule.add.CreateArgs()


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

LucD
Leadership
Leadership
Jump to solution

Based on your script, that could be something like this

Get-Datacenter -Name MYCLUSTER | Get-VMHost -PipelineVariable esx |
Foreach-Object -Process {
  $esxcli = Get-Esxcli -VMHost $esx -V2

  $rule = @{
    vendor = 'NETAPP'
    model = 'LUN C-Mode'
    satp = 'VMW_SATP_ALUA'
    psp = 'VMW_PSP_RR'
    description = 'NetApp ONTAP SATP Rule'
    option = 'iops=1'
  }
  $esxcli.storage.nmp.satp.rule.add.Invoke($rule)

  $esxcli.storage.core.device.list.invoke() |
  Where-Object { $_.Device -match '^naa.6008|^naa.600a' } |
  Foreach-Object -Process {
    $set = @{
      device = $_.device
      type = 'iops'
      iops = [long]1
    }
    $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set.Invoke($set)
  }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

dbutch1976
Hot Shot
Hot Shot
Jump to solution

Literally can't thank you enough LucD!

0 Kudos
einhirn
Contributor
Contributor
Jump to solution

Hi LucD,
I recently used this code to apply the 'iops=1' option to some storage here and ran into problems - I found a

WARNING: VMW_SATP_DEFAULT_AA: satp_default_aa_setDeviceConfig:396: Invalid config parameter: iops=1

in the log files and needed to apply a correction to the rule: 'iops=1' needs to go into 'pspoption' instead of 'option'...

Just want to leave this for anyone that googles this thread. Thanks!

LucD
Leadership
Leadership
Jump to solution

Thanks for the info.
For which vSphere version did you notice that?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
einhirn
Contributor
Contributor
Jump to solution

We're on

VMware ESXi 6.7, Patch Release ESXi670-202201001
Build: 19195723
 
but I'm not sure if this issue only appears in the current patch release. The "system"-Claim Rules also put the "iops=1" into pspoptions, you can check with
 
$c=get-esxcli -V2 -VMHost HOSTNAME
$c.storage.nmp.satp.rule.list.Invoke() |ft

Just look for "iops=X"-Parameters and in which column they're defined.

0 Kudos
dbutch1976
Hot Shot
Hot Shot
Jump to solution

Hi LucD.

Is there an easy way of displaying the settings being updated in the script? I need to confirm that these settings were updated for a particular host that's having issues.

Thanks.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The following should list all devices with the setting

$esxcli.storage.nmp.device.list.Invoke()


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference