aly 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: 929950a91790b6ca3522f18cb114d29d58ccc1d4c61e4de6b649198d5624ecf3
4
- data.tar.gz: 0c55d48418ec5a8661f8ef912dc7fc647514c99be0c14964a2f2d7fb4ed78198
3
+ metadata.gz: 1f26b851dc09f00694624a45426546e11bc72c63de0a991ceb1e6b1e8989a3f1
4
+ data.tar.gz: e4f1e81074036af2e6565f0f98a30ffd7a81dc82a1c42bb878f6357c5a93cf55
5
5
  SHA512:
6
- metadata.gz: e3e21c88c0dc447b9ca035786bbe4f1c4504f148a7731cb9cc8b9d1205152392e5e83d7fb702aaefd6f20ffb5acea3fc22677f3bccd20332c0914391ceae2e30
7
- data.tar.gz: da9a871f358fa988084dc84f5498c3800bd6eefc8467dcae6faf81fc7f4a2aab60cc6128cf84d387103ff92b658611dda502c4a9f1beb2162100749a6dc0b3e8
6
+ metadata.gz: c762fdf73886adb7229a88510e613ec7d58966dc42cb1fe98bf3d84b7082274551e2201f08439953c467743561e90a4229d777294963d765a68987f0c3916c2d
7
+ data.tar.gz: 97f110b453a54434943d380ad960536dc26934ceff82b6f8fac8782011c38f2e8aba9692ff56cd8d5714c2df78926f0a947e965d78169e55f8d9fcf1f35d9796
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aly (0.2.2)
4
+ aly (0.2.3)
5
5
  terminal-table (~> 1.8.0)
6
6
  thor (~> 0.20.0)
7
7
 
data/lib/aly/app.rb CHANGED
@@ -63,6 +63,7 @@ module Aly
63
63
  end
64
64
  end
65
65
 
66
+
66
67
  if options['detail']
67
68
  puts JSON.pretty_generate(selected)
68
69
  else
@@ -94,6 +95,10 @@ module Aly
94
95
  raw_out = exec('slb', 'DescribeLoadBalancers', '--pager', **options)
95
96
  selected = raw_out['LoadBalancers']['LoadBalancer'] || []
96
97
 
98
+ eips = exec('vpc', 'DescribeEipAddresses', "--PageSize=#{selected.size}", **options)['EipAddresses']['EipAddress'].each_with_object({}) do |item, result|
99
+ result[item['InstanceId']] = item['IpAddress']
100
+ end
101
+
97
102
  listeners = (exec('slb', 'DescribeLoadBalancerListeners', '--pager', 'path=Listeners', **options)['Listeners'] || []).each_with_object({}) do |listener, result|
98
103
  instance_id = listener['LoadBalancerId']
99
104
  result[instance_id] ||= []
@@ -140,6 +145,7 @@ module Aly
140
145
  Id: row['LoadBalancerId'],
141
146
  Name: row['LoadBalancerName'],
142
147
  Address: row['Address'],
148
+ Eip: eips[row['LoadBalancerId']] || '',
143
149
  Listeners: listeners
144
150
  }
145
151
  end
@@ -148,7 +154,7 @@ module Aly
148
154
  end
149
155
 
150
156
  def slb_contains_host?(host)
151
- @slb.any? { |lb| lb['Address'] == host }
157
+ @slb.any? { |lb| lb['Address'] == host || lb['Eip'] == host }
152
158
  end
153
159
 
154
160
  def ecs_contains_host?(host)
@@ -157,7 +163,7 @@ module Aly
157
163
 
158
164
  def show_slb(host, **options)
159
165
  @listeners ||= exec('slb', 'DescribeLoadBalancerListeners', '--pager', 'path=Listeners', **options)['Listeners'] || []
160
- lb = @slb.find { |e| e['Address'] == host }
166
+ lb = @slb.find { |e| e['Address'] == host || e['Eip'] == host }
161
167
  listeners = @listeners.select { |e| e['LoadBalancerId'] == lb['LoadBalancerId'] }
162
168
  background_servers = exec('slb', 'DescribeLoadBalancerAttribute', "--LoadBalancerId=#{lb['LoadBalancerId']}", **options)['BackendServers']['BackendServer']
163
169
 
@@ -166,6 +172,7 @@ module Aly
166
172
  Id: lb['LoadBalancerId'],
167
173
  Name: lb['LoadBalancerName'],
168
174
  Address: lb['Address'],
175
+ Eip: lb['Eip'],
169
176
  Listeners: listeners.size
170
177
  }].table.to_s)
171
178
  puts
@@ -257,6 +264,12 @@ module Aly
257
264
  @slb ||= exec('slb', 'DescribeLoadBalancers', '--pager', **options)['LoadBalancers']['LoadBalancer'] || []
258
265
 
259
266
  @eip ||= exec('vpc', 'DescribeEipAddresses', '--PageSize=100', **options)['EipAddresses']['EipAddress'] || []
267
+
268
+ eip_map = @eip.each_with_object({}) { |eip, h| h[eip['InstanceId']] = eip['IpAddress'] }
269
+ @slb.each do |slb|
270
+ slb['Eip'] = eip_map[slb['LoadBalancerId']]
271
+ end
272
+
260
273
  unless @ecs
261
274
  @ecs = exec('ecs', 'DescribeInstances', '--pager', **options)['Instances']['Instance'] || []
262
275
  @ecs.each do |item|
@@ -282,7 +295,7 @@ module Aly
282
295
  elsif ecs_contains_host?(host)
283
296
  show_ecs(host)
284
297
  elsif eip_contains_host?(host)
285
- eip(host)
298
+ eip(host, **options)
286
299
  else
287
300
  puts "Not found: #{host}"
288
301
  end
data/lib/aly/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aly
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang