-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from PowerShell/dev
Merging release pull request
- Loading branch information
Showing
7 changed files
with
774 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
DSCResources/MSFT_xClusterQuorum/MSFT_xClusterQuorum.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
|
||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([Hashtable])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('Yes')] | ||
[String] $IsSingleInstance, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[ValidateSet('NodeMajority', 'NodeAndDiskMajority', 'NodeAndFileShareMajority', 'DiskOnly')] | ||
[String] $Type, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[String] $Resource | ||
) | ||
|
||
$ClusterQuorum = Get-ClusterQuorum | ||
|
||
switch ($ClusterQuorum.QuorumType) | ||
{ | ||
# WS2016 only | ||
'Majority' { | ||
if ($ClusterQuorum.QuorumResource -eq $null) | ||
{ | ||
$ClusterQuorumType = 'NodeMajority' | ||
} | ||
elseif ($ClusterQuorum.QuorumResource.ResourceType.DisplayName -eq 'Physical Disk') | ||
{ | ||
$ClusterQuorumType = 'NodeAndDiskMajority' | ||
} | ||
elseif ($ClusterQuorum.QuorumResource.ResourceType.DisplayName -eq 'File Share Witness') | ||
{ | ||
$ClusterQuorumType = 'NodeAndFileShareMajority' | ||
} | ||
else | ||
{ | ||
throw "Unknown quorum resource: $($ClusterQuorum.QuorumResource)" | ||
} | ||
} | ||
|
||
# WS2012R2 only | ||
'NodeMajority' { | ||
$ClusterQuorumType = 'NodeMajority' | ||
} | ||
'NodeAndDiskMajority' { | ||
$ClusterQuorumType = 'NodeAndDiskMajority' | ||
} | ||
'NodeAndFileShareMajority' { | ||
$ClusterQuorumType = 'NodeAndFileShareMajority' | ||
} | ||
|
||
# All | ||
'DiskOnly' { | ||
$ClusterQuorumType = 'DiskOnly' | ||
} | ||
|
||
# Default | ||
default { | ||
throw "Unknown quorum type: $($ClusterQuorum.QuorumType)" | ||
} | ||
} | ||
|
||
if ($ClusterQuorumType -eq 'NodeAndFileShareMajority') | ||
{ | ||
$ClusterQuorumResource = $ClusterQuorum.QuorumResource | Get-ClusterParameter -Name SharePath | Select-Object -ExpandProperty Value | ||
} | ||
else | ||
{ | ||
$ClusterQuorumResource = [String] $ClusterQuorum.QuorumResource.Name | ||
} | ||
|
||
@{ | ||
IsSingleInstance = $IsSingleInstance | ||
Type = $ClusterQuorumType | ||
Resource = $ClusterQuorumResource | ||
} | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('Yes')] | ||
[String] $IsSingleInstance, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[ValidateSet('NodeMajority', 'NodeAndDiskMajority', 'NodeAndFileShareMajority', 'DiskOnly')] | ||
[String] $Type, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[String] $Resource | ||
) | ||
|
||
switch ($Type) | ||
{ | ||
'NodeMajority' { | ||
Set-ClusterQuorum -NoWitness | ||
} | ||
|
||
'NodeAndDiskMajority' { | ||
Set-ClusterQuorum -DiskWitness $Resource | ||
} | ||
|
||
'NodeAndFileShareMajority' { | ||
Set-ClusterQuorum -FileShareWitness $Resource | ||
} | ||
|
||
'DiskOnly' { | ||
Set-ClusterQuorum -DiskOnly $Resource | ||
} | ||
} | ||
} | ||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([Boolean])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateSet('Yes')] | ||
[String] $IsSingleInstance, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[ValidateSet('NodeMajority', 'NodeAndDiskMajority', 'NodeAndFileShareMajority', 'DiskOnly')] | ||
[String] $Type, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[String] $Resource | ||
) | ||
|
||
$CurrentQuorum = Get-TargetResource -IsSingleInstance $IsSingleInstance | ||
|
||
return ( | ||
($CurrentQuorum.Type -eq $Type) -and | ||
($CurrentQuorum.Resource -eq $Resource) | ||
) | ||
} | ||
|
||
Export-ModuleMember -Function *-TargetResource |
9 changes: 9 additions & 0 deletions
9
DSCResources/MSFT_xClusterQuorum/MSFT_xClusterQuorum.schema.mof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ClassVersion("1.0.0.0"), FriendlyName("xClusterQuorum")] | ||
class MSFT_xClusterQuorum : OMI_BaseResource | ||
{ | ||
[Key, ValueMap{"Yes"}, Values{"Yes"}] string IsSingleInstance; | ||
|
||
[Write, ValueMap{"NodeMajority", "NodeAndDiskMajority", "NodeAndFileShareMajority", "DiskOnly"}, Values{"NodeMajority", "NodeAndDiskMajority", "NodeAndFileShareMajority", "DiskOnly"}] string Type; | ||
|
||
[Write] String Resource; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.