Skip to content

Commit b9740bb

Browse files
committed
Started adding HA function (WIP)
1 parent 04f9d5c commit b9740bb

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed

NetScaler/NetScaler.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ FunctionsToExport = @(
9292
'Disable-NSLBVirtualServer',
9393
'Disable-NSMode',
9494
'Disconnect-NetScaler',
95+
'Enable-NSHighAvailability',
9596
'Enable-NSFeature',
9697
'Enable-NSLBMonitor',
9798
'Enable-NSLBServer',

NetScaler/Private/_AssertSessionActive.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ limitations under the License.
1515
#>
1616

1717
function _AssertSessionActive {
18-
$s = $script:session
19-
if ($null -eq $s ) {
18+
param(
19+
$Session = $script:session
20+
)
21+
22+
if ($null -eq $session) {
2023
throw 'Must be logged into NetScaler appliance first!'
2124
}
2225
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<#
2+
Copyright 2017 Dominique Broeglin
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
#>
16+
17+
function Enable-NSHighAvailability {
18+
<#
19+
.SYNOPSIS
20+
Enable high-availability between two NetScaler instances.
21+
22+
.DESCRIPTION
23+
Enable high-availability between two NetScaler instances.
24+
25+
.EXAMPLE
26+
Enable-NSHighAvailability -PrimarySession $ns1 -SecondarySession Session $ns2
27+
28+
Enable high-availability between the netscaler instances corresponding to
29+
the already opened $ns1 and $ns2.
30+
31+
.PARAMETER PrimarySession
32+
The NetScaler session object for the first NetScaler instance (will end up master).
33+
34+
.PARAMETER SecondarySession
35+
The NetScaler session object for the second NetScaler instance (will end up slave).
36+
37+
.PARAMETER PeerNodeId
38+
The node id used to denote the peer.
39+
40+
Default value: 1
41+
42+
.PARAMETER Force
43+
Suppress confirmation when activating high-availability.
44+
#>
45+
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact='High')]
46+
param(
47+
[parameter(Mandatory)]
48+
$PrimarySession,
49+
50+
[parameter(Mandatory)]
51+
$SecondarySession,
52+
53+
[int]$PeerNodeId = 1,
54+
55+
[switch]$Force
56+
)
57+
58+
begin {
59+
_AssertSessionActive -Session $PrimarySession
60+
_AssertSessionActive -Session $SecondarySession
61+
}
62+
63+
process {
64+
if ($Force -or $PSCmdlet.ShouldProcess($item, 'Enable high-availability')) {
65+
try {
66+
67+
68+
} catch {
69+
throw $_
70+
}
71+
}
72+
}
73+
}

NetScaler/Public/Get-NSConfig.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ function Get-NSConfig {
5858
} else {
5959
$Config = (_InvokeNSRestApi -Session $Session -Method Get -Type nssavedconfig -Action GetAll).nssavedconfig.textblob
6060
}
61-
$Config -Split '\n' | ? { $_ -and !($_ -match "^( Done| *#)") }
61+
$Config -Split '\n' | Where-Object { $_ -and !($_ -match "^( Done| *#)") }
6262
}
6363
}

0 commit comments

Comments
 (0)