f5-icontrol 0.1.2 → 0.1.3

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: b8587b7f410c3f3d017acf7dad53a35b7a525fde
4
- data.tar.gz: fd6bac18d27da90beacda52a8184da3a7ad34c72
3
+ metadata.gz: 6fec57b1d21f739421ddfaea3bca33a34c026b6d
4
+ data.tar.gz: c1507eeddf2f4501d6454e20bba4b12a03e50d0f
5
5
  SHA512:
6
- metadata.gz: d3495c946b952f5f223699c6d3f66178b86e75c08fa266a97a015726423e04a582143ba419be5005c29996d1f204dd194d54432f9214a8fa79d7e8ce51f88d67
7
- data.tar.gz: f35e767af028beae255bcf924f744ad13e37e44b6fc3d1e6498faa87674c06615e94152b49bc07b986d89ab83c25df465da7b3eef42c2070ecda75fed813eace
6
+ metadata.gz: 53ac4f57f25b527a170b38fb931da8dd80cb32454d6b506cd4d2353c4c80498c0772c13b50da206d486319c89c498310411ea6205a2c443b031f64446e995768
7
+ data.tar.gz: a9df0bcde1ea51fe3e0727d277466ef71a509be0eadf5335f61aebd0608843a568b526fc1ccfb94456b0f46c723893359f3ce24d85ac1c65f304b1d0ed23d033
@@ -4,5 +4,6 @@
4
4
  ### CLI
5
5
  * Add a --force option to disable a pool member
6
6
  * Fix a bug where pools with one member crashed
7
+
7
8
  ## 0.1.1
8
9
  * It's useable now
@@ -1,4 +1,5 @@
1
1
  require 'thor'
2
+ require 'awesome_print'
2
3
 
3
4
  module F5
4
5
  module Cli
@@ -40,10 +41,24 @@ module F5
40
41
  statuses = response[:item][:item]
41
42
  statuses = [ statuses ] if statuses.is_a? Hash
42
43
 
43
- puts "%20s %25s %25s" % ["Address", "Availability", "Enabled"]
44
+ response = client.LocalLB.Pool.get_all_member_statistics(
45
+ pool_names: { item: [ pool ] }
46
+ )
47
+
48
+ stats = response[:item][:statistics][:item]
49
+ stats = [ stats ] if stats.is_a? Hash
50
+
51
+ connections = stats.map do |host|
52
+ stats = host[:statistics][:item]
53
+ c = stats.find { |stat| stat[:type] == "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS" }
54
+ c[:value][:high].to_i * (2<<32) + c[:value][:low].to_i
55
+ end
56
+
57
+ puts "%20s %25s %25s %25s" % ["Address", "Availability", "Enabled", "Current Connections"]
44
58
  statuses.each_with_index do |s, idx|
45
- puts "%20s %25s %25s" % [ members[idx][:address], s[:availability_status].split(/_/).last, s[:enabled_status].split(/_/).last ]
59
+ puts "%20s %25s %25s %25s" % [ members[idx][:address], s[:availability_status].split(/_/).last, s[:enabled_status].split(/_/).last, connections[idx]]
46
60
  end
61
+
47
62
  end
48
63
 
49
64
  desc "enable POOL MEMBERS", "Enables the given members"
@@ -1,5 +1,5 @@
1
1
  module F5
2
2
  module Icontrol
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'f5/cli/application'
3
+
4
+ describe F5::Cli::Pool do
5
+ before do
6
+ allow(subject).to receive(:client).and_return(client)
7
+ end
8
+
9
+ let(:client) { double }
10
+
11
+ context "list" do
12
+ let(:output) { capture(:stdout) { subject.list } }
13
+
14
+ context "no pools" do
15
+ it "indicates there are no pools" do
16
+ allow(client).to receive_message_chain("LocalLB", "Pool", "get_list") { { item: nil } }
17
+ expect(output).to include("No pools found")
18
+ end
19
+ end
20
+
21
+ context "one pool" do
22
+ it "lists the pools" do
23
+ allow(client).to receive_message_chain("LocalLB", "Pool", "get_list") { { item: "/Common/foobar" } }
24
+ expect(output).to eq("/Common/foobar\n")
25
+ end
26
+ end
27
+
28
+ context "two pools" do
29
+ it "lists the pools" do
30
+ allow(client).to receive_message_chain("LocalLB", "Pool", "get_list") { { item: [ "/Common/one", "/Common/two" ] } }
31
+ expect(output).to eq("/Common/one\n/Common/two\n")
32
+ end
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,29 @@ require 'f5/icontrol'
2
2
  require 'vcr'
3
3
 
4
4
  RSpec.configure do |c|
5
+ # https://github.com/docwhat/homedir/blob/homedir3/spec/spec_helper.rb
6
+ # Captures the output for analysis later
7
+ #
8
+ # @example Capture `$stderr`
9
+ #
10
+ # output = capture(:stderr) { $stderr.puts "this is captured" }
11
+ #
12
+ # @param [Symbol] stream `:stdout` or `:stderr`
13
+ # @yield The block to capture stdout/stderr for.
14
+ # @return [String] The contents of $stdout or $stderr
15
+ def capture(stream)
16
+ begin
17
+ stream = stream.to_s
18
+ eval "$#{stream} = StringIO.new"
19
+ yield
20
+ result = eval("$#{stream}").string
21
+ ensure
22
+ eval("$#{stream} = #{stream.upcase}")
23
+ end
24
+
25
+ result
26
+ end
27
+
5
28
  end
6
29
 
7
30
  VCR.configure do |c|
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Walberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-10 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -376,6 +376,7 @@ files:
376
376
  - spec/cassettes/F5_Icontrol_System_SystemInfo/retrieves_something_with_a_complex_return_type_and_input.yml
377
377
  - spec/cassettes/F5_Icontrol_System_SystemInfo/retrieves_the_uptime.yml
378
378
  - spec/cassettes/F5_Icontrol_System_SystemInfo/retrieves_the_version.yml
379
+ - spec/cli/pool_spec.rb
379
380
  - spec/models/api_spec.rb
380
381
  - spec/spec_helper.rb
381
382
  homepage: https://github.com/swalberg/f5-icontrol
@@ -407,5 +408,6 @@ test_files:
407
408
  - spec/cassettes/F5_Icontrol_System_SystemInfo/retrieves_something_with_a_complex_return_type_and_input.yml
408
409
  - spec/cassettes/F5_Icontrol_System_SystemInfo/retrieves_the_uptime.yml
409
410
  - spec/cassettes/F5_Icontrol_System_SystemInfo/retrieves_the_version.yml
411
+ - spec/cli/pool_spec.rb
410
412
  - spec/models/api_spec.rb
411
413
  - spec/spec_helper.rb