awful 0.0.38 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/auto_scaling.rb +28 -22
- data/lib/awful/s3.rb +26 -9
- data/lib/awful/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff4da95e3c0f20638173ed7fb22ee8e55708ff6c
|
4
|
+
data.tar.gz: a8f8d60efa566e0575c56be0c07ba6f8ad7451de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2908b7accf1edae0464a5fa48859559911db58ec7dcac5fbc901d06fa3367a619ce3309e0da7f90a92d04bdb8652d70ad0659b4f31bcfa292a31156462bbb9f3
|
7
|
+
data.tar.gz: 5870345390e1c1bf2a9df53c20ac899e28336a0833ff09fbde0de70d683a6b53fd9d62b2b52dc7578a8a5417b5e296e57d4aa2abf2ad90c0e202178604699eaa
|
data/lib/awful/auto_scaling.rb
CHANGED
@@ -265,35 +265,41 @@ module Awful
|
|
265
265
|
def old_instances(*names)
|
266
266
|
asgs = autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: names).map(&:auto_scaling_groups).flatten
|
267
267
|
|
268
|
-
|
268
|
+
## get hash of old instances by ASG name
|
269
|
+
olds = asgs.each_with_object({}) do |asg, hash|
|
269
270
|
outdated = asg.instances.select do |instance|
|
270
271
|
instance.launch_configuration_name != asg.launch_configuration_name
|
271
272
|
end
|
272
273
|
hash[asg.auto_scaling_group_name] = outdated unless outdated.empty?
|
273
|
-
end
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
olds.
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
puts olds.keys
|
289
|
-
elsif options[:long]
|
290
|
-
print_table olds.map { |asg, ins| ins.map { |i| [i.instance_id, asg, i.launch_configuration_name] }.flatten }
|
291
|
-
else
|
292
|
-
puts olds.values.flatten.map(&:instance_id)
|
274
|
+
end
|
275
|
+
|
276
|
+
if olds.empty?
|
277
|
+
# noop
|
278
|
+
elsif options[:detach]
|
279
|
+
autoscaling.detach_instances(auto_scaling_group_name: name, instance_ids: olds.values.flatten.map(&:instance_id), should_decrement_desired_capacity: options[:decrement])
|
280
|
+
elsif options[:deregister]
|
281
|
+
asgs.select do |asg|
|
282
|
+
olds.has_key?(asg.auto_scaling_group_name)
|
283
|
+
end.each do |asg|
|
284
|
+
instance_ids = olds[asg.auto_scaling_group_name].flatten.map(&:instance_id)
|
285
|
+
asg.load_balancer_names.each do |elb_name|
|
286
|
+
say "Deregistering #{instance_ids.join(',')} from ELB #{elb_name}", :yellow
|
287
|
+
elb.deregister_instances_from_load_balancer(load_balancer_name: elb_name, instances: instance_ids.map { |id| {instance_id: id} })
|
288
|
+
end
|
293
289
|
end
|
290
|
+
elsif options[:terminate]
|
291
|
+
olds.values.flatten.map do |instance|
|
292
|
+
autoscaling.terminate_instance_in_auto_scaling_group(instance_id: instance.instance_id, should_decrement_desired_capacity: options[:decrement] && true)
|
293
|
+
instance.instance_id
|
294
|
+
end.tap { |ids| say("Terminated: #{ids.join(',')}", :yellow) }
|
295
|
+
elsif options[:groups]
|
296
|
+
puts olds.keys
|
297
|
+
elsif options[:long]
|
298
|
+
print_table olds.map { |asg, ins| ins.map { |i| [i.instance_id, asg, i.launch_configuration_name] }.flatten }
|
299
|
+
else
|
300
|
+
puts olds.values.flatten.map(&:instance_id)
|
294
301
|
end
|
295
302
|
end
|
296
|
-
|
297
303
|
end
|
298
304
|
|
299
305
|
end
|
data/lib/awful/s3.rb
CHANGED
@@ -2,11 +2,31 @@ module Awful
|
|
2
2
|
|
3
3
|
class S3 < Cli
|
4
4
|
|
5
|
-
|
5
|
+
no_commands do
|
6
|
+
|
7
|
+
## resource interface to S3 commands
|
8
|
+
def s3_resource
|
9
|
+
Aws::S3::Resource.new(client: s3)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'ls PATTERN', 'list buckets or objects'
|
15
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
16
|
+
def ls(name = '.')
|
17
|
+
if name.include?('/')
|
18
|
+
bucket, prefix = name.split('/', 2)
|
19
|
+
invoke 'objects', [bucket, prefix], options
|
20
|
+
else
|
21
|
+
invoke 'buckets', [name], options
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'buckets [PATTERN]', 'list buckets'
|
6
26
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
7
|
-
def
|
27
|
+
def buckets(name = /./)
|
8
28
|
s3.list_buckets.buckets.select do |bucket|
|
9
|
-
bucket.name.match(name)
|
29
|
+
bucket.name.match(/#{name}/)
|
10
30
|
end.tap do |list|
|
11
31
|
if options[:long]
|
12
32
|
print_table list.map { |b| [ b.name, b.creation_date ] }
|
@@ -16,12 +36,9 @@ module Awful
|
|
16
36
|
end
|
17
37
|
end
|
18
38
|
|
19
|
-
desc '
|
20
|
-
def
|
21
|
-
|
22
|
-
# puts list
|
23
|
-
# end
|
24
|
-
Aws::S3::Resource.new(client: s3).bucket(bucket).objects(delimiter: '', prefix: prefix).map do |object|
|
39
|
+
desc 'objects BUCKET [PATTERN]', 'list objects in bucket'
|
40
|
+
def objects(bucket, prefix = nil)
|
41
|
+
s3_resource.bucket(bucket).objects(prefix: prefix).map do |object|
|
25
42
|
object.key
|
26
43
|
end.tap { |list| puts list }
|
27
44
|
end
|
data/lib/awful/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.39
|
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-09-
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|