Skip to content

Commit

Permalink
Changes to SqlServerConfiguration
Browse files Browse the repository at this point in the history
  - BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed
    to ServerName and InstanceName respectivly (issue dsccommunity#308).
  • Loading branch information
johlju committed Dec 1, 2017
1 parent cf8165f commit 35a8214
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 61 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -47,6 +47,9 @@
- Changes to SqlDatabaseRole
- BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed
to ServerName and InstanceName respectivly ([issue #308](https://github.com/PowerShell/xSQLServer/issues/)).
- Changes to SqlServerConfiguration
- BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed
to ServerName and InstanceName respectivly ([issue #308](https://github.com/PowerShell/xSQLServer/issues/)).
- Changes to SqlServerEndpoint
- BREAKING CHANGE: Parameters SQLServer and SQLInstanceName has been renamed
to ServerName and InstanceName respectivly ([issue #308](https://github.com/PowerShell/xSQLServer/issues/)).
Expand Down
Expand Up @@ -6,10 +6,10 @@ Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Pare
.SYNOPSIS
Gets the current value of a SQL configuration option
.PARAMETER SQLServer
.PARAMETER ServerName
Hostname of the SQL Server to be configured
.PARAMETER SQLInstanceName
.PARAMETER InstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
.PARAMETER OptionName
Expand All @@ -33,11 +33,11 @@ function Get-TargetResource
param(
[Parameter(Mandatory = $true)]
[String]
$SQLServer,
$ServerName,

[Parameter(Mandatory = $true)]
[String]
$SQLInstanceName,
$InstanceName,

[Parameter(Mandatory = $true)]
[String]
Expand All @@ -56,7 +56,7 @@ function Get-TargetResource
$RestartTimeout = 120
)

$sql = Connect-SQL -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName
$sql = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName

## get the configuration option
$option = $sql.Configuration.Properties | Where-Object { $_.DisplayName -eq $OptionName }
Expand All @@ -67,23 +67,23 @@ function Get-TargetResource
}

return @{
SqlServer = $SQLServer
SQLInstanceName = $SQLInstanceName
OptionName = $option.DisplayName
OptionValue = $option.ConfigValue
RestartService = $RestartService
RestartTimeout = $RestartTimeout
ServerName = $ServerName
InstanceName = $InstanceName
OptionName = $option.DisplayName
OptionValue = $option.ConfigValue
RestartService = $RestartService
RestartTimeout = $RestartTimeout
}
}

<#
.SYNOPSIS
Sets the value of a SQL configuration option
.PARAMETER SQLServer
.PARAMETER ServerName
Hostname of the SQL Server to be configured
.PARAMETER SQLInstanceName
.PARAMETER InstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
.PARAMETER OptionName
Expand All @@ -104,11 +104,11 @@ function Set-TargetResource
param(
[Parameter(Mandatory = $true)]
[String]
$SQLServer,
$ServerName,

[Parameter(Mandatory = $true)]
[String]
$SQLInstanceName,
$InstanceName,

[Parameter(Mandatory = $true)]
[String]
Expand All @@ -127,7 +127,7 @@ function Set-TargetResource
$RestartTimeout = 120
)

$sql = Connect-SQL -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName
$sql = Connect-SQL -SQLServer $ServerName -SQLInstanceName $InstanceName

## get the configuration option
$option = $sql.Configuration.Properties | Where-Object { $_.DisplayName -eq $OptionName }
Expand All @@ -147,7 +147,7 @@ function Set-TargetResource
elseif (($option.IsDynamic -eq $false) -and ($RestartService -eq $true))
{
New-VerboseMessage -Message 'Configuration option has been updated, restarting instance...'
Restart-SqlService -SQLServer $SQLServer -SQLInstanceName $SQLInstanceName -Timeout $RestartTimeout
Restart-SqlService -SQLServer $ServerName -SQLInstanceName $InstanceName -Timeout $RestartTimeout
}
else
{
Expand All @@ -159,10 +159,10 @@ function Set-TargetResource
.SYNOPSIS
Determines whether a SQL configuration option value is properly set
.PARAMETER SQLServer
.PARAMETER ServerName
Hostname of the SQL Server to be configured
.PARAMETER SQLInstanceName
.PARAMETER InstanceName
Name of the SQL instance to be configued. Default is 'MSSQLSERVER'
.PARAMETER OptionName
Expand All @@ -186,11 +186,11 @@ function Test-TargetResource
param(
[Parameter(Mandatory = $true)]
[String]
$SQLServer,
$ServerName,

[Parameter(Mandatory = $true)]
[String]
$SQLInstanceName,
$InstanceName,

[Parameter(Mandatory = $true)]
[String]
Expand Down
@@ -1,8 +1,8 @@
[ClassVersion("1.0.0.0"), FriendlyName("SqlServerConfiguration")]
class MSFT_SqlServerConfiguration : OMI_BaseResource
{
[Key, Description("The hostname of the SQL Server to be configured.")] String SQLServer;
[Key, Description("Name of the SQL instance to be configured.")] String SQLInstanceName;
[Key, Description("The hostname of the SQL Server to be configured.")] String ServerName;
[Key, Description("Name of the SQL instance to be configured.")] String InstanceName;
[Key, Description("The name of the SQL configuration option to be checked.")] String OptionName;
[Required, Description("The desired value of the SQL configuration option.")] Sint32 OptionValue;
[Write, Description("Determines whether the instance should be restarted after updating the configuration option.")] Boolean RestartService;
Expand Down
Expand Up @@ -25,10 +25,10 @@ Configuration Example
{
SqlServerConfiguration ('SQLConfigCLR_{0}' -f $SQLInstance)
{
SQLServer = $node.NodeName
SQLInstanceName = $SQLInstance
OptionName = $node.OptionName
OptionValue = 1
Servername = $node.NodeName
InstanceName = $SQLInstance
OptionName = $node.OptionName
OptionValue = 1
}
}
}
Expand Down
Expand Up @@ -14,11 +14,11 @@ Configuration Example
SqlServerConfiguration 'SQLConfigPriorityBoost'
{

SQLServer = 'localhost'
SQLInstanceName = 'MSSQLSERVER'
OptionName = 'priority boost'
OptionValue = 1
RestartService = $false
ServerName = 'localhost'
InstanceName = 'MSSQLSERVER'
OptionName = 'priority boost'
OptionValue = 1
RestartService = $false
}
}
}
58 changes: 29 additions & 29 deletions Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1
@@ -1,12 +1,12 @@
$script:DSCModuleName = 'SqlServerDsc'
$script:DSCResourceName = 'MSFT_SqlServerConfiguration'
$script:DSCModuleName = 'SqlServerDsc'
$script:DSCResourceName = 'MSFT_SqlServerConfiguration'

# Unit Test Template Version: 1.1.0
[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if ( (-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests'))) -or `
(-not (Test-Path -Path (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1'))) )
{
& git @('clone','https://github.com/PowerShell/DscResource.Tests.git',(Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\'))
& git @('clone', 'https://github.com/PowerShell/DscResource.Tests.git', (Join-Path -Path $script:moduleRoot -ChildPath '\DSCResource.Tests\'))
}

Import-Module (Join-Path -Path $script:moduleRoot -ChildPath 'DSCResource.Tests\TestHelper.psm1') -Force
Expand All @@ -16,46 +16,46 @@ $TestEnvironment = Initialize-TestEnvironment `
-TestType Unit

$defaultState = @{
SQLServer = 'CLU01'
SQLInstanceName = 'ClusteredInstance'
OptionName = 'user connections'
OptionValue = 0
ServerName = 'CLU01'
InstanceName = 'ClusteredInstance'
OptionName = 'user connections'
OptionValue = 0
RestartService = $false
RestartTimeout = 120
}

$desiredState = @{
SQLServer = 'CLU01'
SQLInstanceName = 'ClusteredInstance'
OptionName = 'user connections'
OptionValue = 500
ServerName = 'CLU01'
InstanceName = 'ClusteredInstance'
OptionName = 'user connections'
OptionValue = 500
RestartService = $false
RestartTimeout = 120
}

$desiredStateRestart = @{
SQLServer = 'CLU01'
SQLInstanceName = 'ClusteredInstance'
OptionName = 'user connections'
OptionValue = 5000
ServerName = 'CLU01'
InstanceName = 'ClusteredInstance'
OptionName = 'user connections'
OptionValue = 5000
RestartService = $true
RestartTimeout = 120
}

$dynamicOption = @{
SQLServer = 'CLU02'
SQLInstanceName = 'ClusteredInstance'
OptionName = 'show advanced options'
OptionValue = 0
ServerName = 'CLU02'
InstanceName = 'ClusteredInstance'
OptionName = 'show advanced options'
OptionValue = 0
RestartService = $false
RestartTimeout = 120
}

$invalidOption = @{
SQLServer = 'CLU01'
SQLInstanceName = 'MSSQLSERVER'
OptionName = 'Does Not Exist'
OptionValue = 1
ServerName = 'CLU01'
InstanceName = 'MSSQLSERVER'
OptionName = 'Does Not Exist'
OptionValue = 1
RestartService = $false
RestartTimeout = 120
}
Expand Down Expand Up @@ -95,8 +95,8 @@ try
$result = Get-TargetResource @desiredState

It 'Should return the same values as passed' {
$result.SQLServer | Should -Be $desiredState.SQLServer
$result.SQLInstanceName | Should -Be $desiredState.SQLInstanceName
$result.ServerName | Should -Be $desiredState.ServerName
$result.InstanceName | Should -Be $desiredState.InstanceName
$result.OptionName | Should -Be $desiredState.OptionName
$result.OptionValue | Should -Not -Be $desiredState.OptionValue
$result.RestartService | Should -Be $desiredState.RestartService
Expand Down Expand Up @@ -132,8 +132,8 @@ try
$result = Get-TargetResource @desiredState

It 'Should return the same values as passed' {
$result.SQLServer | Should -Be $desiredState.SQLServer
$result.SQLInstanceName | Should -Be $desiredState.SQLInstanceName
$result.ServerName | Should -Be $desiredState.ServerName
$result.InstanceName | Should -Be $desiredState.InstanceName
$result.OptionName | Should -Be $desiredState.OptionName
$result.OptionValue | Should -Be $desiredState.OptionValue
$result.RestartService | Should -Be $desiredState.RestartService
Expand Down Expand Up @@ -216,7 +216,7 @@ try
@{
DisplayName = 'user connections'
ConfigValue = 0
IsDynamic = $false
IsDynamic = $false
}
)
}
Expand All @@ -235,7 +235,7 @@ try
@{
DisplayName = 'show advanced options'
ConfigValue = 1
IsDynamic = $true
IsDynamic = $true
}
)
}
Expand Down

0 comments on commit 35a8214

Please sign in to comment.