aly 0.3.1 → 0.3.4

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: 3a2457a76990e5b419f291514cc1fef338740d4d92ec8e1cafef0722f5a9e898
4
- data.tar.gz: 976571d639a35952bde380eac487c4d4532f5746d8c5ce39acc62f8d31dbb2d7
3
+ metadata.gz: 710c187d9fac4262f8c0507ba0334d54b983dd1bcdf19248e5f4cb2d52cf707d
4
+ data.tar.gz: ef60807c9b0184da58027f9048da53845924aaa5edcc4beac8c43d6dd0dd9236
5
5
  SHA512:
6
- metadata.gz: b243a6c0e3424e6078441fa504eedad8c88a32a032134a6494fc4fc40fa4819d030e1d26c2ae15a88754e4b8f7fa8d669c149b5322ecb8cf2929c41937074891
7
- data.tar.gz: 1c8dcfa337ab879b1fa4d45b7e92686286fee9c04e79231277cf6d051cacfc1c3e28b720b0e6aa709fc5f418164377718a65240fe40fadcba35411779cec443b
6
+ metadata.gz: f366b47ab659a41bb3e1d9aa78045e281fb3330b02fa41f193ed83561d50c5b8f4aef313f9916549081e0126a3284797c7b715136accc76eea1714da1abc99a3
7
+ data.tar.gz: 985ea70ca8b61ec19d9ab78c1db6f7692c5f5e992116f7b18c92c15943d0474165685530c2898f93e7bc1de5637f090fdd9839b3a79ef40ce655a72300f60b14
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aly (0.3.1)
4
+ aly (0.3.4)
5
5
  terminal-table (~> 1.8.0)
6
6
  thor (~> 0.20.0)
7
7
 
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['detail']
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['detail']
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['acl']
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['full']
274
+ if options[:full]
261
275
  full_slb(selected, eips, **options)
262
- elsif options['detail']
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
- if options['acl']
409
- acl_ids = listeners.flat_map { |listener| listener['AclIds'] || [] }.uniq
410
- unless acl_ids.empty?
411
- alc_entries = acl_ids.flat_map do |acl_id|
412
- attr = exec('slb', 'DescribeAccessControlListAttribute', "--AclId=#{acl_id}", **options)
413
- (attr.dig('AclEntrys', 'AclEntry') || []).each_with_index.map do |e, idx|
414
- {
415
- AclId: (idx.zero? ? attr['AclId'] : ''),
416
- AclName: (idx.zero? ? attr['AclName'] : ''),
417
- AclEntryIP: e['AclEntryIP'],
418
- AclEntryComment: e['AclEntryComment']
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['profile']}" if options['profile']
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aly
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.4"
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.3.1
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang