Hi,
I want to change the default iops settings for all LUNs, I found it a bit tedious doing it for each LUN; What I want to do is to put all the LUNs WWN name to a file and read the file to apply
esxcli storage nmp psp roundrobin deviceconfig set --type=iops --iops 1 --device=
Get-Content C:\LUNPaths.txt | esxcli I don't know how to do it in esxcli.
Thanks,
You could read the WWN into an array and then use the Contains operator to check if the current device belongs to your list of targets.
Something like this
$wwn = Get-Content -Path C:\WWN.txt
$esxHosts = Get-VMHost -Location $mycluster | Sort Name
foreach($esx in $esxHosts) { $esxcli = Get-EsxCli -VMHost $esx
$esxcli.storage.nmp.device.list() | where {$wwn -contains $_.Device}| %{ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null) } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Get-Content C:\LUNPaths.txt | %{ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_,[long]1,"iops",$null) }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your reply, I have tried the code but it doesn't work.
Thanks,
Are you on vSPhere 5.* ?
The Get-EsxCli commands have changed between 4.* and 5.*
Any error messages btw ?
And what entries do you actually have in the file, canonicalnames/runtime names/... ?
If it are really the WWN of the LUNs, the script will have to convert those WWN to canonicalname.
You can do a
$esxcli.storage.nmp.device.list()
to see what should be passed for the device.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello,
I have the following info in the file; and I'm on version 5.0.0,xxxx
naa.6006048c2dbfafbf370eb3513331ae4a
naa.6006048c8b3ad5764c3a242e8d69901c
naa.6006048cb2c1d57e0317e40d3edff00d
naa.6006048cc71d62f2e4fe28c98afe53b4
naa.6006048cda0003d9750feb982758de
Error:
You cannot call a method on a null-valued expression.
At D:\Scripts\ChangeIOPsTo1.ps1:2 char:3
+
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullYou cannot call a method on a null-valued expression.
At D:\Scripts\ChangeIOPsTo1.ps1:2 char:3
+
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullYou cannot call a method on a null-valued expression.
At D:\Scripts\ChangeIOPsTo1.ps1:2 char:3
+
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullYou cannot call a method on a null-valued expression.
At D:\Scripts\ChangeIOPsTo1.ps1:2 char:3
+
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullYou cannot call a method on a null-valued expression.
At D:\Scripts\ChangeIOPsTo1.ps1:2 char:3
+
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$
...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
It looks as if $esxcli is $null.
Did you do a
$esxcli = Get-EsxCli -VMHost MyEsx
before running the script ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No I don't.
Thanks,
Hi,
Found script it does the job but it loops through the whole WWN by specifying the WWN vendor array number instead of going to a specific set of LUNs to target them and do the required changes.
## Script Variables$VC = Read-Host 'Please Enter VirtualCenter Name'$mycluster = Read-Host 'Please Enter The Cluster Name or DataCenter'$DiskID = "naa.600"### Connect to VirtualCenterConnect-VIServer $VC | Out-Null### Loop Through Cluster or DC to get ESXCLI instances and run commands$esxHosts = Get-VMHost -Location $mycluster | Sort Nameforeach($esx in $esxHosts){### $esxcli.system.hostname.get() ###$esxcli = Get-EsxCli -VMHost $esx$esxcli.storage.nmp.device.list() | where {$_.Device -match $DiskID}| % {$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null) }}#Disconnect from VirtualCenterDisconnect-VIServer $VC -Confirm:$false | Out-NullI think in this script the veritable $DiskID ="naa.600" it could be $DiskID = Get-Content -Path C:\WWN.txt to read through the file and get only those LUNs which they require the changes... will try it tomorrow.
Thanks,
You could read the WWN into an array and then use the Contains operator to check if the current device belongs to your list of targets.
Something like this
$wwn = Get-Content -Path C:\WWN.txt
$esxHosts = Get-VMHost -Location $mycluster | Sort Name
foreach($esx in $esxHosts) { $esxcli = Get-EsxCli -VMHost $esx
$esxcli.storage.nmp.device.list() | where {$wwn -contains $_.Device}| %{ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.Device,1,"iops",$null) } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It works great
PowerCLI D:\Scripts> .\ChangeIOPsTo1.ps1
true
true
true
PowerCLI D:\Scripts>
Highly appreciated.
Not sure if things changed between 5.0 & 5.1 but trying to set a value required 6 arguments for me. I ended up doing something similar to this:
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set(0, $null, $_.Device, 1, "iops",0)
The arguments are Bytes, Config file, Device, IOPS, Type, UseAno
Things changed in 5.1, there is an extra parameter for the config file (2nd parameter).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference