Skip to content

Commit e90a5ad

Browse files
committed
Merge pull request heyzua#2 from clarenceb/master
Some bug fixes and ability to enable/disable individual services in a servicegroup
2 parents e4bc95a + 1bbd30c commit e90a5ad

4 files changed

Lines changed: 42 additions & 6 deletions

File tree

‎lib/netscaler/cli.rb‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,17 @@ def servicegroups
214214
end
215215
end
216216
end
217+
string :servername, "The name of the server that an individual service runs on (used when scoping the action to an individual service in a service group)." do
218+
depends_on :action
219+
end
220+
string :port, "The port number that an individual service in bound to (used when scoping the action to an individual service in a service group)." do
221+
depends_on :action
222+
end
223+
end
224+
string :delay, "The delay (in seconds) to wait before disabled services transition to Out of Service. Default is 0 seconds (immediately)." do
225+
depends_on :action
226+
default "0"
227+
end
217228
arguments do
218229
count 0..1 #:at_least => 0, :at_most => 1
219230
metaname '[SERVICEGROUP]'

‎lib/netscaler/servicegroup/request.rb‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ module Netscaler::ServiceGroup
55
class Request < Netscaler::BaseRequest
66
def enable(service, options)
77
params = { :servicegroupname => service }
8+
[:servername, :port].each do |option|
9+
params[option] = options[option] if options[option]
10+
end
811
send_request('enableservicegroup', params)
912
end
1013

1114
def disable(servicegroup, options)
12-
params = {
13-
:servicegroupname => servicename,
14-
:delay => 0
15-
}
15+
params = { :servicegroupname => servicegroup }
16+
[:servername, :port, :delay].each do |option|
17+
params[option] = options[option] if options[option]
18+
end
1619
send_request('disableservicegroup', params)
1720
end
1821

‎lib/netscaler/servicegroup/response.rb‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def initialize(raw_response, index)
6060
@ip_address = @ip_address[index]
6161
@state = @state[index]
6262
@port = @port[index]
63-
@type = @type[index]
6463
end
6564
end
6665

‎spec/netscaler/cli_spec.rb‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def parse(*args)
161161
res.subresults[0].args[0].should eql('a-service-group')
162162
end
163163

164-
it "should succed in setting the vserver name" do
164+
it "should succeed in setting the vserver name" do
165165
res = parse('-n', 'else', 'servicegroup', '-a', 'bind', '-v', 'blah', 'a-service-group')
166166
res.subresults[0][:vserver].should eql('blah')
167167
end
@@ -175,6 +175,29 @@ def parse(*args)
175175
res = parse('-n', 'else', 'servicegroup', 'a-service-group')
176176
res.subresults[0][:action].should eql(:status)
177177
end
178+
179+
describe "scoping to an individual service" do
180+
before :each do
181+
@res = parse('-n', 'else', 'servicegroup', '-a', 'enable', 'a-service-group', '-s', 'a-server-name', '-p', '8080', '-d', '180')
182+
end
183+
184+
it "should set the servername to a-server-name" do
185+
@res.subresults[0][:servername].should eql('a-server-name')
186+
end
187+
188+
it "should set the port to 8080" do
189+
@res.subresults[0][:port].should eql('8080')
190+
end
191+
192+
it "should set the delay to 180" do
193+
@res.subresults[0][:delay].should eql('180')
194+
end
195+
196+
it "should set the delay to 0 if not specified" do
197+
@res = parse('-n', 'else', 'servicegroup', '-a', 'enable', 'a-service-group', '-s', 'a-server-name', '-p', '8080')
198+
@res.subresults[0][:delay].should eql('0')
199+
end
200+
end
178201
end
179202

180203
end

0 commit comments

Comments
 (0)