Skip to content

Commit

Permalink
SqlServerDsc: New resource SqlRSSetup, plus other changes (#1308)
Browse files Browse the repository at this point in the history
- Changes to SqlServerDsc
  - Added new resources.
    - SqlRSSetup
  - Added helper module DscResource.Common from the repository
    DscResource.Template.
    - Moved all helper functions from SqlServerDscHelper.psm1 to DscResource.Common.
    - Renamed Test-SqlDscParameterState to Test-DscParameterState.
  - Added helper module DscResource.LocalizationHelper from the repository
    DscResource.Template, this replaces the helper module CommonResourceHelper.psm1.
  - Cleaned up unit tests, mostly around loading cmdlet stubs and loading
    classes stubs, but also some tests that were using some odd variants.
  - Fix all integration tests according to issue [PowerShell/DscResource.Template#14](PowerShell/DscResource.Template#14).
- Changes to SqlSetup
  - Moved some resource specific helper functions to the new helper module
    DscResource.Common so they can be shared with the new resource SqlRSSetup.
  - Improved verbose messages in Test-TargetResource function to more
    clearly tell if features are already installed or not.
  - Refactored unit tests for the functions Test-TargetResource and
    Set-TargetResource to improve testing speed.
  - Modified the Test-TargetResource and Set-TargetResource to not be
    case-sensitive when comparing feature names. *This was handled
    correctly in real-world scenarios, but failed when running the unit
    tests (and testing casing).*
- Changes to SqlDatabaseDefaultLocation
  - No longer does the Test-TargetResource fail on the second test run
    when the backup file path was changed, and the path was ending with
    a backslash (issue #1307).
  • Loading branch information
johlju authored Mar 20, 2019
1 parent 98eaa84 commit f13c001
Show file tree
Hide file tree
Showing 89 changed files with 6,192 additions and 3,939 deletions.
33 changes: 29 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

## Unreleased

- Changes to SqlServerDsc
- Added new resources.
- SqlRSSetup
- Added helper module DscResource.Common from the repository
DscResource.Template.
- Moved all helper functions from SqlServerDscHelper.psm1 to DscResource.Common.
- Renamed Test-SqlDscParameterState to Test-DscParameterState.
- New-TerminatingError error text for a missing localized message now matches
the output even if the "missing localized message" localized message is
also missing.
- Added helper module DscResource.LocalizationHelper from the repository
DscResource.Template, this replaces the helper module CommonResourceHelper.psm1.
- Cleaned up unit tests, mostly around loading cmdlet stubs and loading
classes stubs, but also some tests that were using some odd variants.
- Fix all integration tests according to issue [PowerShell/DscResource.Template#14](https://github.com/PowerShell/DscResource.Template/issues/14).
- Changes to SqlServerMemory
- Updated Cim Class to Win32_ComputerSystem (instead of Win32_PhysicalMemory)
because the correct memory size was not being detected correctly on Azure VMs
Expand Down Expand Up @@ -33,14 +48,20 @@
- Changed the logic of 'Build the argument string to be passed to setup' to
not quote the value if root directory is specified
([issue #1254](https://github.com/PowerShell/SqlServerDsc/issues/1254)).
- Moved some resource specific helper functions to the new helper module
DscResource.Common so they can be shared with the new resource SqlRSSetup.
- Improved verbose messages in Test-TargetResource function to more
clearly tell if features are already installed or not.
- Refactored unit tests for the functions Test-TargetResource and
Set-TargetResource to improve testing speed.
- Modified the Test-TargetResource and Set-TargetResource to not be
case-sensitive when comparing feature names. *This was handled
correctly in real-world scenarios, but failed when running the unit
tests (and testing casing).*
- Changes to SqlAGDatabase
- Fix MatchDatabaseOwner to check for CONTROL SERVER, IMPERSONATE LOGIN, or
CONTROL LOGIN permission in addition to IMPERSONATE ANY LOGIN.
- Update and fix MatchDatabaseOwner help text.
- Changes to xSQLServerHelper
- New-TerminatingError error text for a missing localized message now matches
the output even if the "missing localized message" localized message is
also missing.
- Changes to SqlAG
- Updated documentation on the behaviour of defaults as they only apply when
creating a group.
Expand All @@ -52,6 +73,10 @@
run ([issue #518](https://github.com/PowerShell/SqlServerDsc/issues/518)).
- Test-Resource fixed to report whether ReadOnlyRoutingList desired state
has been reached correctly ([issue #1305](https://github.com/PowerShell/SqlServerDsc/issues/1305)).
- Changes to SqlDatabaseDefaultLocation
- No longer does the Test-TargetResource fail on the second test run
when the backup file path was changed, and the path was ending with
a backslash ([issue #1307](https://github.com/PowerShell/SqlServerDsc/issues/1307)).

## 12.3.0.0

Expand Down
11 changes: 8 additions & 3 deletions DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Expand Down
12 changes: 7 additions & 5 deletions DSCResources/MSFT_SqlAGDatabase/MSFT_SqlAGDatabase.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
-ChildPath 'CommonResourceHelper.psm1')
$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlAGDatabase'

Expand Down
12 changes: 9 additions & 3 deletions DSCResources/MSFT_SqlAGListener/MSFT_SqlAGListener.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Returns the current state of the Availability Group listener.
Expand Down
11 changes: 8 additions & 3 deletions DSCResources/MSFT_SqlAGReplica/MSFT_SqlAGReplica.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Expand Down
12 changes: 7 additions & 5 deletions DSCResources/MSFT_SqlAgentOperator/MSFT_SqlAgentOperator.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
-ChildPath 'CommonResourceHelper.psm1')
$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlAgentOperator'

Expand Down
9 changes: 8 additions & 1 deletion DSCResources/MSFT_SqlAlias/MSFT_SqlAlias.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'SqlServerDscHelper.psm1') -Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

function Get-TargetResource
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Expand Down
12 changes: 9 additions & 3 deletions DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
This function gets the sql database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
-ChildPath 'CommonResourceHelper.psm1')
$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlDatabaseDefaultLocation'

Expand Down Expand Up @@ -145,6 +147,12 @@ Function Set-TargetResource
$ProcessOnlyOnActiveNode
)

if ($Type -eq 'Backup')
{
# Ending backslash is removed because of issue #1307.
$Path = $Path.TrimEnd('\')
}

# Make sure the Path exists, needs to be cluster aware as well for this check
if (-Not (Test-Path $Path))
{
Expand Down Expand Up @@ -263,6 +271,12 @@ function Test-TargetResource

Write-Verbose -Message ($script:localizedData.TestingCurrentPath -f $Type)

if ($Type -eq 'Backup')
{
# Ending backslash is removed because of issue #1307.
$Path = $Path.TrimEnd('\')
}

$getTargetResourceParameters = @{
InstanceName = $InstanceName
ServerName = $ServerName
Expand Down
14 changes: 10 additions & 4 deletions DSCResources/MSFT_SqlDatabaseOwner/MSFT_SqlDatabaseOwner.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
This function gets the owner of the desired sql database.
Expand Down Expand Up @@ -200,7 +206,7 @@ function Test-TargetResource
Write-Verbose -Message "Testing owner $Name of database $Database"

$currentValues = Get-TargetResource @PSBoundParameters
return Test-SQLDscParameterState -CurrentValues $CurrentValues `
return Test-DscParameterState -CurrentValues $CurrentValues `
-DesiredValues $PSBoundParameters `
-ValuesToCheck @('Name', 'Database')
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Returns the current permissions for the user in the database
Expand Down Expand Up @@ -402,7 +408,7 @@ function Test-TargetResource
the value 'Present' for the Ensure parameter, otherwise Ensure will have the value
'Absent'.
#>
return Test-SQLDscParameterState -CurrentValues $getTargetResourceResult `
return Test-DscParameterState -CurrentValues $getTargetResourceResult `
-DesiredValues $PSBoundParameters `
-ValuesToCheck @('Name', 'Ensure', 'PermissionState')
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
This function gets all Key properties defined in the resource schema file
Expand Down Expand Up @@ -191,7 +197,7 @@ function Test-TargetResource

$currentValues = Get-TargetResource @PSBoundParameters

return Test-SQLDscParameterState -CurrentValues $currentValues `
return Test-DscParameterState -CurrentValues $currentValues `
-DesiredValues $PSBoundParameters `
-ValuesToCheck @('Name', 'RecoveryModel')
}
Expand Down
11 changes: 8 additions & 3 deletions DSCResources/MSFT_SqlDatabaseRole/MSFT_SqlDatabaseRole.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Expand Down
11 changes: 8 additions & 3 deletions DSCResources/MSFT_SqlRS/MSFT_SqlRS.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.LocalizationHelper'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'DscResource.LocalizationHelper.psm1')

$script:resourceHelperModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name (Join-Path -Path $script:resourceHelperModulePath -ChildPath 'DscResource.Common.psm1')

<#
.SYNOPSIS
Expand Down
Loading

0 comments on commit f13c001

Please sign in to comment.