]> insang Git - newton-cn_pos.git/blob
166a9175cb20e15671b5c208fe794465c1532915
[newton-cn_pos.git] /
1 #
2 # WaitForSome
3 #
4
5 #
6 # The Get-TargetResource cmdlet.
7 #
8 function Get-TargetResource
9 {
10     param
11     (
12         [parameter(Mandatory)]
13         [ValidateNotNullOrEmpty()]
14         [string] $ResourceName,
15
16         [parameter(Mandatory)]
17         [ValidateNotNullOrEmpty()]
18         [string[]] $NodeName,
19
20         [parameter(Mandatory)]
21         [Uint32] $NodeCount,
22         
23         [ValidateRange(1,[Uint64]::MaxValue)]
24         [Uint64] $RetryIntervalSec = 1, 
25
26         [Uint32] $RetryCount = 0,
27
28         [Uint32] $ThrottleLimit = 32 #Powershell New-CimSession default throttle value
29     )
30
31     Import-Module $PSScriptRoot\..\..\PSDSCxMachine.psm1 -Verbose:$false
32
33     $result = PSDSCxMachine\Get-_InternalPSDscXMachineTR `
34                -RemoteResourceId $ResourceName `
35                -RemoteMachine $NodeName `
36                -MinimalNumberOfMachineInState $NodeCount `
37                -RetryIntervalSec $RetryIntervalSec `
38                -RetryCount $RetryCount `
39                -ThrottleLimit $ThrottleLimit
40     $result.NodeCount = $NodeCount
41
42     $result
43 }
44
45 #
46 # The Set-TargetResource cmdlet.
47 #
48 function Set-TargetResource
49 {
50     param
51     (
52         [parameter(Mandatory)]
53         [ValidateNotNullOrEmpty()]
54         [string] $ResourceName,
55
56         [parameter(Mandatory)]
57         [ValidateNotNullOrEmpty()]
58         [string[]] $NodeName,
59
60         [parameter(Mandatory)]
61         [Uint32] $NodeCount,
62
63         [ValidateRange(1,[Uint64]::MaxValue)]
64         [Uint64] $RetryIntervalSec = 1, 
65
66         [Uint32] $RetryCount = 0,
67
68         [Uint32] $ThrottleLimit = 32 #Powershell New-CimSession default throttle value
69     )
70
71     Import-Module $PSScriptRoot\..\..\PSDSCxMachine.psm1 -Verbose:$false
72
73     PSDSCxMachine\Set-_InternalPSDscXMachineTR `
74                -RemoteResourceId $ResourceName `
75                -RemoteMachine $NodeName `
76                -MinimalNumberOfMachineInState $NodeCount `
77                -RetryIntervalSec $RetryIntervalSec `
78                -RetryCount $RetryCount `
79                -ThrottleLimit $ThrottleLimit `
80                -Verbose:$($PSBoundParameters["Verbose"] -eq $true)
81 }
82
83
84 # Test-TargetResource
85 #
86
87 function Test-TargetResource  
88 {
89     param
90     (
91         [parameter(Mandatory)]
92         [ValidateNotNullOrEmpty()]
93         [string] $ResourceName,
94
95         [parameter(Mandatory)]
96         [ValidateNotNullOrEmpty()]
97         [string[]] $NodeName,
98
99         [parameter(Mandatory)]
100         [Uint32] $NodeCount,
101         
102         [ValidateRange(1,[Uint64]::MaxValue)]
103         [Uint64] $RetryIntervalSec = 1, 
104
105         [Uint32] $RetryCount = 0,
106
107         [Uint32] $ThrottleLimit = 32 #Powershell New-CimSession default throttle value
108     )
109
110     if ($NodeCount -gt $NodeName.Count)
111     {
112         throw "Invalid input NodeCount!"
113     }
114
115     Import-Module $PSScriptRoot\..\..\PSDSCxMachine.psm1 -Verbose:$false
116
117     return PSDSCxMachine\Test-_InternalPSDscXMachineTR `
118                -RemoteResourceId $ResourceName `
119                -RemoteMachine $NodeName `
120                -MinimalNumberOfMachineInState $NodeCount `
121                -RetryIntervalSec $RetryIntervalSec `
122                -RetryCount $RetryCount `
123                -ThrottleLimit $ThrottleLimit `
124                -Verbose:$($PSBoundParameters["Verbose"] -eq $true)
125 }
126
127
128
129 Export-ModuleMember -Function *-TargetResource