netscaler-cli 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gem 'log4r', '~> 1.1'
4
4
  gem 'savon', '~> 0.7.0'
5
5
  gem 'highline', '>= 1.6'
6
6
  gem 'choosy', '~> 0.2'
7
+ gem 'json_pure', '~> 1.5.1', :require => 'json'
7
8
 
8
9
  group :development do
9
10
  gem 'rspec', :require => "spec"
data/Gemfile.lock CHANGED
@@ -7,10 +7,12 @@ GEM
7
7
  autotest-notification (2.3.1)
8
8
  autotest (~> 4.3)
9
9
  builder (3.0.0)
10
- choosy (0.2.3)
10
+ choosy (0.2.5)
11
11
  crack (0.1.8)
12
12
  diff-lcs (1.1.2)
13
13
  highline (1.6.1)
14
+ hirb (0.4.0)
15
+ json_pure (1.5.1)
14
16
  log4r (1.1.9)
15
17
  rspec (2.5.0)
16
18
  rspec-core (~> 2.5.0)
@@ -32,6 +34,8 @@ DEPENDENCIES
32
34
  autotest-notification
33
35
  choosy (~> 0.2)
34
36
  highline (>= 1.6)
37
+ hirb (~> 0.4.0)
38
+ json_pure (~> 1.5.1)
35
39
  log4r (~> 1.1)
36
40
  rspec
37
41
  savon (~> 0.7.0)
data/etc/Version CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.5.0
@@ -30,7 +30,10 @@ module Netscaler
30
30
  soap.body = body
31
31
  end
32
32
 
33
- log.debug(result)
33
+ if log.debug?
34
+ require 'pp'
35
+ PP::pp(result.to_hash, $stderr, 80)
36
+ end
34
37
 
35
38
  response = result.to_hash["#{name.to_s}_response".to_sym]
36
39
  msg = response[:return][:message]
data/lib/netscaler/cli.rb CHANGED
@@ -5,6 +5,7 @@ require 'netscaler/executor'
5
5
  require 'netscaler/server/request'
6
6
  require 'netscaler/vserver/request'
7
7
  require 'netscaler/service/request'
8
+ require 'netscaler/servicegroup/request'
8
9
  require 'choosy'
9
10
 
10
11
  module Netscaler
@@ -35,7 +36,7 @@ module Netscaler
35
36
 
36
37
  protected
37
38
  def command
38
- cmds = [servers, vservers, services]
39
+ cmds = [vservers, servers, services, servicegroups]
39
40
  @command ||= Choosy::SuperCommand.new :netscaler do
40
41
  printer :standard, :color => true, :headers => [:bold, :blue], :max_width => 80
41
42
 
@@ -47,7 +48,7 @@ module Netscaler
47
48
  alias: is_optional
48
49
  usernamd: is_required
49
50
  password: is_optional_but_querried_if_not_found"
50
-
51
+
51
52
  # COMMANDS
52
53
  header 'Commands:'
53
54
  cmds.each do |cmd|
@@ -98,7 +99,7 @@ module Netscaler
98
99
  end
99
100
  arguments do
100
101
  count 0..1 #:at_least => 0, :at_most => 1
101
- metaname 'SERVER'
102
+ metaname '[SERVER]'
102
103
  validate do |args, options|
103
104
  if args.length == 0
104
105
  die "no server given to act upon" unless options[:action] == :list
@@ -147,7 +148,7 @@ module Netscaler
147
148
  end
148
149
  arguments do
149
150
  count 0..1 #:at_least => 0, :at_most => 1
150
- metaname 'SERVER'
151
+ metaname '[SERVER]'
151
152
  validate do |args, options|
152
153
  if args.length == 0
153
154
  die "no virtual server given to act upon" unless options[:action] == :list
@@ -181,7 +182,7 @@ module Netscaler
181
182
  end
182
183
  arguments do
183
184
  count 0..1 #:at_least => 0, :at_most => 1
184
- metaname 'SERVICE'
185
+ metaname '[SERVICE]'
185
186
  validate do |args, options|
186
187
  if args.length == 0
187
188
  die "no services given to act on" unless options[:action] == :list
@@ -191,6 +192,40 @@ module Netscaler
191
192
  end
192
193
  end
193
194
 
195
+ def servicegroups
196
+ Choosy::Command.new :servicegroup do
197
+ executor Netscaler::Executor.new(Netscaler::ServiceGroup::Request)
198
+ summary "Enables, disables, binds or unbinds from a virtual server, a given service group."
199
+ header 'Description:'
200
+ para "This is a tool for enabling and disabling service groups in a Netscaler load balancer. The name of the service group is required, as is the address of the Netscaler load balancer."
201
+
202
+ header 'Options:'
203
+ enum :action, [:enable, :disable, :bind, :unbind, :status], "Either [enable, disable, bind, unbind, status] of a service group. 'bind' and 'unbind' require the '--vserver' flag. Default is 'status'." do
204
+ default :status
205
+ end
206
+ string :vserver, "The virtual server to bind/unbind this service to/from." do
207
+ depends_on :action
208
+ default :unset
209
+ validate do |arg, options|
210
+ if [:bind, :unbind].include?(options[:action])
211
+ die "requires the -v/--vserver flag" if arg == :unset
212
+ else
213
+ die "only used with bind/unbind" unless arg == :unset
214
+ end
215
+ end
216
+ end
217
+ arguments do
218
+ count 0..1 #:at_least => 0, :at_most => 1
219
+ metaname '[SERVICEGROUP]'
220
+ validate do |args, options|
221
+ if args.length == 0
222
+ die "no service group given to act on" unless options[:action] == :list
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
228
+
194
229
  private
195
230
  def print_error(e)
196
231
  STDERR.puts "#{File.basename($0)}: #{e}"
@@ -1,7 +1,7 @@
1
1
  require 'netscaler/errors'
2
2
  require 'netscaler/logging'
3
3
  require 'netscaler/transaction'
4
- require 'netscaler/extensions'
4
+ require 'json'
5
5
 
6
6
  module Netscaler
7
7
  class Executor
@@ -16,16 +16,10 @@ module Netscaler
16
16
  Netscaler::Transaction.new options[:netscaler] do |client|
17
17
  @request_class.new(client).send(options[:action], args[0], options) do |response|
18
18
  if options[:json]
19
- puts response.to_json
19
+ puts JSON.pretty_generate(response)
20
20
  else
21
- if response.is_a?(Array)
22
- if response.length > 0
23
- puts response[0].header
24
- end
25
- else
26
- puts response.header
27
- end
28
- puts response.to_s
21
+ STDERR.puts "Tempoararily disabled stdout. Use --json instead. Sorry...."
22
+ # puts Hirb::Helpers::Tree.render(response)
29
23
  end
30
24
  end
31
25
  end
@@ -15,7 +15,7 @@ module Netscaler::Server
15
15
  responses = []
16
16
  send_request('getserver', {:empty => :ok}) do |response|
17
17
  response_part(response).each_with_index do |server, i|
18
- responses << Response.new(server)
18
+ responses << Response.new(server).to_hash
19
19
  end
20
20
  end
21
21
  yield responses if block_given?
@@ -23,7 +23,7 @@ module Netscaler::Server
23
23
 
24
24
  def status(server, options)
25
25
  send_request('getserver', {:name => server }) do |response|
26
- yield Response.new(response_part(response)) if block_given?
26
+ yield Response.new(response_part(response)).to_hash if block_given?
27
27
  end
28
28
  end
29
29
 
@@ -1,67 +1,46 @@
1
1
  module Netscaler::Server
2
2
  class Response
3
- FORMAT = "%-30s %15s %10s"
4
-
5
- attr_reader :info
6
-
7
3
  def initialize(raw_response)
8
4
  @info = raw_response
9
5
  end
10
6
 
11
7
  def name
12
- info[:name]
8
+ @info[:name]
13
9
  end
14
10
 
15
11
  def ip_address
16
- info[:ipaddress]
12
+ @info[:ipaddress]
17
13
  end
18
14
 
19
15
  def state
20
- info[:state]
21
- end
22
-
23
- def header
24
- line = sprintf FORMAT, 'Name', 'IP Address', 'State'
25
- eqls = '=' * line.length
26
- line + "\n" + eqls
16
+ @info[:state]
27
17
  end
28
18
 
29
19
  def services
30
- if info[:servicename]
31
- res = info[:servicename][:item]
32
- if !res.is_a?(Array)
33
- [res]
34
- else
35
- res
36
- end
37
- else
38
- []
39
- end
40
- end
20
+ @services ||= if @info[:servicename]
21
+ res = @info[:servicename][:item]
22
+ if res.is_a?(Array)
23
+ res
24
+ else
25
+ [res]
26
+ end
27
+ else
28
+ []
29
+ end
30
+ end
31
+
32
+ def to_hash
33
+ hash = {
34
+ :name => name,
35
+ :ip_address => ip_address,
36
+ :state => state,
37
+ }
41
38
 
42
- def to_s
43
- base = sprintf FORMAT, name, ip_address, state
44
39
  if !services.empty?
45
- base << "\n"
46
- services.each do |s|
47
- base << "| service: #{s}\n"
48
- end
40
+ hash[:services] = services
49
41
  end
50
- base
51
- end
52
42
 
53
- def to_json(prefix=nil)
54
- indent = if prefix
55
- prefix + " "
56
- else
57
- " "
58
- end
59
- base = "{\n#{indent}'name': '#{name}',\n#{indent}'ip_address': '#{ip_address}',\n#{indent}'state': '#{state}'"
60
- if !services.empty?
61
- base << ",\n#{indent}'services':\n#{services.to_json(indent)}"
62
- end
63
- base.chomp!
64
- base << "\n#{prefix}}"
43
+ hash
65
44
  end
66
45
  end
67
46
  end
@@ -35,7 +35,7 @@ module Netscaler::Service
35
35
  def status(service, options)
36
36
  params = { :name => service }
37
37
  send_request('getservice', params) do |response|
38
- yield Response.new(response) if block_given?
38
+ yield Response.new(response).to_hash if block_given?
39
39
  end
40
40
  end
41
41
  end
@@ -1,7 +1,5 @@
1
1
  module Netscaler::Service
2
2
  class Response
3
- FORMAT = "%-30s %15s %10s %10s"
4
-
5
3
  def initialize(raw_response)
6
4
  @info = raw_response[:return][:list][:item]
7
5
  end
@@ -19,26 +17,20 @@ module Netscaler::Service
19
17
  end
20
18
 
21
19
  def port
22
- @info[:port]
20
+ @info[:port].to_i
23
21
  end
24
22
 
25
- def header
26
- line = sprintf FORMAT, 'Name', 'IP Address', 'State', 'Port'
27
- eqls = '=' * line.length
28
- line + "\n" + eqls
29
- end
30
-
31
- def to_s
32
- sprintf FORMAT, name, ip_address, state, port
23
+ def server
24
+ @info[:servername]
33
25
  end
34
26
 
35
- def to_json(prefix=nil)
36
- indent = if prefix
37
- ' ' + prefix
38
- else
39
- ' '
40
- end
41
- "{\n#{indent}'name': '#{name}',\n#{indent}'ip_address': '#{ip_address}',\n#{indent}'state': '#{state}',\n#{indent}'port': #{port}\n#{prefix}}"
27
+ def to_hash
28
+ { :name => name,
29
+ :server => server,
30
+ :ip_address => ip_address,
31
+ :state => state,
32
+ :port => port
33
+ }
42
34
  end
43
35
  end
44
36
  end
@@ -0,0 +1,43 @@
1
+ require 'netscaler/base_request'
2
+ require 'netscaler/servicegroup/response'
3
+
4
+ module Netscaler::ServiceGroup
5
+ class Request < Netscaler::BaseRequest
6
+ def enable(service, options)
7
+ params = { :servicegroupname => service }
8
+ send_request('enableservicegroup', params)
9
+ end
10
+
11
+ def disable(servicegroup, options)
12
+ params = {
13
+ :servicegroupname => servicename,
14
+ :delay => 0
15
+ }
16
+ send_request('disableservicegroup', params)
17
+ end
18
+
19
+ def bind(servicegroup, options)
20
+ params = {
21
+ :name => options[:vserver],
22
+ :servicegroupname => servicegroup
23
+ }
24
+ send_request('bindlbvserver_servicegroup', params)
25
+ end
26
+
27
+ def unbind(servicegroup, options)
28
+ params = {
29
+ :name => options[:vserver],
30
+ :servicename => servicegroup
31
+ }
32
+ send_request('unbindlbvserver_servicegroup', params)
33
+ end
34
+
35
+ def status(servicegroup, options)
36
+ params = { :servicegroupname => servicegroup }
37
+ send_request('getservicegroup', params) do |response|
38
+ yield Response.new(response).to_hash if block_given?
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,79 @@
1
+ module Netscaler::ServiceGroup
2
+ class Response
3
+ def initialize(raw_response)
4
+ @info = raw_response[:return][:list][:item]
5
+ end
6
+
7
+ def name
8
+ @info[:servicegroupname]
9
+ end
10
+
11
+ def state
12
+ @info[:state]
13
+ end
14
+
15
+ def type
16
+ @info[:servicetype]
17
+ end
18
+
19
+ def servers
20
+ @parsed_servers ||= []
21
+ return @parsed_servers if !@parsed_servers.empty? || @info[:servername].nil?
22
+
23
+ if @info[:servername][:item].is_a?(String)
24
+ @parsed_servers << ServerInfo.new(@info, nil)
25
+ else
26
+ @info[:servername][:item].each_with_index do |name, i|
27
+ @parsed_servers << ServerInfo.new(@info, i)
28
+ end
29
+ end
30
+
31
+ @parsed_servers
32
+ end
33
+
34
+ def to_hash
35
+ hash = {
36
+ :name => name,
37
+ :state => state,
38
+ :type => type,
39
+ }
40
+
41
+ if !servers.empty?
42
+ hash[:servers] = servers.map {|s| s.to_hash}
43
+ end
44
+
45
+ hash
46
+ end
47
+ end
48
+
49
+ class ServerInfo
50
+ attr_reader :name, :ip_address, :state
51
+
52
+ def initialize(raw_response, index)
53
+ @name = raw_response[:servername][:item]
54
+ @ip_address = raw_response[:ipaddress][:item]
55
+ @state = raw_response[:svcstate][:item]
56
+ @port = raw_response[:port][:item]
57
+
58
+ if !index.nil?
59
+ @name = @name[index]
60
+ @ip_address = @ip_address[index]
61
+ @state = @state[index]
62
+ @port = @port[index]
63
+ @type = @type[index]
64
+ end
65
+ end
66
+
67
+ def port
68
+ @port.to_i
69
+ end
70
+
71
+ def to_hash
72
+ { :name => name,
73
+ :ip_address => ip_address,
74
+ :state => state,
75
+ :port => port
76
+ }
77
+ end
78
+ end
79
+ end
@@ -20,7 +20,7 @@ module Netscaler::VServer
20
20
  vservers = []
21
21
  send_request('getlbvserver', {:empty => :ok}) do |response|
22
22
  response[:return][:list][:item].each do |vserver|
23
- vservers << Response.new(vserver)
23
+ vservers << Response.new(vserver).to_hash
24
24
  end
25
25
  end
26
26
  yield vservers if block_given?
@@ -29,7 +29,7 @@ module Netscaler::VServer
29
29
  def status(vserver, options)
30
30
  params = { :name => vserver }
31
31
  send_request('getlbvserver', params) do |response|
32
- yield Response.new(response) if block_given?
32
+ yield Response.new(response).to_hash if block_given?
33
33
  end
34
34
  end
35
35
 
@@ -1,10 +1,5 @@
1
-
2
1
  module Netscaler::VServer
3
2
  class Response
4
- FORMAT = "%-47s %15s %15s %10s %10s"
5
-
6
- attr_reader :info
7
-
8
3
  def initialize(raw_response)
9
4
  @info = if raw_response[:return]
10
5
  raw_response[:return][:list][:item]
@@ -14,84 +9,62 @@ module Netscaler::VServer
14
9
  end
15
10
 
16
11
  def name
17
- info[:name]
12
+ @info[:name]
18
13
  end
19
14
 
20
15
  def ip_address
21
- if info[:ipaddress] =~ /0\.0\.0\.0/
22
- info[:ipaddress2]
16
+ if @info[:ipaddress] =~ /0\.0\.0\.0/
17
+ @info[:ipaddress2]
23
18
  else
24
- info[:ipaddress]
19
+ @info[:ipaddress]
25
20
  end
26
21
  end
27
22
 
28
23
  def type
29
- info[:servicetype]
24
+ @info[:servicetype]
30
25
  end
31
26
 
32
27
  def port
33
- info[:port]
28
+ @info[:port].to_i
34
29
  end
35
30
 
36
31
  def state
37
- info[:state]
32
+ @info[:state]
38
33
  end
39
34
 
40
- def header
41
- line = sprintf FORMAT, 'Name', 'IP Address', 'State', 'Port', 'Type'
42
- eqls = '=' * line.length
43
- line + "\n" + eqls
44
- end
35
+ def services
36
+ @parsed_services ||= []
37
+ return @parsed_services if !@parsed_services.empty? || @info[:servicename].nil?
45
38
 
46
- def servers
47
- @parsed_servers ||= []
48
- if !@parsed_servers.empty? || info[:servicename].nil?
49
- return @parsed_servers
50
- end
51
-
52
- if info[:servicename][:item].is_a?(String)
53
- @parsed_servers << ServerInfo.new(info, nil)
39
+ if @info[:servicename][:item].is_a?(String)
40
+ @parsed_services << ServiceInfo.new(info, nil)
54
41
  else
55
- info[:servicename][:item].each_with_index do |name, i|
56
- @parsed_servers << ServerInfo.new(info, i)
57
- end
58
- end
59
-
60
- @parsed_servers
61
- end
62
-
63
- def to_s
64
- base = sprintf FORMAT, name, ip_address, state, port, type
65
-
66
- if !servers.empty?
67
- base << "\n"
68
- servers.each do |server|
69
- base << "|> server: #{server}\n"
42
+ @info[:servicename][:item].each_with_index do |name, i|
43
+ @parsed_services << ServiceInfo.new(info, i)
70
44
  end
71
45
  end
72
46
 
73
- base
47
+ @parsed_services
74
48
  end
75
49
 
76
- def to_json(prefix=nil)
77
- indent = if prefix
78
- ' ' + prefix
79
- else
80
- ' '
81
- end
82
- base = "{\n#{indent}'name': '#{name}',\n#{indent}'ip_address': '#{ip_address}',\n#{indent}'state': '#{state}',\n#{indent}'port': #{port},\n#{indent}'type': '#{type}'"
50
+ def to_hash
51
+ hash = { :name => name,
52
+ :ip_address => ip_address,
53
+ :state => state,
54
+ :port => port,
55
+ :type => type,
56
+ }
83
57
 
84
- if !servers.empty?
85
- base << ",\n#{indent}'servers':\n#{servers.to_json(indent)}"
58
+ if !services.empty?
59
+ hash[:services] = services.map {|s| s.to_hash}
86
60
  end
87
-
88
- base << "\n#{prefix}}"
89
- base
61
+
62
+ hash
90
63
  end
91
64
  end
92
65
 
93
- class ServerInfo
94
- attr_accessor :name, :ip_address, :state, :port, :type
66
+ class ServiceInfo
67
+ attr_accessor :name, :ip_address, :state, :type
95
68
 
96
69
  def initialize(raw_response, index)
97
70
  @name = raw_response[:servicename][:item]
@@ -109,17 +82,17 @@ module Netscaler::VServer
109
82
  end
110
83
  end
111
84
 
112
- def to_s
113
- sprintf "%-26s %15s %18s %10s %10s", name, ip_address, state, port, type
85
+ def port
86
+ @port.to_i
114
87
  end
115
88
 
116
- def to_json(prefix=nil)
117
- indent = if prefix
118
- ' ' + prefix
119
- else
120
- ' '
121
- end
122
- "{\n#{indent}'name': '#{name}',\n#{indent}'ip_address': '#{ip_address}',\n#{indent}'state': '#{state}',\n#{indent}'port': #{port},\n#{indent}'type': '#{type}'\n#{prefix}}"
89
+ def to_hash
90
+ { :name => name,
91
+ :ip_address => ip_address,
92
+ :state => state,
93
+ :port => port,
94
+ :type => type
95
+ }
123
96
  end
124
97
  end
125
98
  end
@@ -55,6 +55,48 @@ module Netscaler
55
55
  end
56
56
  end
57
57
 
58
+ describe "for vserver" do
59
+ it "should fail when the vserver is given to a non-list option" do
60
+ attempting {
61
+ parse('-n', 'else', 'vserver', '-a', 'disable')
62
+ }.should raise_error(Choosy::ValidationError, /no virtual server/)
63
+ end
64
+
65
+ it "should fail when the --policy flag is unset on a bind/unbind" do
66
+ attempting {
67
+ parse('-n', 'else', 'vserver', '-a', 'bind', 'vserv')
68
+ }.should raise_error(Choosy::ValidationError, /required by the 'bind\/unbind' actions/)
69
+ end
70
+
71
+ it "should fail when the --policy flag is used on anything other than bind/unbind" do
72
+ attempting {
73
+ parse('-n', 'else', 'vserver', '-a', 'disable', '-p', 'pol', 'vserv')
74
+ }.should raise_error(Choosy::ValidationError, /only used with bind/)
75
+ end
76
+
77
+ it "should fail when priority flag is used on anything other than a bind" do
78
+ attempting {
79
+ parse('-n', 'else', 'vserver', '-a', 'disable', '-P', '20', 'vserv')
80
+ }.should raise_error(Choosy::ValidationError, /only used with the bind action/)
81
+ end
82
+
83
+ it "should set the default value for the priority to 100" do
84
+ res = parse('-n', 'else', 'vserver', '-a', 'bind', '-p', 'pol', 'vserv')
85
+ res.subresults[0][:Priority].should eql(100)
86
+ end
87
+
88
+ it "should set the policy name" do
89
+ res = parse('-n', 'else', 'vserver', '-a', 'bind', '-p', 'pol', 'vserv')
90
+ res.subresults[0][:policy].should eql('pol')
91
+ end
92
+
93
+ it "should fail on a bad action" do
94
+ attempting {
95
+ parse('-n', 'else', 'vserver', '-a', 'asdf', 'vserv')
96
+ }.should raise_error(Choosy::ValidationError, /unrecognized value/)
97
+ end
98
+ end
99
+
58
100
  describe "for services" do
59
101
  it "should fail when the service is given to a non-list action" do
60
102
  attempting {
@@ -95,46 +137,45 @@ module Netscaler
95
137
  end
96
138
  end
97
139
 
98
- describe "for vserver" do
99
- it "should fail when the vserver is given to a non-list option" do
140
+ describe "for servicegroups" do
141
+ it "should fail when the service is given to a non-list action" do
100
142
  attempting {
101
- parse('-n', 'else', 'vserver', '-a', 'disable')
102
- }.should raise_error(Choosy::ValidationError, /no virtual server/)
143
+ parse('-n', 'else', 'servicegroup', '-a', 'disable')
144
+ }.should raise_error(Choosy::ValidationError, /no service group given to act/)
103
145
  end
104
-
105
- it "should fail when the --policy flag is unset on a bind/unbind" do
146
+
147
+ it "should fail when --vserver flag is used with a non-bind/unbind action" do
106
148
  attempting {
107
- parse('-n', 'else', 'vserver', '-a', 'bind', 'vserv')
108
- }.should raise_error(Choosy::ValidationError, /required by the 'bind\/unbind' actions/)
149
+ parse('-n', 'else', 'servicegroup', '-a', 'disable', '-v', 'blarg', 'a-service-group')
150
+ }.should raise_error(Choosy::ValidationError, /only used with bind/)
109
151
  end
110
152
 
111
- it "should fail when the --policy flag is used on anything other than bind/unbind" do
153
+ it "should fail when the --vserver flag is not present with the bind/unbind action" do
112
154
  attempting {
113
- parse('-n', 'else', 'vserver', '-a', 'disable', '-p', 'pol', 'vserv')
114
- }.should raise_error(Choosy::ValidationError, /only used with bind/)
155
+ parse('-n', 'else', 'servicegroup', '-a', 'bind', 'a-service-group')
156
+ }.should raise_error(Choosy::ValidationError, /requires the -v\/--vserver flag/)
115
157
  end
116
158
 
117
- it "should fail when priority flag is used on anything other than a bind" do
118
- attempting {
119
- parse('-n', 'else', 'vserver', '-a', 'disable', '-P', '20', 'vserv')
120
- }.should raise_error(Choosy::ValidationError, /only used with the bind action/)
159
+ it "should succeed in setting the service name as an argument" do
160
+ res = parse('-n', 'else', 'servicegroup', '-a', 'bind', '-v', 'blah', 'a-service-group')
161
+ res.subresults[0].args[0].should eql('a-service-group')
121
162
  end
122
163
 
123
- it "should set the default value for the priority to 100" do
124
- res = parse('-n', 'else', 'vserver', '-a', 'bind', '-p', 'pol', 'vserv')
125
- res.subresults[0][:Priority].should eql(100)
164
+ it "should succed in setting the vserver name" do
165
+ res = parse('-n', 'else', 'servicegroup', '-a', 'bind', '-v', 'blah', 'a-service-group')
166
+ res.subresults[0][:vserver].should eql('blah')
126
167
  end
127
168
 
128
- it "should set the policy name" do
129
- res = parse('-n', 'else', 'vserver', '-a', 'bind', '-p', 'pol', 'vserv')
130
- res.subresults[0][:policy].should eql('pol')
169
+ it "should succeed in setting the action" do
170
+ res = parse('-n', 'else', 'servicegroup', '-a', 'bind', '-v', 'blah', 'a-service-group')
171
+ res.subresults[0][:action].should eql(:bind)
131
172
  end
132
173
 
133
- it "should fail on a bad action" do
134
- attempting {
135
- parse('-n', 'else', 'vserver', '-a', 'asdf', 'vserv')
136
- }.should raise_error(Choosy::ValidationError, /unrecognized value/)
174
+ it "should set the default action to status" do
175
+ res = parse('-n', 'else', 'servicegroup', 'a-service-group')
176
+ res.subresults[0][:action].should eql(:status)
137
177
  end
138
178
  end
179
+
139
180
  end
140
181
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netscaler-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-03-16 00:00:00.000000000 -07:00
12
+ date: 2011-03-18 00:00:00.000000000 -07:00
13
13
  default_executable: netscaler
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: log4r
17
- requirement: &73549750 !ruby/object:Gem::Requirement
17
+ requirement: &76829760 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '1.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *73549750
25
+ version_requirements: *76829760
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: savon
28
- requirement: &73549450 !ruby/object:Gem::Requirement
28
+ requirement: &76829510 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *73549450
36
+ version_requirements: *76829510
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: highline
39
- requirement: &73549150 !ruby/object:Gem::Requirement
39
+ requirement: &76829270 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '1.6'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *73549150
47
+ version_requirements: *76829270
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: choosy
50
- requirement: &73548850 !ruby/object:Gem::Requirement
50
+ requirement: &76829030 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,21 @@ dependencies:
55
55
  version: '0.2'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *73548850
58
+ version_requirements: *76829030
59
+ - !ruby/object:Gem::Dependency
60
+ name: json_pure
61
+ requirement: &76828790 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.5.1
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: *76828790
59
70
  - !ruby/object:Gem::Dependency
60
71
  name: rspec
61
- requirement: &73548550 !ruby/object:Gem::Requirement
72
+ requirement: &76828540 !ruby/object:Gem::Requirement
62
73
  none: false
63
74
  requirements:
64
75
  - - ! '>='
@@ -66,10 +77,10 @@ dependencies:
66
77
  version: '0'
67
78
  type: :development
68
79
  prerelease: false
69
- version_requirements: *73548550
80
+ version_requirements: *76828540
70
81
  - !ruby/object:Gem::Dependency
71
82
  name: autotest
72
- requirement: &73548250 !ruby/object:Gem::Requirement
83
+ requirement: &76828300 !ruby/object:Gem::Requirement
73
84
  none: false
74
85
  requirements:
75
86
  - - ! '>='
@@ -77,10 +88,10 @@ dependencies:
77
88
  version: '0'
78
89
  type: :development
79
90
  prerelease: false
80
- version_requirements: *73548250
91
+ version_requirements: *76828300
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: autotest-notification
83
- requirement: &73547960 !ruby/object:Gem::Requirement
94
+ requirement: &76828010 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ! '>='
@@ -88,10 +99,10 @@ dependencies:
88
99
  version: '0'
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *73547960
102
+ version_requirements: *76828010
92
103
  - !ruby/object:Gem::Dependency
93
104
  name: log4r
94
- requirement: &73547690 !ruby/object:Gem::Requirement
105
+ requirement: &76827750 !ruby/object:Gem::Requirement
95
106
  none: false
96
107
  requirements:
97
108
  - - ! '>='
@@ -99,10 +110,10 @@ dependencies:
99
110
  version: 1.1.9
100
111
  type: :runtime
101
112
  prerelease: false
102
- version_requirements: *73547690
113
+ version_requirements: *76827750
103
114
  - !ruby/object:Gem::Dependency
104
115
  name: savon
105
- requirement: &73547420 !ruby/object:Gem::Requirement
116
+ requirement: &76827500 !ruby/object:Gem::Requirement
106
117
  none: false
107
118
  requirements:
108
119
  - - ! '>='
@@ -110,10 +121,10 @@ dependencies:
110
121
  version: 0.7.9
111
122
  type: :runtime
112
123
  prerelease: false
113
- version_requirements: *73547420
124
+ version_requirements: *76827500
114
125
  - !ruby/object:Gem::Dependency
115
126
  name: highline
116
- requirement: &73547130 !ruby/object:Gem::Requirement
127
+ requirement: &76827250 !ruby/object:Gem::Requirement
117
128
  none: false
118
129
  requirements:
119
130
  - - ! '>='
@@ -121,10 +132,10 @@ dependencies:
121
132
  version: '1.6'
122
133
  type: :runtime
123
134
  prerelease: false
124
- version_requirements: *73547130
135
+ version_requirements: *76827250
125
136
  - !ruby/object:Gem::Dependency
126
137
  name: choosy
127
- requirement: &73546840 !ruby/object:Gem::Requirement
138
+ requirement: &76827010 !ruby/object:Gem::Requirement
128
139
  none: false
129
140
  requirements:
130
141
  - - ! '>='
@@ -132,10 +143,10 @@ dependencies:
132
143
  version: 0.2.4
133
144
  type: :runtime
134
145
  prerelease: false
135
- version_requirements: *73546840
146
+ version_requirements: *76827010
136
147
  - !ruby/object:Gem::Dependency
137
148
  name: rspec
138
- requirement: &73546540 !ruby/object:Gem::Requirement
149
+ requirement: &76826760 !ruby/object:Gem::Requirement
139
150
  none: false
140
151
  requirements:
141
152
  - - ! '>='
@@ -143,7 +154,7 @@ dependencies:
143
154
  version: 2.5.0
144
155
  type: :development
145
156
  prerelease: false
146
- version_requirements: *73546540
157
+ version_requirements: *76826760
147
158
  description: This gem installs several simple command line utilities locally. It
148
159
  uses the NSConfig.wsdl SOAP interface for remote access.
149
160
  email:
@@ -165,12 +176,13 @@ files:
165
176
  - lib/netscaler/config.rb
166
177
  - lib/netscaler/errors.rb
167
178
  - lib/netscaler/executor.rb
168
- - lib/netscaler/extensions.rb
169
179
  - lib/netscaler/logging.rb
170
180
  - lib/netscaler/server/request.rb
171
181
  - lib/netscaler/server/response.rb
172
182
  - lib/netscaler/service/request.rb
173
183
  - lib/netscaler/service/response.rb
184
+ - lib/netscaler/servicegroup/request.rb
185
+ - lib/netscaler/servicegroup/response.rb
174
186
  - lib/netscaler/transaction.rb
175
187
  - lib/netscaler/version.rb
176
188
  - lib/netscaler/vserver/request.rb
@@ -180,7 +192,6 @@ files:
180
192
  - spec/netscaler/configs/bad-yaml.yml
181
193
  - spec/netscaler/configs/missing-username.yml
182
194
  - spec/netscaler/configs/simple-config.yml
183
- - spec/netscaler/extenstions_spec.rb
184
195
  - spec/spec_helpers.rb
185
196
  has_rdoc: true
186
197
  homepage: http://github.com/gabemc/netscaler-cli
@@ -211,5 +222,4 @@ summary: Simple command line utilities for interacting remotely with a Netscaler
211
222
  test_files:
212
223
  - spec/netscaler/cli_spec.rb
213
224
  - spec/netscaler/config_spec.rb
214
- - spec/netscaler/extenstions_spec.rb
215
225
  - spec/spec_helpers.rb
@@ -1,47 +0,0 @@
1
-
2
- # Alter the standard Array class
3
- class Array
4
- def to_s
5
- base = ""
6
- each do |e|
7
- base << e.to_s
8
- base << "\n"
9
- end
10
- base
11
- end
12
-
13
- def to_json(prefix=nil)
14
- value = if prefix
15
- prefix.dup
16
- else
17
- ""
18
- end
19
- if empty?
20
- return value << "[]"
21
- end
22
-
23
- indent = if prefix
24
- " " << prefix
25
- else
26
- " "
27
- end
28
-
29
- value << "[\n"
30
-
31
- each_with_index do |e, i|
32
- value << indent
33
- value << e.to_json(indent)
34
- value << ",\n" unless i == length - 1
35
- end
36
-
37
- value << "\n"
38
- value << prefix if prefix
39
- value << "]\n"
40
- end
41
- end
42
-
43
- class String
44
- def to_json(prefix=nil)
45
- "\"#{self}\""
46
- end
47
- end
@@ -1,26 +0,0 @@
1
- require 'spec_helpers'
2
- require 'netscaler/extensions'
3
-
4
- describe Array do
5
- it "should just print out the [] when empty" do
6
- [].to_json.should eql('[]')
7
- end
8
-
9
- it "should indent the [] if given" do
10
- [].to_json(' ').should eql(' []')
11
- end
12
-
13
- class Integer
14
- def to_json(prefix=nil)
15
- to_s
16
- end
17
- end
18
-
19
- it "should print out the contents, one line each." do
20
- [1, 2, 3].to_json.should eql("[\n 1,\n 2,\n 3\n]\n")
21
- end
22
-
23
- it "should print out the contents indented" do
24
- [1, 2, 3].to_json(' ').should eql(" [\n 1,\n 2,\n 3\n ]\n")
25
- end
26
- end