Skip to content

Commit 79ab3ff

Browse files
committed
Moved common functions to separate module
1 parent ef7fb8e commit 79ab3ff

10 files changed

Lines changed: 94 additions & 109 deletions

File tree

build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
####################################################
55
CopyPaths:
66
- DSCResources
7+
- Modules
78
- en-US
89
Encoding: UTF8
910
VersionedOutputDirectory: true

source/DSCResources/MSFT_xCluster/MSFT_xCluster.psm1

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

@@ -501,30 +503,4 @@ function Close-UserToken
501503
}
502504
}
503505

504-
<#
505-
.SYNOPSIS
506-
This method is used to converted Distinguished Name to a Simple Name.
507-
508-
.PARAMETER CurrentValues
509-
Distinguished Name to be converted to a Simple Name
510-
#>
511-
512-
function Convert-DistinguishedNameToSimpleName {
513-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'returnValue')]
514-
[CmdletBinding()]
515-
[OutputType([string])]
516-
param
517-
(
518-
[Parameter(Mandatory = $true)]
519-
[string]
520-
$DistinguishedName
521-
)
522-
523-
$returnValue = $DistinguishedName
524-
525-
if ($DistinguishedName -match '^(\s*CN\s*=\w*)((\s*,\s*OU\s*=\w*)*)((\s*,\s*DC\s*=\w*)*)$') {
526-
$returnValue = ((($DistinguishedName -split ',')[0]) -split '=')[1]
527-
}
528-
529-
return $returnValue
530-
}
506+
Export-ModuleMember -Function *-TargetResource

source/DSCResources/MSFT_xClusterDisk/MSFT_xClusterDisk.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

source/DSCResources/MSFT_xClusterNetwork/MSFT_xClusterNetwork.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

source/DSCResources/MSFT_xClusterPreferredOwner/MSFT_xClusterPreferredOwner.psm1

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

@@ -314,30 +316,4 @@ function Test-TargetResource
314316
$result
315317
}
316318

317-
<#
318-
.SYNOPSIS
319-
This method is used to converted Distinguished Name to a Simple Name.
320-
321-
.PARAMETER CurrentValues
322-
Distinguished Name to be converted to a Simple Name
323-
#>
324-
325-
function Convert-DistinguishedNameToSimpleName {
326-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'returnValue')]
327-
[CmdletBinding()]
328-
[OutputType([string])]
329-
param
330-
(
331-
[Parameter(Mandatory = $true)]
332-
[string]
333-
$DistinguishedName
334-
)
335-
336-
$returnValue = $DistinguishedName
337-
338-
if ($DistinguishedName -match '^(\s*CN\s*=\w*)((\s*,\s*OU\s*=\w*)*)((\s*,\s*DC\s*=\w*)*)$') {
339-
$returnValue = ((($DistinguishedName -split ',')[0]) -split '=')[1]
340-
}
341-
342-
return $returnValue
343-
}
319+
Export-ModuleMember -Function *-TargetResource

source/DSCResources/MSFT_xClusterProperty/MSFT_xClusterProperty.psm1

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

@@ -404,32 +406,5 @@ function Test-TargetResource
404406
return $output
405407
}
406408

407-
<#
408-
.SYNOPSIS
409-
This method is used to converted Distinguished Name to a Simple Name.
410-
411-
.PARAMETER CurrentValues
412-
Distinguished Name to be converted to a Simple Name
413-
#>
414-
415-
function Convert-DistinguishedNameToSimpleName {
416-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'returnValue')]
417-
[CmdletBinding()]
418-
[OutputType([string])]
419-
param
420-
(
421-
[Parameter(Mandatory = $true)]
422-
[string]
423-
$DistinguishedName
424-
)
425-
426-
$returnValue = $DistinguishedName
427-
428-
if ($DistinguishedName -match '^(\s*CN\s*=\w*)((\s*,\s*OU\s*=\w*)*)((\s*,\s*DC\s*=\w*)*)$') {
429-
$returnValue = ((($DistinguishedName -split ',')[0]) -split '=')[1]
430-
}
431-
432-
return $returnValue
433-
}
434-
409+
Export-ModuleMember -Function *-TargetResource
435410
Export-ModuleMember -Function *-TargetResource

source/DSCResources/MSFT_xClusterQuorum/MSFT_xClusterQuorum.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

source/DSCResources/MSFT_xWaitForCluster/MSFT_xWaitForCluster.psm1

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
$script:failoverClusterHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\FailoverCluster.Common'
23

34
Import-Module -Name $script:resourceHelperModulePath
5+
Import-Module -Name $script:failoverClusterHelperModulePath
46

57
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
68

@@ -182,30 +184,4 @@ function Test-TargetResource
182184
$testTargetResourceReturnValue
183185
}
184186

185-
<#
186-
.SYNOPSIS
187-
This method is used to converted Distinguished Name to a Simple Name.
188-
189-
.PARAMETER CurrentValues
190-
Distinguished Name to be converted to a Simple Name
191-
#>
192-
193-
function Convert-DistinguishedNameToSimpleName {
194-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'returnValue')]
195-
[CmdletBinding()]
196-
[OutputType([string])]
197-
param
198-
(
199-
[Parameter(Mandatory = $true)]
200-
[string]
201-
$DistinguishedName
202-
)
203-
204-
$returnValue = $DistinguishedName
205-
206-
if ($DistinguishedName -match '^(\s*CN\s*=\w*)((\s*,\s*OU\s*=\w*)*)((\s*,\s*DC\s*=\w*)*)$') {
207-
$returnValue = ((($DistinguishedName -split ',')[0]) -split '=')[1]
208-
}
209-
210-
return $returnValue
211-
}
187+
Export-ModuleMember -Function *-TargetResource
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@{
2+
# Script module or binary module file associated with this manifest.
3+
RootModule = 'FailoverCluster.Common.psm1'
4+
5+
# Version number of this module.
6+
ModuleVersion = '1.0.0'
7+
8+
# ID used to uniquely identify this module
9+
GUID = '7ef908fb-3e4b-4807-a8d5-9a6ca6daadb1'
10+
11+
# Author of this module
12+
Author = 'DSC Community'
13+
14+
# Company or vendor of this module
15+
CompanyName = 'DSC Community'
16+
17+
# Copyright statement for this module
18+
Copyright = 'Copyright the DSC Community contributors. All rights reserved.'
19+
20+
# Description of the functionality provided by this module
21+
Description = 'Functions used by the DSC resources in xFailoverCluster.'
22+
23+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
24+
FunctionsToExport = @(
25+
'Convert-DistinguishedNameToSimpleName'
26+
)
27+
28+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
29+
CmdletsToExport = @()
30+
31+
# Variables to export from this module
32+
VariablesToExport = @()
33+
34+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
35+
AliasesToExport = @()
36+
37+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
38+
PrivateData = @{
39+
PSData = @{
40+
} # End of PSData hashtable
41+
} # End of PrivateData hashtable
42+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
$script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common'
2+
3+
Import-Module -Name $script:resourceHelperModulePath
4+
5+
$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'
6+
7+
<#
8+
.SYNOPSIS
9+
This method is used to converted Distinguished Name to a Simple Name.
10+
11+
.PARAMETER CurrentValues
12+
Distinguished Name to be converted to a Simple Name
13+
#>
14+
15+
function Convert-DistinguishedNameToSimpleName {
16+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'returnValue')]
17+
[CmdletBinding()]
18+
[OutputType([string])]
19+
param
20+
(
21+
[Parameter(Mandatory = $true)]
22+
[string]
23+
$DistinguishedName
24+
)
25+
26+
$returnValue = $DistinguishedName
27+
28+
if ($DistinguishedName -match '^(\s*CN\s*=\w*)((\s*,\s*OU\s*=\w*)*)((\s*,\s*DC\s*=\w*)*)$') {
29+
$returnValue = ((($DistinguishedName -split ',')[0]) -split '=')[1]
30+
}
31+
32+
return $returnValue
33+
}

0 commit comments

Comments
 (0)