Skip to content

Commit

Permalink
SqlSetup: Added the properties NpEnabled and TcpEnabled (issue dsccom…
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed May 6, 2020
1 parent e6cb820 commit adcb717
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SqlSetup
- A read only property `IsClustered` was added that can be used to determine
if the instance is clustered.
- Added the properties `NpEnabled` and `TcpEnabled` ([issue #1161](https://github.com/dsccommunity/SqlServerDsc/issues/1161)).
- SqlServerDsc.Common
- The helper function `Restart-SqlService` was improved to handle Failover
Clusters better. Now the SQL Server service will only be taken offline
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,12 @@ with different sizes and growths.
of each tempdb log file in MB.
* **`[UInt32]` SqlTempdbLogFileGrowth** _(Write)_: Specifies the file growth
increment of each tempdb data file in MB.
* **`[Boolean]` NpEnabled** _(Write)_: Specifies the state of the Named Pipes
protocol for the SQL Server service. The value $true will enable the Named
Pipes protocol and $false will disabled it.
* **`[Boolean]` TcpEnabled** _(Write)_: Specifies the state of the TCP protocol
for the SQL Server service. The value $true will enable the TCP protocol and
$false will disabled it.
* **`[UInt32]` SetupProcessTimeout** _(Write)_: The timeout, in seconds, to wait
for the setup process to finish. Default value is 7200 seconds (2 hours). If
the setup process does not finish before this time, and error will be thrown.
Expand Down
70 changes: 64 additions & 6 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@ function Get-TargetResource
.PARAMETER SqlTempdbLogFileGrowth
Specifies the file growth increment of each tempdb data file in MB.
.PARAMETER NpEnabled
Specifies the state of the Named Pipes protocol for the SQL Server service.
The value $true will enable the Named Pipes protocol and $false will disabled
it.
.PARAMETER TcpEnabled
Specifies the state of the TCP protocol for the SQL Server service. The
value $true will enable the TCP protocol and $false will disabled it.
.PARAMETER SetupProcessTimeout
The timeout, in seconds, to wait for the setup process to finish. Default
value is 7200 seconds (2 hours). If the setup process does not finish before
Expand Down Expand Up @@ -860,6 +869,14 @@ function Set-TargetResource
[System.UInt32]
$SqlTempdbLogFileGrowth,

[Parameter()]
[System.Boolean]
$NpEnabled,

[Parameter()]
[System.Boolean]
$TcpEnabled,

[Parameter()]
[System.UInt32]
$SetupProcessTimeout = 7200,
Expand Down Expand Up @@ -1246,6 +1263,30 @@ function Set-TargetResource
$setupArguments['SQLSysAdminAccounts'] += $SQLSysAdminAccounts
}

if ($PSBoundParameters.ContainsKey('NpEnabled'))
{
if ($NpEnabled)
{
$setupArguments['NPENABLED'] = 1
}
else
{
$setupArguments['NPENABLED'] = 0
}
}

if ($PSBoundParameters.ContainsKey('TcpEnabled'))
{
if ($TcpEnabled)
{
$setupArguments['TCPENABLED'] = 1
}
else
{
$setupArguments['TCPENABLED'] = 0
}
}

$argumentVars += @(
'SecurityMode',
'SQLCollation',
Expand Down Expand Up @@ -1418,18 +1459,14 @@ function Set-TargetResource
{
if ($argument -eq 'ProductKey')
{
$setupArguments += @{
'PID' = (Get-Variable -Name $argument -ValueOnly)
}
$setupArguments['PID'] = Get-Variable -Name $argument -ValueOnly
}
else
{
# If the argument contains a value, then add the argument to the setup argument list
if (Get-Variable -Name $argument -ValueOnly)
{
$setupArguments += @{
$argument = (Get-Variable -Name $argument -ValueOnly)
}
$setupArguments[$argument] = Get-Variable -Name $argument -ValueOnly
}
}
}
Expand Down Expand Up @@ -1781,6 +1818,19 @@ function Set-TargetResource
.PARAMETER SqlTempdbLogFileGrowth
Specifies the file growth increment of each tempdb data file in MB.
.PARAMETER NpEnabled
Specifies the state of the Named Pipes protocol for the SQL Server service.
The value $true will enable the Named Pipes protocol and $false will disabled
it.
Not used in Test-TargetResource.
.PARAMETER TcpEnabled
Specifies the state of the TCP protocol for the SQL Server service. The
value $true will enable the TCP protocol and $false will disabled it.
Not used in Test-TargetResource.
.PARAMETER SetupProcessTimeout
The timeout, in seconds, to wait for the setup process to finish. Default
value is 7200 seconds (2 hours). If the setup process does not finish before
Expand Down Expand Up @@ -2027,6 +2077,14 @@ function Test-TargetResource
[System.UInt32]
$SqlTempdbLogFileGrowth,

[Parameter()]
[System.Boolean]
$NpEnabled,

[Parameter()]
[System.Boolean]
$TcpEnabled,

[Parameter()]
[System.UInt32]
$SetupProcessTimeout = 7200,
Expand Down
2 changes: 2 additions & 0 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class DSC_SqlSetup : OMI_BaseResource
[Write, Description("Specifies the file growth increment of each tempdb data file in MB.")] UInt32 SqlTempdbFileGrowth;
[Write, Description("Specifies the initial size of each tempdb log file in MB.")] UInt32 SqlTempdbLogFileSize;
[Write, Description("Specifies the file growth increment of each tempdb data file in MB.")] UInt32 SqlTempdbLogFileGrowth;
[Write, Description("Specifies the state of the Named Pipes protocol for the SQL Server service. The value $true will enable the Named Pipes protocol and $false will disabled it.")] Boolean NpEnabled;
[Write, Description("Specifies the state of the TCP protocol for the SQL Server service. The value $true will enable the TCP protocol and $false will disabled it.")] Boolean TcpEnabled;
[Write, Description("The timeout, in seconds, to wait for the setup process to finish. Default value is 7200 seconds (2 hours). If the setup process does not finish before this time, and error will be thrown.")] UInt32 SetupProcessTimeout;
[Write, Description("Feature flags are used to toggle functionality on or off. See the documentation for what additional functionality exist through a feature flag.")] String FeatureFlag[];
[Read, Description("Returns a boolean value of $true if the instance is clustered, otherwise it returns $false.")] Boolean IsClustered;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Configuration Example
ASBackupDir = 'C:\MSOLAP\Backup'
ASTempDir = 'C:\MSOLAP\Temp'
SourcePath = 'C:\InstallMedia\SQL2016RTM'
NpEnabled = $true
TcpEnabled = $true
UpdateEnabled = 'False'
ForceReboot = $false

Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/DSC_SqlSetup.config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ Configuration DSC_SqlSetup_InstallDatabaseEngineNamedInstanceAsSystem_Config
SqlTempDbFileGrowth = $Node.SqlTempDbFileGrowth
SqlTempDbLogFileSize = $Node.SqlTempDbLogFileSize
SqlTempDbLogFileGrowth = $Node.SqlTempDbLogFileGrowth
NpEnabled = $true
TcpEnabled = $true

# This must be set if using SYSTEM account to install.
SQLSysAdminAccounts = @(
Expand Down
8 changes: 6 additions & 2 deletions tests/Unit/DSC_SqlSetup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ try
Assert-VerifiableMock
}

Describe "SqlSetup\Set-TargetResource" -Tag 'Set' {
Describe 'SqlSetup\Set-TargetResource' -Tag 'Set' {
BeforeAll {
#region Setting up TestDrive:\

Expand Down Expand Up @@ -2237,6 +2237,8 @@ try
SqlTempDbFileGrowth = 128
SqlTempDbLogFileSize = 128
SqlTempDbLogFileGrowth = 128
NpEnabled = $true
TcpEnabled = $true
}

if ( $mockSqlMajorVersion -in (13,14) )
Expand Down Expand Up @@ -2271,6 +2273,8 @@ try
SqlTempDbFileGrowth = 128
SqlTempDbLogFileSize = 128
SqlTempDbLogFileGrowth = 128
NpEnabled = 1
TcpEnabled = 1
}

{ Set-TargetResource @testParameters } | Should -Not -Throw
Expand All @@ -2282,7 +2286,7 @@ try
Assert-MockCalled -CommandName Import-SQLPSModule -Exactly -Times 1 -Scope It
}

if( $mockSqlMajorVersion -in (13,14) )
if ($mockSqlMajorVersion -in (13,14))
{
It 'Should throw when feature parameter contains ''SSMS'' when installing SQL Server 2016 and 2017' {
$testParameters += @{
Expand Down

0 comments on commit adcb717

Please sign in to comment.