Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/PowerShell/xSQLServer into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kewalaka committed Jun 4, 2017
2 parents 8883615 + 15b873f commit a631068
Show file tree
Hide file tree
Showing 120 changed files with 15,202 additions and 6,999 deletions.
5 changes: 2 additions & 3 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ coverage:
status:
project:
default:
# Set the overall project code coverage requirement to 68
# This should be 70
target: 68
# Set the overall project code coverage requirement to 70%
target: 70
patch:
default:
# Set the pull request requirement to not regress overall coverage by more than 5%
Expand Down
13 changes: 7 additions & 6 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@

_Your feedback and support is greatly appreciated, thanks for contributing! If you like to contribute more please feel free to read the [contributing section](https://github.com/PowerShell/xSQLServer#contributing)._
<!--
Your feedback and support is greatly appreciated, thanks for contributing!
Please prefix the issue title with the resource name, i.e. 'xSQLServerSetup: Short description of my issue'

Please provide the following information regarding your issue (place N/A if the fields that don't apply to your issue):
---- DELETE THIS LINE AND ABOVE ----

**Details of the scenario you try and problem that is occurring:**
If you like to contribute more please feel free to read the contributing section at https://github.com/PowerShell/xSQLServer#contributing.
-->
**Details of the scenario you tried and the problem that is occurring:**

**The DSC configuration that is using the resource (as detailed as possible):**

**Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:**

**What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:**

**Version of the DSC module you're using, or 'dev' if you're using current dev branch:**
13 changes: 7 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
_Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project is greatly appreciated!_
<!--
Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project is greatly appreciated!
Please make sure you have read the [contributing section](https://github.com/PowerShell/xSQLServer#contributing)
Please make sure you have read the contributing section at https://github.com/PowerShell/xSQLServer#contributing.
Please prefix the PR title with the resource name, i.e. 'xSQLServerSetup: My short description'
If this is a breaking change, then also prefix the PR title with 'BREAKING CHANGE:', i.e. 'BREAKING CHANGE: xSQLServerSetup: My short description'
To aid community reviewers in reviewing and merging your PR, please take the time to run through the below checklist.
Change to [x] for each task in the task list that applies to this PR.

---- DELETE THIS LINE AND EVERYTHING ABOVE ----

-->
**Pull Request (PR) description**
[Replace this with a description of your pull request]

This Pull Request (PR) fixes the following issues:
**This Pull Request (PR) fixes the following issues:**
[Replace this with the list of issues or n/a. Use format: Fixes #123]

**Task list:**
- [ ] Change details added to Unreleased section of CHANGELOG.md?
- [ ] Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
- [ ] Examples appropriately updated?
Expand Down
216 changes: 205 additions & 11 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ If you are keen to make xSQLServer better, why not consider contributing your wo

## Core contribution guidelines

We follow all of the standard contribution guidelines for DSC resources [outlined in DscResources repo](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md), so please review these as a baseline for contributing.
We follow all of the standard contribution guidelines for DSC resources [outlined in DscResources repository](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md), so please review these as a baseline for contributing.

## xSQLServer specific guidelines

### SQL Server products supported by resources

Any resource should be able to target at least all SQL Server versions that are currently supported by Microsoft (also those in extended support).
Unless the functionality that the resource targets does not exist in a certain SQL Server version.
There can also be other limitations that restrict the resource from tageting all supported versions.
There can also be other limitations that restrict the resource from targeting all supported versions.

Those SQL Server products that are still supported can be listed at the [Microsoft lifecycle site](https://support.microsoft.com/en-us/lifecycle/search?alpha=SQL%20Server).
Those SQL Server products that are still supported can be listed at the [Microsoft life cycle site](https://support.microsoft.com/en-us/lifecycle/search?alpha=SQL%20Server).

### Naming convention

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class MSFT_xSQLAOGroupEnsure : OMI_BaseResource
[Key, Description("Name for availability group.")] String AvailabilityGroupName;
[Write, Description("Listener name for availability group.")] String AvailabilityGroupNameListener;
[Write, Description("List of IP addresses associated with listener.")] String AvailabilityGroupNameIP[];
[Write, Description("Network subnetmask for listener.")] String AvailabilityGroupSubMask[];
[Write, Description("Network subnet mask for listener.")] String AvailabilityGroupSubMask[];
[Write, Description("Port availability group should listen on.")] Uint32 AvailabilityGroupPort;
[Write, Description("Mode secondaries should operate under (None, ReadOnly, ReadIntent)."), ValueMap{"None","ReadOnly","ReadIntent"}, Values{"None","ReadOnly","ReadIntent"}] String ReadableSecondary;
[Write, Description("Where backups should be backed up from (Primary, Secondary)."), ValueMap{"Primary","Secondary"}, Values{"Primary","Secondary"}] String AutoBackupPreference;
[Write, Description("The percentage weight for backup prority (default 50).")] Uint32 BackupPriority;
[Write, Description("The percentage weight for backup priority (default 50).")] Uint32 BackupPriority;
[Write, Description("he TCP port for the SQL AG Endpoint (default 5022).")] Uint32 EndPointPort;
[Write, Description("The SQL Server for the database.")] String SQLServer;
[Write, Description("The SQL instance for the database.")] String SQLInstanceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MSFT_xSQLServerAlias : OMI_BaseResource
{
[Key, Description("The name of Alias (e.g. svr01\\inst01).")] String Name;
[Write, Description("Protocol to use when connecting. Valid values are 'TCP' or 'NP' (Named Pipes). Default value is 'TCP'."), ValueMap{"TCP","NP"}, Values{"TCP","NP"}] String Protocol;
[Key, Description("The SQL Server you are aliasing (the netbios name or FQDN).")] String ServerName;
[Key, Description("The SQL Server you are aliasing (the NetBIOS name or FQDN).")] String ServerName;
[Write, Description("The TCP port SQL is listening on. Only used when protocol is set to 'TCP'. Default value is port 1433.")] UInt16 TcpPort;
[Write, Description("The UseDynamicTcpPort specify that the Net-Library will determine the port dynamically. The port specified in Port number will not be used. Default value is '$false'.")] Boolean UseDynamicTcpPort;
[Read, Description("Named Pipes path from the Get-TargetResource method.")] String PipeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function Set-TargetResource
}
catch
{
throw New-TerminatingError -ErrorType RemoveAvailabilityGroupFailed -FormatArgs $availabilityGroup.Name,$SQLInstanceName -ErrorCategory ResourceUnavailable
throw New-TerminatingError -ErrorType RemoveAvailabilityGroupFailed -FormatArgs $availabilityGroup.Name,$SQLInstanceName -ErrorCategory ResourceUnavailable -InnerException $_.Exception
}
}
else
Expand All @@ -254,55 +254,55 @@ function Set-TargetResource
{
$clusterServiceName = 'NT SERVICE\ClusSvc'
$ntAuthoritySystemName = 'NT AUTHORITY\SYSTEM'
$availabilityGroupManagementRoleName = 'AG_Management'
$availabilityGroupManagementPerms = @('Connect SQL','Alter Any Availability Group','View Server State')
$clusterPermissionsPresent = $false

$permissionsParams = @{
SQLServer = $SQLServer
SQLInstanceName = $SQLInstanceName
Database = 'master'
WithResults = $true
}

foreach ( $loginName in @( $clusterServiceName, $ntAuthoritySystemName ) )
{
if ( $serverObject.Logins[$loginName] -and -not $clusterPermissionsPresent )
if ( $serverObject.Logins[$loginName] )
{
$queryToGetEffectivePermissionsForLogin = "
EXECUTE AS LOGIN = '$loginName'
SELECT DISTINCT permission_name
FROM fn_my_permissions(null,'SERVER')
REVERT
"

$loginEffectivePermissionsResult = Invoke-Query @permissionsParams -Query $queryToGetEffectivePermissionsForLogin
$loginEffectivePermissions = $loginEffectivePermissionsResult.Tables.Rows.permission_name
$testLoginEffectivePermissionsParams = @{
SQLServer = $SQLServer
SQLInstanceName = $SQLInstanceName
LoginName = $loginName
Permissions = $availabilityGroupManagementPerms
}

$clusterPermissionsPresent = Test-LoginEffectivePermissions @testLoginEffectivePermissionsParams

if ( $clusterPermissionsPresent )
{
# Exit the loop when the script verifies the required cluster permissions are present
break
}
else
{
switch ( $loginName )
{
$clusterServiceName
{
New-VerboseMessage -Message "The recommended account '$loginName' is missing one or more of the following permissions: $( $availabilityGroupManagementPerms -join ', ' ). Trying with '$ntAuthoritySystemName'."
}

if ( $null -ne $loginEffectivePermissions )
$ntAuthoritySystemName
{
New-VerboseMessage -Message "'$loginName' is missing one or more of the following permissions: $( $availabilityGroupManagementPerms -join ', ' )"
}
}
}
}
else
{
switch ( $loginName )
{
$loginMissingPermissions = Compare-Object -ReferenceObject $availabilityGroupManagementPerms -DifferenceObject $loginEffectivePermissions |
Where-Object { $_.SideIndicator -ne '=>' } |
Select-Object -ExpandProperty InputObject

if ( $loginMissingPermissions.Count -eq 0 )
$clusterServiceName
{
$clusterPermissionsPresent = $true
New-VerboseMessage -Message "The recommended login '$loginName' is not present. Trying with '$ntAuthoritySystemName'."
}
else

$ntAuthoritySystemName
{
switch ( $loginName )
{
$clusterServiceName
{
New-VerboseMessage -Message "The recommended account '$loginName' is missing the following permissions: $( $loginMissingPermissions -join ', ' ). Trying with '$ntAuthoritySystemName'."
}

$ntAuthoritySystemName
{
New-VerboseMessage -Message "'$loginName' is missing the following permissions: $( $loginMissingPermissions -join ', ' )"
}
}
New-VerboseMessage -Message "The login '$loginName' is not present."
}
}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ function Set-TargetResource
}
catch
{
throw New-TerminatingError -ErrorType CreateAvailabilityGroupReplicaFailed -FormatArgs $Ensure,$SQLInstanceName -ErrorCategory OperationStopped
throw New-TerminatingError -ErrorType CreateAvailabilityGroupReplicaFailed -FormatArgs $newReplicaParams.Name,$SQLInstanceName -ErrorCategory OperationStopped -InnerException $_.Exception
}

# Set up the parameters for the new availability group
Expand Down Expand Up @@ -398,7 +398,7 @@ function Set-TargetResource
}
catch
{
throw New-TerminatingError -ErrorType CreateAvailabilityGroupFailed -FormatArgs $Name,$_.Exception -ErrorCategory OperationStopped
throw New-TerminatingError -ErrorType CreateAvailabilityGroupFailed -FormatArgs $Name -ErrorCategory OperationStopped -InnerException $_.Exception
}
}
# Otherwise let's check each of the parameters passed and update the Availability Group accordingly
Expand Down Expand Up @@ -747,39 +747,7 @@ function Update-AvailabilityGroup
}
catch
{
throw New-TerminatingError -ErrorType AlterAvailabilityGroupFailed -FormatArgs $AvailabilityGroup.Name -ErrorCategory OperationStopped
}
finally
{
$ErrorActionPreference = $originalErrorActionPreference
}
}

<#
.SYNOPSIS
Executes the alter method on an Availability Group Replica object.
.PARAMETER AvailabilityGroupReplica
The Availabilty Group Replica object that must be altered.
#>
function Update-AvailabilityGroupReplica
{
param
(
[Parameter(Mandatory = $true)]
[Microsoft.SqlServer.Management.Smo.AvailabilityReplica]
$AvailabilityGroupReplica
)

try
{
$originalErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
$AvailabilityGroupReplica.Alter()
}
catch
{
throw New-TerminatingError -ErrorType AlterAvailabilityGroupReplicaFailed -FormatArgs $AvailabilityGroupReplica.Name -ErrorCategory OperationStopped
throw New-TerminatingError -ErrorType AlterAvailabilityGroupFailed -FormatArgs $AvailabilityGroup.Name -ErrorCategory OperationStopped -InnerException $_.Exception
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MSFT_xSQLServerAlwaysOnAvailabilityGroup : OMI_BaseResource
{
[Key, Description("The name of the availability group.")] String Name;
[Required, Description("Hostname of the SQL Server to be configured.")] String SQLServer;
[Key, Description("Name of the SQL instance to be configued.")] String SQLInstanceName;
[Key, Description("Name of the SQL instance to be configured.")] String SQLInstanceName;
[Write, Description("Specifies if the availability group should be present or absent. Default is Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
[Write, Description("Specifies the automated backup preference for the availability group. Default is None"), ValueMap{"Primary","SecondaryOnly","Secondary","None"}, Values{"Primary","SecondaryOnly","Secondary","None"}] String AutomatedBackupPreference;
[Write, Description("Specifies the replica availability mode. Default is 'AsynchronousCommit'."), ValueMap{"AsynchronousCommit","SynchronousCommit"}, Values{"AsynchronousCommit","SynchronousCommit"}] String AvailabilityMode;
Expand Down
Loading

0 comments on commit a631068

Please sign in to comment.