awful 0.0.161 → 0.0.162
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 +4 -4
- data/lib/awful/ami.rb +18 -21
- data/lib/awful/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c108b1b219d5b3b1f34c50c775a06e12070a5e8
|
4
|
+
data.tar.gz: 98a86eee58b229adc6ca819d1882ae29feccbdb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0777d9f98e288504f35f990422d7dec9d8911061b2825a577a4b27cf4adba37607ca70da86894953fe14274ed49a894d8378cbb5f0da160373a9421c68027490
|
7
|
+
data.tar.gz: 60db36d4cf8a4dade79edb173fe7738b1ee6a9bc848ba428111d37ab14ceb229036254276b387d530facee916b5bd90cb35e5fc94339815301f5e7f8485c1a15
|
data/lib/awful/ami.rb
CHANGED
@@ -6,8 +6,8 @@ module Awful
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Ami < Cli
|
9
|
-
class_option :owners, aliases: '-o', type: :
|
10
|
-
class_option :filters, aliases: '-f', type: :array,
|
9
|
+
class_option :owners, aliases: '-o', type: :array, default: %w[self], desc: 'List images with this owner'
|
10
|
+
class_option :filters, aliases: '-f', type: :array, default: [], desc: 'Filter using name=value, eg tag:Foo=bar, multiples are ANDed'
|
11
11
|
|
12
12
|
COLORS = {
|
13
13
|
available: :green,
|
@@ -16,15 +16,17 @@ module Awful
|
|
16
16
|
}
|
17
17
|
|
18
18
|
no_commands do
|
19
|
-
def images(
|
19
|
+
def images(*image_ids)
|
20
20
|
params = {
|
21
|
-
|
21
|
+
image_ids: Array(image_ids),
|
22
|
+
owners: options[:owners],
|
22
23
|
filters: options[:filters].map do |tag|
|
23
24
|
k, v = tag.split('=')
|
24
25
|
{name: k, values: v.split(',')}
|
25
26
|
end
|
26
27
|
}.reject { |k,v| v.empty? }
|
27
|
-
|
28
|
+
|
29
|
+
ec2.describe_images(params).images
|
28
30
|
end
|
29
31
|
|
30
32
|
def color(string)
|
@@ -32,12 +34,10 @@ module Awful
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
desc 'ls [
|
37
|
+
desc 'ls [IDS]', 'list AMIs'
|
36
38
|
method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
|
37
|
-
def ls(
|
38
|
-
images(
|
39
|
-
image.name.match(name)
|
40
|
-
end.output do |list|
|
39
|
+
def ls(*ids)
|
40
|
+
images(*ids).output do |list|
|
41
41
|
if options[:long]
|
42
42
|
print_table list.map { |i|
|
43
43
|
[ i.name, i.image_id, i.root_device_type, color(i.state), i.creation_date, i.tags.map{ |t| "#{t.key}=#{t.value}" }.sort.join(',') ]
|
@@ -48,20 +48,17 @@ module Awful
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
desc 'delete
|
51
|
+
desc 'delete ID', 'delete AMI'
|
52
52
|
def delete(id)
|
53
|
-
images(
|
54
|
-
|
55
|
-
|
56
|
-
if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow
|
57
|
-
ec2.deregister_image(image_id: ami.image_id)
|
58
|
-
end
|
53
|
+
ami = images(id).first
|
54
|
+
if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow
|
55
|
+
ec2.deregister_image(image_id: ami.image_id)
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
62
59
|
desc 'dump IDS', 'describe images'
|
63
60
|
def dump(*ids)
|
64
|
-
|
61
|
+
images(*ids).output do |images|
|
65
62
|
images.each do |image|
|
66
63
|
puts YAML.dump(stringify_keys(image.to_hash))
|
67
64
|
end
|
@@ -71,8 +68,8 @@ module Awful
|
|
71
68
|
desc 'tags ID [TAGS]', 'get tags for AMI, or set multiple tags as key:value'
|
72
69
|
def tags(id, *tags)
|
73
70
|
if tags.empty?
|
74
|
-
|
75
|
-
print_table
|
71
|
+
images(id).first.tags.output do |tags|
|
72
|
+
print_table tags.map { |t| [t.key, t.value] }
|
76
73
|
end
|
77
74
|
else
|
78
75
|
ec2.create_tags(
|
@@ -100,7 +97,7 @@ module Awful
|
|
100
97
|
desc 'last NAME', 'get ids of last (by creation date) AMIs [matching NAME]'
|
101
98
|
method_option :count, aliases: '-n', type: :numeric, default: 1, desc: 'Return N results'
|
102
99
|
def last(name = /./)
|
103
|
-
images
|
100
|
+
images.select do |image|
|
104
101
|
image.name.match(name)
|
105
102
|
end.sort_by(&:creation_date).last(options[:count]).map do |image|
|
106
103
|
image.image_id
|
data/lib/awful/version.rb
CHANGED