Skip to content

Commit

Permalink
- Changes to SqlServerDsc
Browse files Browse the repository at this point in the history
  - Fix hashtables to align with style guideline (issue dsccommunity#1437).
  • Loading branch information
johlju committed Oct 29, 2019
1 parent 0785472 commit c763ea0
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 96 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

## Unreleased

- Changes to SqlServerDsc
- Fix hashtables to align with style guideline ([issue #1437](https://github.com/PowerShell/SqlServerDsc/issues/1437)).

## 13.2.0.0

- Changes to SqlServerDsc
- Fix keywords to lower-case to align with guideline.
- Fix keywords to have space before a parenthesis to align with guideline.
- Fix typo in SqlSetup strings ([issue #1419](https://github.com/PowerShell/SqlServerDsc/issues/1419))
- Fix typo in SqlSetup strings ([issue #1419](https://github.com/PowerShell/SqlServerDsc/issues/1419)).

## 13.1.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ function Test-TargetResource
Make sure default values are part of desired values if the user did
not specify them in the configuration.
#>
$desiredValues = @{ } + $PSBoundParameters
$desiredValues = @{} + $PSBoundParameters
$desiredValues['Ensure'] = $Ensure
$desiredValues['UserType'] = $UserType

Expand Down
78 changes: 59 additions & 19 deletions DSCResources/MSFT_SqlSetup/MSFT_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,9 @@ function Set-TargetResource
}

# Add the cluster disks as a setup argument
$setupArguments += @{ FailoverClusterDisks = ($failoverClusterDisks | Sort-Object) }
$setupArguments += @{
FailoverClusterDisks = ($failoverClusterDisks | Sort-Object)
}
}

# Determine network mapping for specific cluster installation types
Expand Down Expand Up @@ -1320,7 +1322,9 @@ function Set-TargetResource
}

# Add the networks to the installation arguments
$setupArguments += @{ FailoverClusterIPAddresses = $clusterIPAddresses }
$setupArguments += @{
FailoverClusterIPAddresses = $clusterIPAddresses
}
}

# Add standard install arguments
Expand Down Expand Up @@ -1369,7 +1373,9 @@ function Set-TargetResource

if ($SecurityMode -eq 'SQL')
{
$setupArguments += @{ SAPwd = $SAPwd.GetNetworkCredential().Password }
$setupArguments += @{
SAPwd = $SAPwd.GetNetworkCredential().Password
}
}

# Should not be passed when PrepareFailoverCluster is specified
Expand All @@ -1382,7 +1388,9 @@ function Set-TargetResource
system administrator. The username is stored in $PsDscContext.RunAsUser.
#>
Write-Verbose -Message ($script:localizedData.AddingFirstSystemAdministratorSqlServer -f $($PsDscContext.RunAsUser))
$setupArguments += @{ SQLSysAdminAccounts = @($PsDscContext.RunAsUser) }
$setupArguments += @{
SQLSysAdminAccounts = @($PsDscContext.RunAsUser)
}
}

if ($PSBoundParameters.ContainsKey('SQLSysAdminAccounts'))
Expand All @@ -1405,31 +1413,41 @@ function Set-TargetResource
# tempdb : define SqlTempdbFileCount
if ($PSBoundParameters.ContainsKey('SqlTempdbFileCount'))
{
$setupArguments += @{ SqlTempdbFileCount = $SqlTempdbFileCount }
$setupArguments += @{
SqlTempdbFileCount = $SqlTempdbFileCount
}
}

# tempdb : define SqlTempdbFileSize
if ($PSBoundParameters.ContainsKey('SqlTempdbFileSize'))
{
$setupArguments += @{ SqlTempdbFileSize = $SqlTempdbFileSize }
$setupArguments += @{
SqlTempdbFileSize = $SqlTempdbFileSize
}
}

# tempdb : define SqlTempdbFileGrowth
if ($PSBoundParameters.ContainsKey('SqlTempdbFileGrowth'))
{
$setupArguments += @{ SqlTempdbFileGrowth = $SqlTempdbFileGrowth }
$setupArguments += @{
SqlTempdbFileGrowth = $SqlTempdbFileGrowth
}
}

# tempdb : define SqlTempdbLogFileSize
if ($PSBoundParameters.ContainsKey('SqlTempdbLogFileSize'))
{
$setupArguments += @{ SqlTempdbLogFileSize = $SqlTempdbLogFileSize }
$setupArguments += @{
SqlTempdbLogFileSize = $SqlTempdbLogFileSize
}
}

# tempdb : define SqlTempdbLogFileGrowth
if ($PSBoundParameters.ContainsKey('SqlTempdbLogFileGrowth'))
{
$setupArguments += @{ SqlTempdbLogFileGrowth = $SqlTempdbLogFileGrowth }
$setupArguments += @{
SqlTempdbLogFileGrowth = $SqlTempdbLogFileGrowth
}
}

if ($Action -in @('Install','Upgrade'))
Expand All @@ -1440,12 +1458,16 @@ function Set-TargetResource
}
else
{
$setupArguments += @{ AgtSvcStartupType = 'Automatic' }
$setupArguments += @{
AgtSvcStartupType = 'Automatic'
}
}

if ($PSBoundParameters.ContainsKey('SqlSvcStartupType'))
{
$setupArguments += @{ SqlSvcStartupType = $SqlSvcStartupType}
$setupArguments += @{
SqlSvcStartupType = $SqlSvcStartupType
}
}
}
}
Expand All @@ -1466,11 +1488,15 @@ function Set-TargetResource
}
if ($PSBoundParameters.ContainsKey('RsSvcStartupType'))
{
$setupArguments += @{ RsSvcStartupType = $RsSvcStartupType}
$setupArguments += @{
RsSvcStartupType = $RsSvcStartupType
}
}
if ($PSBoundParameters.ContainsKey('RSInstallMode'))
{
$setupArguments += @{ RSINSTALLMODE = $RSInstallMode}
$setupArguments += @{
RSINSTALLMODE = $RSInstallMode
}
}
}

Expand Down Expand Up @@ -1505,7 +1531,9 @@ function Set-TargetResource
system administrator. The username is stored in $PsDscContext.RunAsUser.
#>
Write-Verbose -Message ($script:localizedData.AddingFirstSystemAdministratorAnalysisServices -f $($PsDscContext.RunAsUser))
$setupArguments += @{ ASSysAdminAccounts = @($PsDscContext.RunAsUser) }
$setupArguments += @{
ASSysAdminAccounts = @($PsDscContext.RunAsUser)
}
}

if ($PSBoundParameters.ContainsKey("ASSysAdminAccounts"))
Expand All @@ -1516,7 +1544,9 @@ function Set-TargetResource

if ($PSBoundParameters.ContainsKey('AsSvcStartupType'))
{
$setupArguments += @{ AsSvcStartupType = $AsSvcStartupType}
$setupArguments += @{
AsSvcStartupType = $AsSvcStartupType
}
}
}

Expand All @@ -1529,7 +1559,9 @@ function Set-TargetResource

if ($PSBoundParameters.ContainsKey('IsSvcStartupType'))
{
$setupArguments += @{ IsSvcStartupType = $IsSvcStartupType}
$setupArguments += @{
IsSvcStartupType = $IsSvcStartupType
}
}
}

Expand All @@ -1538,14 +1570,18 @@ 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 All @@ -1564,7 +1600,11 @@ function Set-TargetResource
}
elseif ($currentSetupArgument.Value -is [System.Boolean])
{
$setupArgumentValue = @{ $true = 'True'; $false = 'False' }[$currentSetupArgument.Value]
$setupArgumentValue = @{
$true = 'True'
$false = 'False'
}[$currentSetupArgument.Value]

$setupArgumentValue = '"{0}"' -f $setupArgumentValue
}
else
Expand Down
12 changes: 9 additions & 3 deletions Modules/SqlServerDsc.Common/SqlServerDsc.Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1412,17 +1412,23 @@ function Restart-SqlService

# Stop the SQL Server and dependent resources
Write-Verbose -Message ($script:localizedData.BringClusterResourcesOffline -f $resourceNames) -Verbose
$sqlService | Invoke-CimMethod -MethodName TakeOffline -Arguments @{ Timeout = $Timeout }
$sqlService | Invoke-CimMethod -MethodName TakeOffline -Arguments @{
Timeout = $Timeout
}

# Start the SQL server resource
Write-Verbose -Message ($script:localizedData.BringSqlServerClusterResourcesOnline) -Verbose
$sqlService | Invoke-CimMethod -MethodName BringOnline -Arguments @{ Timeout = $Timeout }
$sqlService | Invoke-CimMethod -MethodName BringOnline -Arguments @{
Timeout = $Timeout
}

# Start the SQL Agent resource
if ($agentService)
{
Write-Verbose -Message ($script:localizedData.BringSqlServerAgentClusterResourcesOnline) -Verbose
$agentService | Invoke-CimMethod -MethodName BringOnline -Arguments @{ Timeout = $Timeout }
$agentService | Invoke-CimMethod -MethodName BringOnline -Arguments @{
Timeout = $Timeout
}
}
}
else
Expand Down
Loading

0 comments on commit c763ea0

Please sign in to comment.