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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/aly/app.rb +16 -3
- data/lib/aly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f26b851dc09f00694624a45426546e11bc72c63de0a991ceb1e6b1e8989a3f1
|
4
|
+
data.tar.gz: e4f1e81074036af2e6565f0f98a30ffd7a81dc82a1c42bb878f6357c5a93cf55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c762fdf73886adb7229a88510e613ec7d58966dc42cb1fe98bf3d84b7082274551e2201f08439953c467743561e90a4229d777294963d765a68987f0c3916c2d
|
7
|
+
data.tar.gz: 97f110b453a54434943d380ad960536dc26934ceff82b6f8fac8782011c38f2e8aba9692ff56cd8d5714c2df78926f0a947e965d78169e55f8d9fcf1f35d9796
|
data/Gemfile.lock
CHANGED
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