Made the following script yesterday to run on all our ESXi hosts to apply HPE recommended settings for 3Par.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#!/bin/sh # Set VMWare recommended path settings for our datastores # https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-3286ENW.pdf # Note: this only targets devices of identifier naa.6000xxxx. Modify this later if required. for i in `esxcli storage nmp device list | grep '^naa.6000'` ; do echo "Setting RR for $i" esxcli storage nmp device set --device $i --psp VMW_PSP_RR; echo "Setting IOPS=1 for $i" esxcli storage nmp psp roundrobin deviceconfig set --type=iops --iops=1 --device $i; echo "Setting queue size for $i" esxcli storage core device set --device $i --queue-full-threshold 4 --queue-full-sample-size 32; echo "" done echo "Setting as default for future" 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 Rule" |
No original contribution from my side here. It’s just something I put together from stuff found elsewhere.
I wanted to run this as a cron job on ESXi periodically but apparently that’s not straightforward. (Wanted to run it as a cron job because I am not sure the queue settings too can be set as a default for new datastores). ESXi doesn’t keep cron jobs over reboots so you to modify some other script to inject a new crontab each time the host reboots. I was too lazy to do that.
Another plan was to try and run this via PowerCLI as I had to do this in a whole bunch of hosts. I was too lazy to do that either and PowerCLI seems a kludgy way to run esxcli
commands. Finally I resorted to plink (SSH was already enabled on all the hosts) to run this en-masse:
1 |
Get-Content .\esxlist.txt | %{ $entry = $_ -split ": " ; $esxhost = $entry[0]; $pass = $entry[1]; "Processing $esxhost"; .\plink.exe -pw $pass root@$esxhost /vmfs/volumes/path/to/fixPSP.sh } |
This feels like cheating, I know. This requires SSH to be enabled on all hosts. This assumes I have put the script in some common datastore accessible across all hosts. I am using PowerShell purely to loop and read the contents of a text file consisting of “hostname: password” entries. And I am using plink
to connect to each host and run the script. (I love plink
for this kind of stuff. It’s super cool!) It feels like a hotch-potch of so many different things and not very elegant but lazy. (Something like this would be elegant. Using PowerCLI properly; not just as a wrapper to run esxcli commands. But I couldn’t figure out the equivalent commands for my case. I was using FC rather the SCSI).