Quantcast
Channel: StarWind Software
Viewing all articles
Browse latest Browse all 785

StarWind Virtual SAN (VSAN) [+Free], HCI Appliance (HCA), Virtual HCI Appliance (VHCA) [+Free] • Setting MPIO to Failover for Witness else LQD via PowerShell

$
0
0
Hi All,

Posting here as I hope it helps.

I have been faffing with powershell to get from ISCSI Target IQN to Disk.
A bit more coding and I can pull Disk Serial.
A bit more coding and I can match Disk Serial to mpclaim Disk Number.
Now with a bit of extra code its possible programatically
  • to set ISCSI Targets with "witness" in their ISCSI IQN to MPIO Policy Failover
  • to set ISCSI Targets without to MPIO Policy Least Queue Depth
Boris Yurchenko asked if anyone solves this to let him know. If staff at Starwind could pass on to Boris for review that would be great! I'd happily accept a special 3x node license thank you for all the saved Starwind Staff finger and RSI clicking pain (re: Don’t break your fingers with hundreds of clicks)

Code:

# Convert to Hash: MPIO Disk Info $disks_MPIO = (gwmi -Namespace root\wmi -Class mpio_disk_info).driveinfo | Group-Object SerialNumber -AsHashTable -AsString$disks_starwind = Get-PhysicalDisk | Where FriendlyName -like "*Starwind*" |  Select-Object Friendlyname, UniqueID, @{Name='MPIO Name'; Expression={ ($disks_MPIO[$_.UniqueID]).Name }} | Format-Table -AutoSize$disks_Serial_vs_ISCSI = Get-IscsiConnection | Select -Property InitiatorAddress,TargetAddress,@{Name='Session'; Expression={($_|Get-IscsiSession).TargetNodeAddress}},@{Name='DiskSerial'; Expression={($_|Get-Disk).SerialNumber}} | Group-Object -Property DiskSerial # Output For Review Write-Output ($disks_Serial_vs_ISCSI | Select -ExpandProperty Group )$disks_Serial_vs_MPIO = @()foreach($currDisk in $disks_Serial_vs_ISCSI){        $countIsWitness = 0    foreach($currISCSI_Target in $currDisk.Group){                If($currISCSI_Target.Session -like "*witness*"){            ++$countIsWitness         }     }    $disks_Serial_vs_MPIO += [pscustomobject]@{        DiskSerial     = $currDisk.Name         MPIO_Required  = If($countIsWitness -gt 0){"FOO"}Else{"LQD"}                MPIO_DiskNb    = ($disks_MPIO[$currDisk.Name]).Name.Replace("MPIO Disk","")        ISCSI_IQN      = $currISCSI_Target.Session     }}# For Review Write-Output $disks_Serial_vs_MPIO# Before Changes & mpclaim -s -dforeach($currDisk in $disks_Serial_vs_MPIO){    $ArgumentList = ""    If($currDisk.MPIO_Required -eq "FOO"){        $ArgumentList = "-l -d " + $currDisk.MPIO_DiskNb + " 1”    } Else {        $ArgumentList = "-l -d " + $currDisk.MPIO_DiskNb + " 4”            #mpclaim /?            #0 = Clear the Policy            #1 = Fail-Over Only            #2 = Round Robin            #3 = Round Robin with Subset            #4 = Least Queue Depth            #5 = Weighted Paths            #6 = Least Blocks            #7 = Vendor-Specific    }    Write-Output ("To set MPIO Load Balance Policy")    Write-Output ("`t  TO: " + $currDisk.MPIO_Required)    Write-Output ("`t FOR: " + $currDisk.ISCSI_IQN)    Write-Output ("`t RUN: " + "mpclaim $ArgumentList")    #start-process “c:\windows\system32\mpclaim.exe” -ArgumentList $ArgumentList -Wait    }# After Changes & mpclaim -s -d

Statistics: Posted by GiveitAGo — Wed Jul 10, 2024 7:28 pm



Viewing all articles
Browse latest Browse all 785

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>