VMware Cloud Community
ajkbond
Contributor
Contributor

Powercli command to find and change RDM LUNS IOPS to 200 from default 1000

I have a power cli script which will change the default IOPS from 1000 to 1 

$AllHosts = Get-Cluster "ClusterA" | Get-VMHost | where {($_.ConnectionState -like "Connected")}

foreach ($esxhost in $AllHosts) {Get-VMHost $esxhost | Get-ScsiLun -LunType disk | Where-Object {$_.Multipathpolicy -like "RoundRobin"} | Set-ScsiLun -CommandsToSwitchPath 1 | Select-Object CanonicalName, MultipathPolicy, CommandsToSwitchPath}

 

what i am looking for is a command to set default IOPS from 1000 to 200 for RDM Luns both physical & virtual.

Get-Datastore | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select "Filename","CapacityKB" | fl

 

i can run 1st command change all and then set RDm alone to 200 if i can get a script for changing RDM luns to 200. if not i need to manually run the below command on each esxi host against all RDm luns

 

for i in `esxcli storage nmp device list | grep naa.xxxxxxxxxxxxxxxxxxxxxxx` ; do esxcli storage nmp psp roundrobin deviceconfig set -t iops -I 200 -d $i; done

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

You can use the Get-EsxCli cmdlet, and then run that esxcli command from there.
That way you can run the esxcli command against each ESXi node


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

Reply
0 Kudos
ajkbond
Contributor
Contributor

Thanks LucD

i have around 200 + RDM so is there a way i can modify the comand to call naa.xxx from a file

something like naa.txt ? 

for i in `esxcli storage nmp device list | grep @naa.txt` ; do esxcli storage nmp psp roundrobin deviceconfig set -t iops -I 200 -d $i; done

Reply
0 Kudos
LucD
Leadership
Leadership

You could do something like this

$naa = Get-Content -Path .\naa.txt
$config = @{
    type = 'iops'
    iops = 200
    device = ''
}

Get-Cluster "ClusterA" | Get-VMHost -PipelineVariable esx | 
where {($_.ConnectionState -like "Connected")} |
ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.storage.nmp.device.list.Invoke() |
    where{$naa -contains $_.Device} |
    ForEach-Object -Process {
        $config.device = $_.Device
        $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set.Invoke($config)
    }
}


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

Reply
0 Kudos
ajkbond
Contributor
Contributor

Thank you so much LucD

Reply
0 Kudos