netscaler-cli 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -6,18 +6,20 @@ This is a simple command line interface for accessing a Netscaler load balancer.
6
6
 
7
7
  The command line tools can be installed with:
8
8
 
9
- gem install netscaler-api
9
+ gem install netscaler-cli
10
10
 
11
11
  # Using
12
12
 
13
13
  The following commands are currently a part of the system:
14
- - *netscaler-vserver* -- An interface for enabling, disabling, and binding responder policies to a specific virtual server.
14
+
15
+ * *netscaler-vserver* -- An interface for enabling, disabling, and binding responder policies to a specific virtual server.
16
+ * *netscaler-service* -- An interface for enabling, disabling, and binding virtual servers to specific service.
15
17
 
16
18
  # Configuration
17
19
 
18
20
  All of the commands rely upon a configuration file in the YAML format. By default, it looks for a file in your home directory
19
21
 
20
- ~/.netscape-cli.yml
22
+ ~/.netscaler-cli.yml
21
23
 
22
24
  Each load balancer requires an entry in the file in the form:
23
25
 
data/Rakefile CHANGED
@@ -39,12 +39,6 @@ rescue LoadError
39
39
  puts "Jeweler or dependencies are not available. Install it with: sudo gem install jeweler"
40
40
  end
41
41
 
42
- desc "Cleans the gem files up."
43
- task :clean do
44
- FileUtils.rm(Dir.glob('*.gemspec'))
45
- FileUtils.rm(Dir.glob('*.gem'))
46
- end
47
-
48
42
  desc "Deploys the gem to rubygems.org"
49
43
  task :gem => :release do
50
44
  system("gem build netscaler-cli.gemspec")
@@ -54,3 +48,9 @@ end
54
48
  desc "Does the full release cycle."
55
49
  task :deploy => [:gem, :clean] do
56
50
  end
51
+
52
+ desc "Cleans the gem files up."
53
+ task :clean do
54
+ FileUtils.rm(Dir.glob('*.gemspec'))
55
+ FileUtils.rm(Dir.glob('*.gem'))
56
+ end
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -12,20 +12,20 @@ module Netscaler
12
12
  end
13
13
 
14
14
  protected
15
- def send_request(name, body_attrs=nil)
15
+ def send_request(name, params, &block)
16
+ if params.nil? || params.empty?
17
+ raise Netscaler::TransactionError.new("The parameters were empty.")
18
+ end
19
+
16
20
  log.debug("Calling: #{name}")
17
21
 
18
22
  result = client.send("#{name}!") do |soap|
19
23
  soap.namespace = Netscaler::NSCONFIG_NAMESPACE
20
-
24
+ soap.input = name
21
25
  body = Hash.new
22
-
23
- if !body_attrs.nil?
24
- body_attrs.each do |k,v|
25
- body[k] = v
26
- end
26
+ params.each do |k,v|
27
+ body[k.to_s] = v
27
28
  end
28
-
29
29
  soap.body = body
30
30
  end
31
31
 
@@ -34,8 +34,13 @@ module Netscaler
34
34
  response = result.to_hash["#{name.to_s}_response".to_sym]
35
35
  if block_given?
36
36
  yield response
37
- else
38
- log.info(response[:return][:message])
37
+ else
38
+ msg = response[:return][:message]
39
+ if msg !~ /^Done$/
40
+ log.error(response[:return][:message])
41
+ else
42
+ log.debug(msg)
43
+ end
39
44
  end
40
45
 
41
46
  result
@@ -4,50 +4,50 @@ module Netscaler::Service
4
4
  class Executor < Netscaler::BaseExecutor
5
5
  def initialize(host, client)
6
6
  super(host, client)
7
+ @params = { :name => host }
7
8
  end
8
9
 
9
10
  def enable
10
- attrs = {
11
- 'name' => host
12
- }
13
- send_request('enableservice', attrs)
11
+ send_request('enableservice', @params)
14
12
  end
15
13
 
16
14
  def disable
17
- attrs = {
18
- 'name' => host,
19
- 'delay' => 0
15
+ params = {
16
+ :name => host,
17
+ :delay => 0
20
18
  }
21
- send_request('disableservice', attrs)
19
+ send_request('disableservice', params)
22
20
  end
23
21
 
24
22
  def status
25
- attrs = { 'name' => host }
26
- send_request('getservice', attrs) do |response|
27
- require 'pp'
28
- pp response
23
+ send_request('getservice', @params) do |response|
24
+ info = response[:return][:list][:item]
25
+ puts "Name: #{info[:name]}"
26
+ puts "IP Address: #{info[:ipaddress]}"
27
+ puts "Port: #{info[:port]}"
28
+ puts "State: #{info[:svrstate]}"
29
29
  end
30
30
  end
31
31
 
32
32
  def bind(vserver)
33
- attrs = {
34
- 'name' => vserver,
35
- 'servicename' => host
33
+ params = {
34
+ :name => vserver,
35
+ :servicename => host
36
36
  }
37
- send_request('bindlbvserver_service', attrs) do |response|
38
- require 'pp'
39
- pp response
37
+ send_request('bindlbvserver_service', params) do |response|
38
+ #require 'pp'
39
+ #pp response
40
40
  end
41
41
  end
42
42
 
43
43
  def unbind(vserver)
44
- attrs = {
45
- 'name' => vserver,
46
- 'servicename' => host
44
+ params = {
45
+ :name => vserver,
46
+ :servicename => host
47
47
  }
48
- send_request('unbindlbvserver_service', attrs) do |response|
49
- require 'pp'
50
- pp response
48
+ send_request('unbindlbvserver_service', params) do |response|
49
+ #require 'pp'
50
+ #pp response
51
51
  end
52
52
  end
53
53
  end
@@ -4,52 +4,51 @@ module Netscaler::VServer
4
4
  class Executor < Netscaler::BaseExecutor
5
5
  def initialize(host, client)
6
6
  super(host, client)
7
+ @params = { :name => host }
7
8
  end
8
9
 
9
10
  def enable
10
- attrs = { 'name' => host }
11
- send_request('enablelbvserver', attrs)
11
+ send_request('enablelbvserver', @params)
12
12
  end
13
13
 
14
14
  def disable
15
- attrs = { 'name' => host }
16
- send_request('disablelbvserver', attrs)
15
+ send_request('disablelbvserver', @params)
17
16
  end
18
17
 
19
18
  def status
20
- attrs = { 'name' => host }
21
- send_request('getlbvserver', attrs) do |response|
22
- puts "Name: #{response[:return][:list][:item][:name]}"
23
- puts "IP Address: #{response[:return][:list][:item][:svcipaddress][:item]}"
24
- puts "Port: #{response[:return][:list][:item][:svcport][:item]}"
25
- puts "State: #{response[:return][:list][:item][:svcstate][:item]}"
19
+ send_request('getlbvserver', @params) do |response|
20
+ info = response[:return][:list][:item]
21
+ puts "Name: #{info[:name]}"
22
+ puts "IP Address: #{info[:svcipaddress][:item]}"
23
+ puts "Port: #{info[:svcport][:item]}"
24
+ puts "State: #{info[:svcstate][:item]}"
26
25
  end
27
26
  end
28
27
 
29
28
  def bind(policy_name)
30
- attrs = {
31
- 'name' => host,
32
- 'policyname' => policy_name,
33
- 'priority' => 1,
34
- 'gotopriorityexpression' => 'END'
29
+ params = {
30
+ :name => host,
31
+ :policyname => policy_name,
32
+ :priority => 1,
33
+ :gotopriorityexpression => 'END'
35
34
  }
36
35
 
37
- send_request('bindlbvserver_policy', attrs) do |response|
38
- require 'pp'
39
- pp response
36
+ send_request('bindlbvserver_policy', params) do |response|
37
+ #require 'pp'
38
+ #pp response
40
39
  end
41
40
  end
42
41
 
43
42
  def unbind(policy_name)
44
- attrs = {
45
- 'name' => host,
46
- 'policyname' => policy_name,
47
- 'type' => 'REQUEST'
43
+ params = {
44
+ :name => host,
45
+ :policyname => policy_name,
46
+ :type => 'REQUEST'
48
47
  }
49
48
 
50
- send_request('unbindlbvserver_policy', attrs) do |response|
51
- require 'pp'
52
- pp response
49
+ send_request('unbindlbvserver_policy', params) do |response|
50
+ #require 'pp'
51
+ #pp response
53
52
  end
54
53
  end
55
54
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netscaler-cli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabe McArthur
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-12 00:00:00 -07:00
18
+ date: 2010-09-28 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency