VMware Cloud Community
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

PowerCLI Script for changing multipath policy to LB-IOPS and set IOPS to 1

Hi,

We are running  large environment. We are in need to set current Storage devices via PowerCLI Script for changing multipath policy to LB-IOPS and set IOPS to 1.

We need to run tihs script for all hosts in specific clusters. 

How can we do that?

Additionaly, our infrastructure is based on Nvme over TCP and Owner seems as HPP.
Path Selection Policy is currently LB-RR and IOPS value is 1000 for all hosts currently.

Labels (3)
Tags (5)
Reply
0 Kudos
1 Solution

Accepted Solutions
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

I submit an SR to vmware SDK team and get a result.

There are many scripts for NMP Storage devices, but not exactly for HPP Storage devices.

So we developed a script with esxcli commands to provide a solution for our needs.
Thank you for your sharing.

Here is the Script we are using for a while.

 

Connect-VIServer -server "vCenter.FQDN"

Get-Cluster

$clusterName=Read-Host "Enter a cluster name to continue "
$cluster=Get-Cluster -Name $clusterName
$hostList=Get-Cluster $cluster | Get-VMHost

foreach($esxi in $hostList){
     $scsiLunList=Get-ScsiLun -VmHost $esxi | ? {$_.CanonicalName -like "eui.*"}
     $esxcli=Get-EsxCli -VMHost $esxi -V2
         
            foreach($scsiLun in $scsiLunList){
                  $args=$esxcli.storage.hpp.device.set.CreateArgs()
                  $args.device=$scsiLun
                  $args.pss="LB-IOPS"
                  $args.iops=1
                  $esxcli.storage.hpp.device.Set.Invoke($args)
            }

}
Disconnect-VIServer

After running complete the script, the next thing to do is go to vCenter and for all hosts in the specified cluster select them Storage > Rescan Storage > Only Select "Scan for new Storage Devices"

Then all NVME disks can be seen with applied Multipath Policy details.

View solution in original post

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Have a look at VMware vSphere NVMe High-Performance Plug-in (HPP)
It also contains the esxcli command to set the PSS for NVMe devices.
You can do this esxcli command through the Get-EsxCli cmdlet.


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

Reply
0 Kudos
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

Thanks for advice, I did figure out some strings for ESXCLi cmdlet. There is a command to set LB-IOPS as Path Selection Policy, and another seperate command to set IOPS to 1, but like setting from GUI, this cmdlet needs to be applied to each host and each path on them repeatedly. There are hundreds of hosts to apply.

So I need to get a powershell or Powercli command set to all hosts connected to vcenter under a specific cluster.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Then you use a loop

$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName |
Get-VMHost -PipelineVariable esx |
Foreach-Object -Process {
   $esxcli = Get-EsxCli -VMHost $esx -V2
   // Do your esxcli command
   // $esxcli....
}


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

Reply
0 Kudos
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

this may be better for running esxcli cmdlet from powershell, but glitch here is that, for each Path, we need to enter unique 4 path device names for each hosts., so this will not work as a script, there would need to modify each loop with path device names.

Below is the commands I mention from esxcli; (we are not allowed to use * for device names here)

To set policy to LB-IOPS;
esxcli storage hpp device set --device=eui.d0eadf8fc5e110a18ccf09680075f099 --pss=LB-IOPS

To set IOPS to 1;
esxcli storage hpp device set -d eui.d0eadf8fc5e110a18ccf09680075f099 -P "LB-IOPS" --iops 1

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure what you are trying to say here.
The Get-EsxCli cmdlet provides a way to execute any esxcli command.

So I don't understand your remark "... so this will not work as a script".
Besides, why post in the PowerCLI community when you don't want to use a script?


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

Reply
0 Kudos
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

I am trying to get Powercli script which doesn't require to connect to each host with ssh.
So I want to use script.

The reason I wrote this "... so this will not work as a script" while there is a need to collect device names "eui.*****" for each path of each host manually, this is not an automated script to use then.

So I am trying to find a way to have a script, works for all hosts in cluster to change policy to LB-IOPS and set iops to set 1 for devices name starts with "eui.*"

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I didn't mention SSH at all.

You don't have to collect the device names manually.
You can use the Get-ScsiLun cmdlet (which is slow) or an esxcli command via the Get-EsxCli cmdlet.


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

Reply
0 Kudos
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

Can you help for writing the whole script?
I couldn't make it work yet.

Tags (1)
Reply
0 Kudos
VMwareGeek_
Enthusiast
Enthusiast
Jump to solution

I submit an SR to vmware SDK team and get a result.

There are many scripts for NMP Storage devices, but not exactly for HPP Storage devices.

So we developed a script with esxcli commands to provide a solution for our needs.
Thank you for your sharing.

Here is the Script we are using for a while.

 

Connect-VIServer -server "vCenter.FQDN"

Get-Cluster

$clusterName=Read-Host "Enter a cluster name to continue "
$cluster=Get-Cluster -Name $clusterName
$hostList=Get-Cluster $cluster | Get-VMHost

foreach($esxi in $hostList){
     $scsiLunList=Get-ScsiLun -VmHost $esxi | ? {$_.CanonicalName -like "eui.*"}
     $esxcli=Get-EsxCli -VMHost $esxi -V2
         
            foreach($scsiLun in $scsiLunList){
                  $args=$esxcli.storage.hpp.device.set.CreateArgs()
                  $args.device=$scsiLun
                  $args.pss="LB-IOPS"
                  $args.iops=1
                  $esxcli.storage.hpp.device.Set.Invoke($args)
            }

}
Disconnect-VIServer

After running complete the script, the next thing to do is go to vCenter and for all hosts in the specified cluster select them Storage > Rescan Storage > Only Select "Scan for new Storage Devices"

Then all NVME disks can be seen with applied Multipath Policy details.

Reply
0 Kudos