awful 0.0.125 → 0.0.126

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
  SHA1:
3
- metadata.gz: 344579f6b39568f6f3c56f62baad2d3c8a31cc61
4
- data.tar.gz: fb71401f43a220dabe1a6275ceb3c32992715a3d
3
+ metadata.gz: ba519bdf7cee6a75862b71cb6e48e23fefdeabdf
4
+ data.tar.gz: 2c33ac07d9460d2650bb6987e02eb89dd2f602cd
5
5
  SHA512:
6
- metadata.gz: dc6f9ae6a2b727b69604e8239802ba082a33731edee4c6d5486f22536d043aa29f12c90cf249d916881d2ca54a9c3c3e103383ec712ee0c38d1a03972ef928bf
7
- data.tar.gz: 95a417937a0068dc135ede81034a0e992559ff0b324cc90401b63c1d5d0088a19408cbef3a2ad3f3d904e53fcd36ba67e628731d1f3167d03a63dca1a6f92e84
6
+ metadata.gz: d8d89602eb2213cf4f9ee90972bc2760f04224d0b653413a789e8309af5ee5ac451ebee0279478395699fe515148b234e8799d8a47e9b6e31c7dce2bfa01e44a
7
+ data.tar.gz: 8c221dcfb174f17b3e5b288f4dcf69a1615078acd3781626388da49bf865858fd5cffbf034d709a24fe70b4296b6174dca9bf89f9688e2bf9dd18e83873deab1
@@ -14,6 +14,9 @@ module Awful
14
14
  ## health statuses
15
15
  Healthy: :green,
16
16
  Unhealthy: :red,
17
+ ## same for asg instances describe
18
+ HEALTHY: :green,
19
+ UNHEALTHY: :red,
17
20
  ## activity status
18
21
  Successful: :green,
19
22
  Failed: :red,
@@ -43,7 +46,7 @@ module Awful
43
46
  desc 'ls [PATTERN]', 'list autoscaling groups with name matching PATTERN'
44
47
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
45
48
  def ls(name = /./)
46
- all_matching_asgs(name).tap do |asgs|
49
+ all_matching_asgs(name).output do |asgs|
47
50
  if options[:long]
48
51
  print_table asgs.map { |a|
49
52
  [
@@ -69,23 +72,31 @@ module Awful
69
72
  end
70
73
  end
71
74
 
72
- desc 'instances', 'list instances for instances in groups matching NAME'
73
- method_option :long, aliases: '-l', default: false, desc: 'Long listing'
74
- method_option :launch_configuration, aliases: '-L', default: false, desc: 'Get instance launch_configs'
75
- def instances(name)
76
- all_matching_asgs(name).map(&:instances).flatten.tap do |instances|
75
+ desc 'instances ASGS', 'describe autoscaling instances for groups'
76
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
77
+ method_option :describe, aliases: '-d', type: :boolean, default: false, desc: 'make extra call to get ASG name for each instance'
78
+ def instances(*names)
79
+ instances = autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: names).auto_scaling_groups.map(&:instances).flatten
80
+
81
+ ## make extra call to get asg name as part of object
82
+ if options[:describe]
83
+ instances = autoscaling.describe_auto_scaling_instances(instance_ids: instances.map(&:instance_id)).auto_scaling_instances
84
+ end
85
+
86
+ instances.output do |list|
77
87
  if options[:long]
78
- print_table instances.map { |i|
88
+ print_table list.map { |i|
79
89
  [
80
90
  i.instance_id,
91
+ options[:describe] ? i.auto_scaling_group_name : nil,
81
92
  i.availability_zone,
82
93
  color(i.lifecycle_state),
83
94
  color(i.health_status),
84
95
  i.launch_configuration_name,
85
- ]
96
+ ].compact
86
97
  }
87
98
  else
88
- puts instances.map(&:instance_id)
99
+ puts list.map(&:instance_id)
89
100
  end
90
101
  end
91
102
  end
@@ -97,7 +108,7 @@ module Awful
97
108
  ids = all_matching_asgs(name).map(&:instances).flatten.map(&:instance_id)
98
109
 
99
110
  ## get instance details for these IDs
100
- ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.sort_by(&:launch_time).tap do |instances|
111
+ ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.sort_by(&:launch_time).output do |instances|
101
112
  if options[:long]
102
113
  print_table instances.map { |i|
103
114
  [ i.public_ip_address, i.private_ip_address, i.instance_id, i.image_id, i.instance_type, i.placement.availability_zone, color(i.state.name), i.launch_time ]
@@ -124,7 +135,7 @@ module Awful
124
135
 
125
136
  desc 'dump NAME', 'dump existing autoscaling group as yaml'
126
137
  def dump(name)
127
- all_matching_asgs(name).map(&:to_hash).tap do |asgs|
138
+ all_matching_asgs(name).map(&:to_hash).output do |asgs|
128
139
  asgs.each do |asg|
129
140
  puts YAML.dump(stringify_keys(asg)) unless options[:quiet]
130
141
  end
@@ -233,7 +244,7 @@ module Awful
233
244
  method_option :newest, aliases: '-n', default: false, type: :boolean, desc: 'Stop newest instances instead of oldest'
234
245
  def stop(name, num = 1)
235
246
  ins = options[:newest] ? newest(name) : oldest(name)
236
- ins.first(num.to_i).map(&:instance_id).tap do |ids|
247
+ ins.first(num.to_i).map(&:instance_id).output do |ids|
237
248
  if yes? "Really stop #{num} instances: #{ids.join(',')}?", :yellow
238
249
  ec2.stop_instances(instance_ids: ids)
239
250
  end
@@ -242,7 +253,7 @@ module Awful
242
253
 
243
254
  desc 'processes', 'describe scaling process types for use with suspend/resume'
244
255
  def processes
245
- autoscaling.describe_scaling_process_types.processes.map(&:process_name).sort.tap do |procs|
256
+ autoscaling.describe_scaling_process_types.processes.map(&:process_name).sort.output do |procs|
246
257
  puts procs
247
258
  end
248
259
  end
@@ -251,7 +262,9 @@ module Awful
251
262
  method_option :list, aliases: '-l', default: false, type: :boolean, desc: 'list currently suspended processes'
252
263
  def suspend(name, *procs)
253
264
  if options[:list]
254
- autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: Array(name)).map(&:auto_scaling_groups).flatten.first.suspended_processes.tap do |list|
265
+ autoscaling.describe_auto_scaling_groups(
266
+ auto_scaling_group_names: Array(name)
267
+ ).map(&:auto_scaling_groups).flatten.first.suspended_processes.output do |list|
255
268
  print_table list.map{ |proc| [ proc.process_name, proc.suspension_reason] }
256
269
  end
257
270
  elsif procs.empty?
@@ -284,9 +297,11 @@ module Awful
284
297
  desc 'launch_configuration NAMES', 'get launch configs for given ASGs'
285
298
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
286
299
  def launch_configuration(*names)
287
- autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: names).map(&:auto_scaling_groups).flatten.each_with_object({}) do |asg, h|
300
+ autoscaling.describe_auto_scaling_groups(
301
+ auto_scaling_group_names: names
302
+ ).map(&:auto_scaling_groups).flatten.each_with_object({}) do |asg, h|
288
303
  h[asg.auto_scaling_group_name] = asg.launch_configuration_name
289
- end.tap do |hash|
304
+ end.output do |hash|
290
305
  if options[:long]
291
306
  print_table hash
292
307
  else
@@ -314,7 +329,7 @@ module Awful
314
329
  end
315
330
 
316
331
  if olds.empty?
317
- # noop
332
+ # noop
318
333
  elsif options[:detach]
319
334
  autoscaling.detach_instances(auto_scaling_group_name: name, instance_ids: olds.values.flatten.map(&:instance_id), should_decrement_desired_capacity: options[:decrement])
320
335
  elsif options[:deregister]
@@ -331,7 +346,7 @@ module Awful
331
346
  olds.values.flatten.map do |instance|
332
347
  autoscaling.terminate_instance_in_auto_scaling_group(instance_id: instance.instance_id, should_decrement_desired_capacity: options[:decrement] && true)
333
348
  instance.instance_id
334
- end.tap { |ids| say("Terminated: #{ids.join(',')}", :yellow) }
349
+ end.output { |ids| say("Terminated: #{ids.join(',')}", :yellow) }
335
350
  elsif options[:groups]
336
351
  puts olds.keys
337
352
  elsif options[:long]
@@ -347,7 +362,7 @@ module Awful
347
362
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
348
363
  method_option :cause, aliases: '-c', default: false, desc: 'Long listing with cause of activity'
349
364
  def activities(name)
350
- autoscaling.describe_scaling_activities(auto_scaling_group_name: name).activities.tap do |activities|
365
+ autoscaling.describe_scaling_activities(auto_scaling_group_name: name).activities.output do |activities|
351
366
  if options[:long]
352
367
  print_table activities.map { |a| [color(a.status_code), a.description, a.start_time, a.end_time] }
353
368
  elsif options[:cause]
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.125'
2
+ VERSION = '0.0.126'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.125
4
+ version: 0.0.126
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler