aly 0.3.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/aly/app.rb +37 -26
- 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: 710c187d9fac4262f8c0507ba0334d54b983dd1bcdf19248e5f4cb2d52cf707d
|
4
|
+
data.tar.gz: ef60807c9b0184da58027f9048da53845924aaa5edcc4beac8c43d6dd0dd9236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f366b47ab659a41bb3e1d9aa78045e281fb3330b02fa41f193ed83561d50c5b8f4aef313f9916549081e0126a3284797c7b715136accc76eea1714da1abc99a3
|
7
|
+
data.tar.gz: 985ea70ca8b61ec19d9ab78c1db6f7692c5f5e992116f7b18c92c15943d0474165685530c2898f93e7bc1de5637f090fdd9839b3a79ef40ce655a72300f60b14
|
data/Gemfile.lock
CHANGED
data/lib/aly/app.rb
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
module Aly
|
19
19
|
class App
|
20
20
|
def start(options)
|
21
|
-
send(options[:command], *options[:args], **options[:options])
|
21
|
+
send(options[:command], *options[:args], **(options[:options].transform_keys(&:to_sym)))
|
22
22
|
end
|
23
23
|
|
24
24
|
def ecs(*args, **options)
|
@@ -35,7 +35,20 @@ module Aly
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
if options[
|
38
|
+
if options[:full]
|
39
|
+
selected = selected.map do |row|
|
40
|
+
{
|
41
|
+
Id: row['InstanceId'],
|
42
|
+
Name: row['InstanceName'],
|
43
|
+
PrivateIP: row['PrivateIP'],
|
44
|
+
PublicIP: row['PublicIP'],
|
45
|
+
CPU: row['Cpu'],
|
46
|
+
RAM: "#{row['Memory'] / 1024.0} GB",
|
47
|
+
WEB: "https://ecs.console.aliyun.com/#/server/#{row['InstanceId']}/monitor?regionId=#{row['RegionId']}"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
puts selected.table&.to_s
|
51
|
+
elsif options[:detail]
|
39
52
|
puts JSON.pretty_generate(selected)
|
40
53
|
else
|
41
54
|
selected = selected.map do |row|
|
@@ -64,7 +77,7 @@ module Aly
|
|
64
77
|
end
|
65
78
|
|
66
79
|
|
67
|
-
if options[
|
80
|
+
if options[:detail]
|
68
81
|
puts JSON.pretty_generate(selected)
|
69
82
|
else
|
70
83
|
net_intefraces = exec('ecs', 'DescribeNetworkInterfaces', '--pager', **options)['NetworkInterfaceSets']['NetworkInterfaceSet'].each_with_object({}) do |item, result|
|
@@ -104,7 +117,8 @@ module Aly
|
|
104
117
|
Name: lb['LoadBalancerName'],
|
105
118
|
Address: lb['Address'],
|
106
119
|
Eip: lb['Eip'],
|
107
|
-
Listeners: listeners.size
|
120
|
+
Listeners: listeners.size,
|
121
|
+
WEB: "https://slb.console.aliyun.com/slb/#{lb['RegionId']}/slbs/#{lb['LoadBalancerId']}/listeners"
|
108
122
|
}].table.to_s.gsub(/^/, ' '))
|
109
123
|
puts
|
110
124
|
|
@@ -189,7 +203,7 @@ module Aly
|
|
189
203
|
puts listener_rules.table.to_s.gsub(/^/, ' ')
|
190
204
|
puts
|
191
205
|
|
192
|
-
if options[
|
206
|
+
if options[:acl]
|
193
207
|
acl_ids = listeners.flat_map { |listener| listener['AclIds'] || [] }.uniq
|
194
208
|
unless acl_ids.empty?
|
195
209
|
alc_entries = acl_ids.flat_map do |acl_id|
|
@@ -257,9 +271,9 @@ module Aly
|
|
257
271
|
item['AllIPs'] = item['PrivateIP'] + item['PublicIP']
|
258
272
|
end
|
259
273
|
|
260
|
-
if options[
|
274
|
+
if options[:full]
|
261
275
|
full_slb(selected, eips, **options)
|
262
|
-
elsif options[
|
276
|
+
elsif options[:detail]
|
263
277
|
selected.each do |row|
|
264
278
|
described_load_balancer_attributes = exec('slb', 'DescribeLoadBalancerAttribute', "--LoadBalancerId=#{row['LoadBalancerId']}", **options)
|
265
279
|
row['BackendServers'] = described_load_balancer_attributes['BackendServers']['BackendServer']
|
@@ -405,25 +419,22 @@ module Aly
|
|
405
419
|
puts listener_rules.table.to_s.gsub(/^/, ' ')
|
406
420
|
puts
|
407
421
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
end + [nil]
|
421
|
-
end
|
422
|
-
puts ' Access Control Lists:'
|
423
|
-
puts alc_entries[0..-2].table.to_s.gsub(/^/, ' ')
|
424
|
-
puts
|
422
|
+
acl_ids = listeners.flat_map { |listener| listener['AclIds'] || [] }.uniq
|
423
|
+
unless acl_ids.empty?
|
424
|
+
alc_entries = acl_ids.flat_map do |acl_id|
|
425
|
+
attr = exec('slb', 'DescribeAccessControlListAttribute', "--AclId=#{acl_id}", **options)
|
426
|
+
(attr.dig('AclEntrys', 'AclEntry') || []).each_with_index.map do |e, idx|
|
427
|
+
{
|
428
|
+
AclId: (idx.zero? ? attr['AclId'] : ''),
|
429
|
+
AclName: (idx.zero? ? attr['AclName'] : ''),
|
430
|
+
AclEntryIP: e['AclEntryIP'],
|
431
|
+
AclEntryComment: e['AclEntryComment']
|
432
|
+
}
|
433
|
+
end + [nil]
|
425
434
|
end
|
426
|
-
|
435
|
+
puts ' Access Control Lists:'
|
436
|
+
puts alc_entries[0..-2].table.to_s.gsub(/^/, ' ')
|
437
|
+
puts
|
427
438
|
end
|
428
439
|
end
|
429
440
|
|
@@ -489,7 +500,7 @@ module Aly
|
|
489
500
|
|
490
501
|
def exec(command, sub_command, *args, **options)
|
491
502
|
command = "aliyun #{command} #{sub_command} #{args.join(' ')}"
|
492
|
-
command += " -p #{options[
|
503
|
+
command += " -p #{options[:profile]}" if options[:profile]
|
493
504
|
JSON.parse(`#{command}`)
|
494
505
|
end
|
495
506
|
end
|
data/lib/aly/version.rb
CHANGED