Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding function to change multipath policy #207

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
3 changes: 2 additions & 1 deletion Microsoft.AVS.VMFS/Microsoft.AVS.VMFS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
"Get-StorageAdapters",
"Get-VmKernelAdapters",
"Set-NVMeTCP",
"New-NVMeTCPAdapter"
"New-NVMeTCPAdapter",
"Set-PureDatastoreMultipathingPolicy"
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
Expand Down
37 changes: 37 additions & 0 deletions Microsoft.AVS.VMFS/Microsoft.AVS.VMFS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1544,3 +1544,40 @@ function New-NVMeTCPAdapter {
Write-Host ""

}


<#
.DESCRIPTION
Set default Multipath Policy to Round Robin for Pure Datastore.

.PARAMETER PureDatastoreName
Pure Datastore name

.EXAMPLE
Set-PureDatastoreMultipathingPolicy -PureDatastoreName "myPureDatastore"

.INPUTS
vCenter pure datastore name.

.OUTPUTS
None.
#>
function Set-PureDatastoreMultipathingPolicy {
[CmdletBinding()]
[AVSAttribute(10, UpdatesSDDC = $false, AutomationOnly = $true)]
param(
[Parameter(Mandatory=$true)]
[string]$PureDatastoreName
)
try {
$datastore = Get-Datastore -Name $PureDatastoreName -ErrorAction Stop
$policy = Get-ScsiLun -Datastore $datastore | Get-View | Select-Object -First 1 -ExpandProperty MultipathPolicy
$policy.ChangePolicy("VMW_PSP_RR")
Write-Host "Successfully set Multipath Policy to Round Robin for pure datastore $PureDatastoreName."
}
catch {
Write-Error "Failed to set Multipath Policy for pure datastore $PureDatastoreName. Error: $($_.Exception.Message)"
}
}