awful 0.0.33 → 0.0.34

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: f37094621cce1973896114b3806bbc9c9fbf8ab0
4
- data.tar.gz: 5447b9590bf70c2b9289c069c8395c3f79806744
3
+ metadata.gz: a551cb4dbe1136540c75856683dae9bb4b0b970c
4
+ data.tar.gz: 822ff26d3ff6b5e645cf9e8be199dad68229bbe9
5
5
  SHA512:
6
- metadata.gz: 4ac0de6a8d3cb0c8d702827e20155d25193ed44ce9614f31c6b79ee7b14c00fa24ac5d7c0af5cb4c870c1205013bf68b92dbbe6b102cfe93e8e8d8920f6e8d28
7
- data.tar.gz: 12d1a194550ff815ddb52f830c6b1f7de94bf28cf1eefd2b67366c6f5c6f7143bf2718332ebecddcb115764bdf0f53119c444c759b19f6141e81af9249e6500a
6
+ metadata.gz: 6b326241de113bd37d6be5f8ed57e010442735f24113ca08c8c7ef2e7a67baa672e5d89283c28cd9b358cd23773ca16d14091a83a32c5cbe2fff427ff1142223
7
+ data.tar.gz: d918d16882a24b63d36222fab8923d858ecdf2f1a674ff011430066e5e6a69ce1f15d45603b09522379f89c0365dbaca581375d8588d28c18bc9f614274d01a4
@@ -252,34 +252,41 @@ module Awful
252
252
  end
253
253
  end
254
254
 
255
- desc 'old_instances NAME', 'Deal with instances that are not on the ASG current launch config'
255
+ desc 'old_instances ASGS', 'Deal with instances that are not on their ASG current launch config'
256
256
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
257
+ method_option :groups, aliases: '-g', default: false, desc: 'Just list names of ASGs with outdated instances'
257
258
  method_option :detach, aliases: '-D', default: false, desc: 'Detach old instances from this ASG'
258
259
  method_option :decrement, aliases: '-d', default: false, desc: 'should decrement desired capacity when detaching instances from ASG'
259
260
  method_option :deregister, aliases: '-E', default: false, desc: 'Deregister old instances from ELB for this ASG'
260
261
  method_option :terminate, aliases: '-t', default: false, desc: 'Terminate old instances'
261
- def old_instances(name)
262
- asg = autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: [name]).map(&:auto_scaling_groups).flatten.first
263
- autoscaling.describe_auto_scaling_instances.map(&:auto_scaling_instances).flatten.select do |instance|
264
- instance.auto_scaling_group_name.match(name) and instance.launch_configuration_name != asg.launch_configuration_name
262
+ def old_instances(*names)
263
+ asgs = autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: names).map(&:auto_scaling_groups).flatten
264
+
265
+ asgs.each_with_object({}) do |asg, hash|
266
+ outdated = asg.instances.select do |instance|
267
+ instance.launch_configuration_name != asg.launch_configuration_name
268
+ end
269
+ hash[asg.auto_scaling_group_name] = outdated unless outdated.empty?
265
270
  end.tap do |olds|
266
271
  if olds.empty?
267
272
  # noop
268
273
  elsif options[:detach]
269
- autoscaling.detach_instances(auto_scaling_group_name: name, instance_ids: olds.map(&:instance_id), should_decrement_desired_capacity: options[:decrement])
274
+ autoscaling.detach_instances(auto_scaling_group_name: name, instance_ids: olds.values.flatten.map(&:instance_id), should_decrement_desired_capacity: options[:decrement])
270
275
  elsif options[:deregister]
271
276
  asg.load_balancer_names.map do |elb_name|
272
- elb.deregister_instances_from_load_balancer(load_balancer_name: elb_name, instances: olds.map { |i| { instance_id: i.instance_id } })
277
+ elb.deregister_instances_from_load_balancer(load_balancer_name: elb_name, instances: olds.values.flatten.map { |i| { instance_id: i.instance_id } })
273
278
  end.tap { puts "Deregistered: #{olds.map(&:instance_id).join(',')}" }
274
279
  elsif options[:terminate]
275
- olds.map do |instance|
280
+ olds.values.flatten.map do |instance|
276
281
  autoscaling.terminate_instance_in_auto_scaling_group(instance_id: instance.instance_id, should_decrement_desired_capacity: options[:decrement] && true)
277
282
  instance.instance_id
278
283
  end.tap { |ids| say("Terminated: #{ids.join(',')}", :yellow) }
284
+ elsif options[:groups]
285
+ puts olds.keys
279
286
  elsif options[:long]
280
- print_table olds.map { |i| [ i.instance_id, i.launch_configuration_name ] }
287
+ print_table olds.map { |asg, ins| ins.map { |i| [i.instance_id, asg, i.launch_configuration_name] }.flatten }
281
288
  else
282
- puts olds.map(&:instance_id)
289
+ puts olds.values.flatten.map(&:instance_id)
283
290
  end
284
291
  end
285
292
  end
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.33"
2
+ VERSION = "0.0.34"
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.33
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler