-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbringOnline.ps1
48 lines (43 loc) · 1.18 KB
/
bringOnline.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$hstnm = hostname
$broughtOnline = $false
$nodeReachable = $false
$retryCount = 180 # retry 15 minutes
while (!$broughtOnline -and $retryCount -gt 0) {
try {
Add-PSSnapin microsoft.hpc
Write-Output "HPC PSSnapin loaded."
$node = Get-HpcNode -Name $hstnm
Set-HpcNodeState -Node $node -State online
$broughtOnline = $true
}
catch {
$broughtOnline = $false
$retryCount--
$_
Write-Output "Wait for 5 secs and then retry"
Start-Sleep 5
}
}
Write-Output "Brought node online. Waiting for node being reachable."
$retryCount = 180
$okState = [Microsoft.ComputeCluster.CCPPSH.NodeHealthState]::OK
while ($broughtOnline -and !$nodeReachable -and $retryCount -gt 0) {
try {
$node = Get-HpcNode -Name $hstnm
$nodeState = $node.HealthState
if ($nodeState -eq $okState) {
$nodeReachable = $true
}
else {
Start-Sleep 5
}
}
catch {
$nodeReachable = $false
$retryCount--
$_
Write-Output "Wait for 5 secs and then retry"
Start-Sleep 5
}
}
schtasks /delete /tn mesoshpconline /f