f5-icontrol 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 629649284f385f3dce498418e2b46347ea3abc8b
4
- data.tar.gz: 97608378edc825c3056da1f1dd15027af0aa9c6c
3
+ metadata.gz: b8587b7f410c3f3d017acf7dad53a35b7a525fde
4
+ data.tar.gz: fd6bac18d27da90beacda52a8184da3a7ad34c72
5
5
  SHA512:
6
- metadata.gz: 09366ecfcff0925f4507c79a4a30a5bad9bb6ee2b1f69267a609e73dae648b1b503397df6378989bb4106e297c0677331a41d07af5eeb06966c24f7808375dab
7
- data.tar.gz: 74415bd966863d47ecd3c06bff9d1f0df59b62904544f386297cdb1ac8acaf3b90a5196c3077bcdcf4c621f8279b231e575bbf1d5955b503305f5e4473eca004
6
+ metadata.gz: d3495c946b952f5f223699c6d3f66178b86e75c08fa266a97a015726423e04a582143ba419be5005c29996d1f204dd194d54432f9214a8fa79d7e8ce51f88d67
7
+ data.tar.gz: f35e767af028beae255bcf924f744ad13e37e44b6fc3d1e6498faa87674c06615e94152b49bc07b986d89ab83c25df465da7b3eef42c2070ecda75fed813eace
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.2
4
+ ### CLI
5
+ * Add a --force option to disable a pool member
6
+ * Fix a bug where pools with one member crashed
7
+ ## 0.1.1
8
+ * It's useable now
@@ -37,7 +37,9 @@ module F5
37
37
  pool_names: { item: [ pool ] },
38
38
  members: { item: [ members ] }
39
39
  )
40
- statuses = Array(response[:item][:item])
40
+ statuses = response[:item][:item]
41
+ statuses = [ statuses ] if statuses.is_a? Hash
42
+
41
43
  puts "%20s %25s %25s" % ["Address", "Availability", "Enabled"]
42
44
  statuses.each_with_index do |s, idx|
43
45
  puts "%20s %25s %25s" % [ members[idx][:address], s[:availability_status].split(/_/).last, s[:enabled_status].split(/_/).last ]
@@ -56,9 +58,16 @@ module F5
56
58
  session_states: { item: [ set.map { "STATE_ENABLED" } ] }
57
59
  )
58
60
 
61
+ response = client.LocalLB.Pool.set_member_monitor_state(
62
+ pool_names: { item: [ pool ] },
63
+ members: { item: [ set ] },
64
+ monitor_states: { item: [ set.map { "STATE_ENABLED" } ] }
65
+ )
66
+
59
67
  end
60
68
 
61
69
  desc "disable POOL MEMBERS", "Disables the given members"
70
+ method_option :force, default: false, desc: "Forces the node offline (only active connections allowed)"
62
71
  def disable(pool, *members)
63
72
  set = pool_members(pool).select do |m|
64
73
  members.include? m[:address]
@@ -69,13 +78,24 @@ module F5
69
78
  members: { item: [ set ] },
70
79
  session_states: { item: [ set.map { "STATE_DISABLED" } ] }
71
80
  )
81
+
82
+ if options[:force]
83
+ response = client.LocalLB.Pool.set_member_monitor_state(
84
+ pool_names: { item: [ pool ] },
85
+ members: { item: [ set ] },
86
+ monitor_states: { item: [ set.map { "STATE_DISABLED" } ] }
87
+ )
88
+ end
72
89
  end
73
90
 
74
91
  private
75
92
 
76
93
  def pool_members(pool)
77
94
  response = client.LocalLB.Pool.get_member_v2(pool_names: { item: [ pool ] } )
78
- members = Array(response[:item][:item])
95
+
96
+ members = response[:item][:item]
97
+ members = [ members ] if members.is_a? Hash
98
+
79
99
  members.map { |m| { address: m[:address], port: m[:port] } }
80
100
  end
81
101
 
@@ -86,11 +106,6 @@ module F5
86
106
  end
87
107
 
88
108
  class Application < Thor
89
- desc 'hello', 'says hi'
90
-
91
- def hello(test)
92
- puts "hello #{test}"
93
- end
94
109
 
95
110
  desc "pool SUBCOMMAND ...ARGS", "manage pools"
96
111
  subcommand "pool", Pool
@@ -12,8 +12,7 @@ module F5
12
12
  end
13
13
 
14
14
  def method_missing(method, args = nil, &block)
15
- if terminal_node?
16
- if supported_method?(method)
15
+ if terminal_node? && supported_method?(method)
17
16
  response_key = "#{method.to_s}_response".to_sym
18
17
 
19
18
  response = client.call(method) do
@@ -24,15 +23,10 @@ module F5
24
23
 
25
24
  response.to_hash[response_key][:return]
26
25
 
27
- else
28
- raise NameError, "#{@api_path} does not support #{method}"
29
- end
26
+ elsif supported_path? append_path(method)
27
+ self.class.new append_path(method)
30
28
  else
31
- if supported_path? append_path(method)
32
- self.class.new append_path(method)
33
- else
34
- raise NameError, "#{append_path(method)} is not supported"
35
- end
29
+ raise NameError, "#{method} is not supported by #{@api_path}"
36
30
  end
37
31
  end
38
32
 
@@ -1,5 +1,5 @@
1
1
  module F5
2
2
  module Icontrol
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -40,6 +40,10 @@ describe F5::Icontrol::API do
40
40
  it "calls the method" do
41
41
  subject.LocalLB.Pool.get_list
42
42
  end
43
+
44
+ it "returns the inner contents" do
45
+ expect(subject.LocalLB.Pool.get_list).to eq "foo"
46
+ end
43
47
  end
44
48
 
45
49
  describe 'a non existent method' do
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.1
4
+ version: 0.1.2
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-10-09 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -132,6 +132,7 @@ extra_rdoc_files: []
132
132
  files:
133
133
  - ".gitignore"
134
134
  - ".travis.yml"
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
137
  - LICENSE
137
138
  - LICENSE.txt