f5-icontrol 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af1d81830bb6821e3a7ef6040d632673be052a82
4
- data.tar.gz: 436e1982d1adc3b0354e93b9f436288f5c24609f
3
+ metadata.gz: 854e1c553d0f5e3f06ab337530db1f72654611d3
4
+ data.tar.gz: 864262f06dd325ef04405e2ec4378207a3c33ad4
5
5
  SHA512:
6
- metadata.gz: fa4feeb14c8b10e1f04e17fdc285f40c1712483c937062d4d84baa1e7b365b0a10690c4c4fca87ed5d49165808f4a240a6e2ba30737cd65cd53b1b88316268e8
7
- data.tar.gz: 61170981d9e12599418f8b55cef318467ba45fdc9517dc292b28605e250f7c05d6f449ff16510caf1b68225f4f06905c7e2875d37c00520335534513c5788478
6
+ metadata.gz: 6914421ea90053c021fd012426c2e5a9f4bf16e2d0e514173128f49b3e022f00eb011ef47e814e1c89e40201aecc60f31d34a4bb844d190d00a521dde0b939e0
7
+ data.tar.gz: 57ce61baf8e0b2a6422091eccffce41a0e542a125de8aa7085e36770de524eb20fcf7897c8b5e64ed062895c2effb1f13d82da7ec750cbfcd06b73a81ba16c22
data/README.md CHANGED
@@ -48,6 +48,20 @@ api = F5::Icontrol::API.new
48
48
  response = api.LocalLB.Pool.get_list
49
49
  ```
50
50
 
51
+ or You can configure per api client.
52
+
53
+ ```Ruby
54
+ api = F5::Icontrol::API.new(
55
+ nil, # This first argument `nil` is required.
56
+ {
57
+ host: "hostname.of.bigip",
58
+ username: "username",
59
+ password: "password",
60
+ }
61
+ )
62
+ response = api.LocalLB.Pool.get_list
63
+ ```
64
+
51
65
  See specs subdir for more examples, especially as it pertains to passing parameters.
52
66
 
53
67
  ## CLI
@@ -51,6 +51,53 @@ module F5
51
51
 
52
52
  end
53
53
 
54
+ class Node < Subcommand
55
+ desc "list", "Lists all the nodes"
56
+ def list
57
+ response = client.LocalLB.NodeAddressV2.get_list
58
+
59
+ nodes = extract_items(response, :as_array)
60
+ if nodes.empty?
61
+ puts "No nodes found"
62
+ else
63
+ nodes.each do |node|
64
+ puts node
65
+ end
66
+ end
67
+ end
68
+
69
+ desc "show NAME", "Shows information about a node"
70
+ def show(node)
71
+ session_status = extract_items client.LocalLB.NodeAddressV2.get_object_status(nodes: { item: [ node ] })
72
+ stats = client.LocalLB.NodeAddressV2.get_statistics(nodes: { item: [ node ] })
73
+ outer_envelope = extract_items stats[:statistics]
74
+ stats = extract_items outer_envelope[:statistics]
75
+
76
+ total_connections = stats.find { |stat| stat[:type] == "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS" }
77
+ total_connections = total_connections[:value][:low]
78
+
79
+ puts "#{node} #{session_status[:availability_status]} (#{session_status[:status_description]}) with #{total_connections} connections"
80
+ end
81
+
82
+ desc "disable NAME", "Disables a particular node"
83
+ def disable(node)
84
+ client.LocalLB.NodeAddressV2.set_monitor_state(
85
+ nodes: { item: [ node ] },
86
+ states: { item: [ "STATE_DISABLED" ] }
87
+ )
88
+ end
89
+
90
+ desc "enable NAME", "Enables a particular node"
91
+ def enable(node)
92
+ client.LocalLB.NodeAddressV2.set_monitor_state(
93
+ nodes: { item: [ node ] },
94
+ states: { item: [ "STATE_ENABLED" ] }
95
+ )
96
+ end
97
+
98
+
99
+ end
100
+
54
101
  class SelfIP < Subcommand
55
102
  desc "list", "Lists all the self IPs"
56
103
  def list
@@ -287,6 +334,9 @@ module F5
287
334
  class Application < Thor
288
335
  class_option :lb, default: 'default'
289
336
 
337
+ desc "node SUBCOMMAND ...ARGS", "manage nodes"
338
+ subcommand "node", Node
339
+
290
340
  desc "pool SUBCOMMAND ...ARGS", "manage pools"
291
341
  subcommand "pool", Pool
292
342
 
@@ -3,10 +3,11 @@ module F5
3
3
  class API
4
4
  attr_accessor :api_path
5
5
 
6
- def initialize(api_path = nil)
7
- @username="a"
8
- @password="b"
9
- @hostname="xxx"
6
+ def initialize(api_path = nil, params = {})
7
+ @params = params.dup
8
+ @username = params[:username]
9
+ @password = params[:password]
10
+ @hostname = params[:host] || params[:hostname]
10
11
  @client_cache = {}
11
12
  @api_path = api_path
12
13
  end
@@ -24,7 +25,7 @@ module F5
24
25
  response.to_hash[response_key][:return]
25
26
 
26
27
  elsif supported_path? append_path(method)
27
- self.class.new append_path(method)
28
+ self.class.new append_path(method), @params
28
29
  else
29
30
  raise NameError, "#{method} is not supported by #{@api_path}"
30
31
  end
@@ -57,9 +58,9 @@ module F5
57
58
  endpoint = '/iControl/iControlPortal.cgi'
58
59
  @client_cache[@api_path] ||=
59
60
  Savon.client(wsdl: "#{wsdl_path}#{@api_path}.wsdl",
60
- endpoint: "https://#{F5::Icontrol.configuration.host}#{endpoint}",
61
+ endpoint: "https://#{@hostname || F5::Icontrol.configuration.host}#{endpoint}",
61
62
  ssl_verify_mode: :none,
62
- basic_auth: [F5::Icontrol.configuration.username, F5::Icontrol.configuration.password],
63
+ basic_auth: [@username || F5::Icontrol.configuration.username, @password || F5::Icontrol.configuration.password],
63
64
  #log: true,
64
65
  #logger: Logger.new(STDOUT),
65
66
  #pretty_print_xml: true,
@@ -1,5 +1,5 @@
1
1
  module F5
2
2
  module Icontrol
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: f5-icontrol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Walberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -399,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
399
399
  version: '0'
400
400
  requirements: []
401
401
  rubyforge_project:
402
- rubygems_version: 2.2.2
402
+ rubygems_version: 2.4.5
403
403
  signing_key:
404
404
  specification_version: 4
405
405
  summary: A gem to manage F5 BigIP devices using the iControl API
@@ -411,4 +411,3 @@ test_files:
411
411
  - spec/cli/pool_spec.rb
412
412
  - spec/models/api_spec.rb
413
413
  - spec/spec_helper.rb
414
- has_rdoc: