Skip to content

Commit

Permalink
Merge pull request #24 from PowerShell/dev
Browse files Browse the repository at this point in the history
Merging release pull request
  • Loading branch information
kwirkykat authored Aug 10, 2016
2 parents 84348e5 + f806a51 commit d8426a7
Show file tree
Hide file tree
Showing 7 changed files with 774 additions and 38 deletions.
8 changes: 5 additions & 3 deletions DSCResources/MSFT_xCluster/MSFT_xCluster.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Get-TargetResource
throw "Can't find the cluster $Name"
}

$address = Get-ClusterGroup -Cluster $Name | Get-ClusterResource -Name 'Cluster IP Address' | Get-ClusterParameter 'Address'
$address = Get-ClusterGroup -Cluster $Name -Name "Cluster IP Address" | Get-ClusterParameter "Address"
}
finally
{
Expand Down Expand Up @@ -106,6 +106,8 @@ function Set-TargetResource

New-Cluster -Name $Name -Node $env:COMPUTERNAME -StaticAddress $StaticIPAddress -NoStorage -Force

While (!(Get-Cluster)){Start-Sleep 5}

Write-Verbose -Message "Created Cluster $Name"
}
else
Expand All @@ -119,7 +121,7 @@ function Set-TargetResource
{
if ($node.Name -eq $env:COMPUTERNAME)
{
if ($node.State -eq 'Down')
if ($node.State -eq "Down")
{
Write-Verbose -Message "node $env:COMPUTERNAME was down, need remove it from the list."

Expand Down Expand Up @@ -203,7 +205,7 @@ function Test-TargetResource
{
if ($node.Name -eq $env:COMPUTERNAME)
{
if ($node.State -eq 'Up')
if ($node.State -eq "Up")
{
$bRet = $true
}
Expand Down
145 changes: 145 additions & 0 deletions DSCResources/MSFT_xClusterQuorum/MSFT_xClusterQuorum.psm1
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
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;
};
33 changes: 8 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

The **xFailOverCluster** DSC modules contains **xCluster** and **xWaitForCluster** resources for creating and configuring failover clusters.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## Contributing
Please check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md).

Expand All @@ -22,28 +19,18 @@ Please check out common DSC Resources [contributing guidelines](https://github.c
* **StaticIPAddress**: Static IP Address of the cluster
* **DomainAdministratorCredential**: Credential used to create the cluster

### xClusterNetwork (Unreleased)
### xClusterQuorum (Unreleased)

* **Address**: The network address (e.g. 192.168.0.0)
* **AddressMask**: The network mask (e.g. 255.255.255.0)
* **Name**: The network label or name
* **Role**: Network role: *0 = None, 1 = Cluster Only, 3 = Clsuter and Client*
* **Metric**: The internal metric for the networks
* **IsSingleInstance** Always set to `Yes` to prevent multiple quorum settings per cluster.
* **Type** Quorum type to use: *NodeMajority*, *NodeAndDiskMajority*, *NodeAndFileShareMajority*, *DiskOnly*
* **Resource** The name of the disk or file share resource to use as witness. Is optional with *NodeMajority* type.

### xClusterDisk (Unreleased)

* **Number**: Number of the cluster disk
* **Ensure**: Define if the cluster disk should be added (Present) or removed (Absent)
* **Label**: The disk label inside the Failover Cluster

### xClusterPreferredOwner (Unreleased)
For more information about cluster preferred owners please see: http://support.microsoft.com/kb/299631
* **ClusterGroup**: Cluster group name
* **ClusterName**: Cluster name
* **Nodes**: Selected cluster nodes.
* **ClusterResources**: Selected cluster resources
* **Ensure**: Whether an owner should be present or removed

### xWaitForCluster

* **Name**: Name of the cluster to wait for
Expand All @@ -54,20 +41,16 @@ For more information about cluster preferred owners please see: http://support.m
## Versions

### Unreleased

### 1.4.0.0
* xClusterDisk: Fixed Test-TargetResource logic

### 1.3.0.0
### 1.5.0.0

* Added xClusterNetwork resource
* Added xClusterQuorum resource with options *NodeMajority*, *NodeAndDiskMajority*, *NodeAndFileShareMajority*, *DiskOnly*
* Currently does not implement cloudwitness for Windows 2016.
* Added xClusterDisk resource
* Added xClusterPreferredOwner resource
* Resolved issue: Failing Get-TargetResource in xCluster

### 1.2.0.0

* xCluster: Added -NoStorage switch to add-clusternode. This prevents disks from being automatically added when joining a node to a cluster
* xCluster: Added -NoStorage switch to add-clusterNode. This prevents disks from being automatically added when joining a node to a cluster

### 1.1.0.0

Expand Down
Loading

0 comments on commit d8426a7

Please sign in to comment.