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

Pulling in items from PR11 to fix merge conflicts #22

Merged
merged 6 commits into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};
36 changes: 8 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[![Build status](https://ci.appveyor.com/api/projects/status/6a59vfritv4kbc7d/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xfailovercluster/branch/master)
[![Build status](https://ci.appveyor.com/api/projects/status/6a59vfritv4kbc7d/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xfailovercluster/branch/master)

# xFailOverCluster

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 [opencode@microsoft.com](mailto:opencode@microsoft.com) 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,21 +41,14 @@ For more information about cluster preferred owners please see: http://support.m
## Versions

### Unreleased
* Converted appveyor.yml to install Pester from PSGallery instead of from Chocolatey.

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

### 1.3.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