awful 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ceac4c8b681f7ea2de4e426d2f78e768a065217
4
- data.tar.gz: da45884f218238540d27c290a5a27a508d062665
3
+ metadata.gz: 7ba0388507d7653bb8b4ef401bc97d0da22f7c4a
4
+ data.tar.gz: 4582b52d1c44a0262093dc4eaa3eb2ada5ac87ae
5
5
  SHA512:
6
- metadata.gz: 294f1ea043f6fbb40dfb501da356233019c2a48eba2782a47125d8adcfd230448b12529891398b0243ac4f79b8a3e6ac35288c51fcb743913ce4a02f4ce854a0
7
- data.tar.gz: a9a098280a15890f48fd7bad3bb8302394ef48b98299814c66c35147b43f2a21983f0b0b8352fe5034ccd2b4d7ff4fb214655100d1e143b7cbfa235171dd7f29
6
+ metadata.gz: 5696f5615837915f58f7cd9d70016684338bcb58c8fd622f3637ca45d9c6c901ab2038e928004bd3df10f6df413cf81a944893f72c2e30bef028be351a6715ca
7
+ data.tar.gz: f3a2a42c334f490ece190fa1be7f9e83699306d15a1b4028b114b56311f2634cc13f1876cced9b56f2f13f09afdc1550bd6b0a1793ffc4de3cf75cb0f16210e2
@@ -34,10 +34,17 @@ module Awful
34
34
  end
35
35
  end
36
36
 
37
- desc 'instances', 'list instance IDs for instances in groups matching NAME'
38
- method_option :long, aliases: '-l', default: false, desc: 'Long listing'
37
+ desc 'instances', 'list instances for instances in groups matching NAME'
38
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
39
+ method_option :launch_configuration, aliases: '-L', default: false, desc: 'Get instance launch_configs'
39
40
  def instances(name)
40
- fields = options[:long] ? %i[instance_id auto_scaling_group_name availability_zone lifecycle_state health_status launch_configuration_name] : %i[instance_id]
41
+ fields = if options[:long]
42
+ %i[ instance_id auto_scaling_group_name availability_zone lifecycle_state health_status launch_configuration_name ]
43
+ elsif options[:launch_configuration]
44
+ %i[ instance_id launch_configuration_name ]
45
+ else
46
+ %i[ instance_id ]
47
+ end
41
48
 
42
49
  autoscaling.describe_auto_scaling_instances.map(&:auto_scaling_instances).flatten.select do |instance|
43
50
  instance.auto_scaling_group_name.match(name)
@@ -245,6 +252,35 @@ module Awful
245
252
  end
246
253
  end
247
254
 
255
+ desc 'old_instances NAME', 'Deal with instances that are not on the ASG current launch config'
256
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
257
+ method_option :detach, aliases: '-D', default: false, desc: 'Detach old instances from this ASG'
258
+ method_option :decrement, aliases: '-d', default: false, desc: 'should decrement desired capacity when detaching instances from ASG'
259
+ method_option :deregister, aliases: '-E', default: false, desc: 'Deregister old instances from ELB for this ASG'
260
+ 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
265
+ end.tap do |olds|
266
+ if options[:detach]
267
+ autoscaling.detach_instances(auto_scaling_group_name: name, instance_ids: olds.map(&:instance_id), should_decrement_desired_capacity: options[:decrement])
268
+ elsif options[:deregister]
269
+ asg.load_balancer_names.each do |elb_name|
270
+ elb.deregister_instances_from_load_balancer(load_balancer_name: elb_name, instances: olds.map { |i| { instance_id: i.instance_id } })
271
+ end
272
+ elsif options[:terminate]
273
+ olds.each do |instance|
274
+ autoscaling.terminate_instance_in_auto_scaling_group(instance_id: instance.instance_id, should_decrement_desired_capacity: options[:decrement] && true)
275
+ end
276
+ elsif options[:long]
277
+ print_table olds.map { |i| [ i.instance_id, i.launch_configuration_name ] }
278
+ else
279
+ puts olds.map(&:instance_id)
280
+ end
281
+ end
282
+ end
283
+
248
284
  end
249
285
 
250
286
  end
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
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.20
4
+ version: 0.0.21
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-07-15 00:00:00.000000000 Z
11
+ date: 2015-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler