Class: F5::Cli::Pool
- Inherits:
-
Thor
- Object
- Thor
- F5::Cli::Pool
- Defined in:
- lib/f5/cli/application.rb
Instance Method Summary collapse
- #disable(pool, *members) ⇒ Object
- #enable(pool, *members) ⇒ Object
- #list ⇒ Object
- #show(pool) ⇒ Object
- #status(pool) ⇒ Object
Instance Method Details
#disable(pool, *members) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/f5/cli/application.rb', line 85 def disable(pool, *members) set = pool_members(pool).select do |m| members.include? m[:address] end response = client.LocalLB.Pool.set_member_session_enabled_state( pool_names: { item: [ pool ] }, members: { item: [ set ] }, session_states: { item: [ set.map { "STATE_DISABLED" } ] } ) if [:force] response = client.LocalLB.Pool.set_member_monitor_state( pool_names: { item: [ pool ] }, members: { item: [ set ] }, monitor_states: { item: [ set.map { "STATE_DISABLED" } ] } ) end end |
#enable(pool, *members) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/f5/cli/application.rb', line 64 def enable(pool, *members) set = pool_members(pool).select do |m| members.include? m[:address] end response = client.LocalLB.Pool.set_member_session_enabled_state( pool_names: { item: [ pool ] }, members: { item: [ set ] }, session_states: { item: [ set.map { "STATE_ENABLED" } ] } ) response = client.LocalLB.Pool.set_member_monitor_state( pool_names: { item: [ pool ] }, members: { item: [ set ] }, monitor_states: { item: [ set.map { "STATE_ENABLED" } ] } ) end |
#list ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/f5/cli/application.rb', line 8 def list response = client.LocalLB.Pool.get_list pools = Array(response[:item]) if pools.empty? puts "No pools found" else pools.each do |p| puts p end end end |
#show(pool) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/f5/cli/application.rb', line 22 def show(pool) members = pool_members(pool) if members.empty? puts "Pool #{pool} is empty" else members.each do |member| puts "#{member[:address]}:#{member[:port]}" end end end |
#status(pool) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/f5/cli/application.rb', line 34 def status(pool) members = pool_members(pool) response = client.LocalLB.Pool.get_member_object_status( pool_names: { item: [ pool ] }, members: { item: [ members ] } ) statuses = response[:item][:item] statuses = [ statuses ] if statuses.is_a? Hash response = client.LocalLB.Pool.get_all_member_statistics( pool_names: { item: [ pool ] } ) stats = response[:item][:statistics][:item] stats = [ stats ] if stats.is_a? Hash connections = stats.map do |host| stats = host[:statistics][:item] c = stats.find { |stat| stat[:type] == "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS" } c[:value][:high].to_i * (2<<32) + c[:value][:low].to_i end puts "%20s %25s %25s %25s" % ["Address", "Availability", "Enabled", "Current Connections"] statuses.each_with_index do |s, idx| puts "%20s %25s %25s %25s" % [ members[idx][:address], s[:availability_status].split(/_/).last, s[:enabled_status].split(/_/).last, connections[idx]] end end |