awful 0.0.67 → 0.0.68

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: 3417964c4b141a0c31c4c3f3b138d272c5f11a61
4
- data.tar.gz: 057174af836697f83f6763a5a9a994df3359bc3e
3
+ metadata.gz: 806fec97b5fd5d94c3054e05dfd79bb16e7db4a1
4
+ data.tar.gz: 47a150687554af433f94f94b400676a082c41777
5
5
  SHA512:
6
- metadata.gz: 4524049f3348effb159b96fa99291c173dc0b423675c2317008e6414a4443dab6fcef8a1353f7c421373ad2a66ff8142c0735d9762a58593efddc4dd61d40a26
7
- data.tar.gz: 6df9d07aadd7cf07a1f495fa8f188a6e1f7f23ad2c6dfeaa0fb62fdf9f6789e32eb2c883aa56f3bbd9565abfd49d408fadb407f4949ceed32093cb20fafb5e8a
6
+ metadata.gz: 9505b1e92b936872a0e7eab63c5a22e2ccbb2e9a5202ab824f2ac45b54c226b03067e498e73a2376f115a7cc3f50918931b502e388e6eadd6a6c67e0cbd87fd6
7
+ data.tar.gz: 19bbe64490df435acbfcc8577da080d9114afa1ff5e0d6d187f99ee3b83caddcb3f55daf18c493fb30f4ec472fff84a91d18f3120eb2dd0bcd82611f9c41da8e
data/lib/awful/ami.rb CHANGED
@@ -1,27 +1,45 @@
1
1
  module Awful
2
2
 
3
3
  class Ami < Cli
4
- class_option :owners, aliases: '-o', default: 'self', desc: 'List images with this owner'
4
+ class_option :owners, aliases: '-o', type: :string, default: 'self', desc: 'List images with this owner'
5
+ class_option :filters, aliases: 'f', type: :array, default: [], desc: 'Filter using name=value, eg tag:Foo=bar, multiples are ANDed'
6
+
7
+ COLORS = {
8
+ available: :green,
9
+ pending: :yellow,
10
+ failed: :red,
11
+ }
5
12
 
6
13
  no_commands do
7
14
  def images(options)
8
- ec2.describe_images(owners: options[:owners].split(',')).map(&:images).flatten
15
+ params = {
16
+ owners: options[:owners].split(','),
17
+ filters: options[:filters].map do |tag|
18
+ k, v = tag.split('=')
19
+ {name: k, values: v.split(',')}
20
+ end
21
+ }.reject { |k,v| v.empty? }
22
+ ec2.describe_images(params).map(&:images).flatten
23
+ end
24
+
25
+ def color(string)
26
+ set_color(string, COLORS.fetch(string.to_sym, :yellow))
9
27
  end
10
28
  end
11
29
 
12
30
  desc 'ls [PATTERN]', 'list AMIs'
13
31
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
14
32
  def ls(name = /./)
15
- fields = options[:long] ?
16
- ->(i) { [ i.name, i.image_id, i.root_device_type, i.state, i.creation_date, i.tags.map{ |t| "#{t.key}=#{t.value}" }.sort.join(',') ] } :
17
- ->(i) { [ i.image_id ] }
18
-
19
33
  images(options).select do |image|
20
34
  image.name.match(name)
21
- end.map do |image|
22
- fields.call(image)
23
35
  end.tap do |list|
24
- print_table list.sort
36
+ if options[:long]
37
+ print_table list.map { |i|
38
+ [ 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(',') ]
39
+ }.sort
40
+ else
41
+ puts list.map(&:name).sort
42
+ end
25
43
  end
26
44
  end
27
45
 
@@ -61,11 +79,12 @@ module Awful
61
79
  # end
62
80
  # end
63
81
 
64
- desc 'last NAME', 'get last AMI matching NAME'
65
- def last(name, n = 1)
82
+ desc 'last NAME', 'get id of last (by creation date) AMI [matching NAME]'
83
+ method_option :count, aliases: '-n', type: :numeric, default: 1, desc: 'Return N results'
84
+ def last(name = /./)
66
85
  images(options).select do |image|
67
86
  image.name.match(name)
68
- end.sort_by { |i| i.creation_date }.last(n.to_i).map do |image|
87
+ end.sort_by(&:creation_date).last(options[:count]).map do |image|
69
88
  image.image_id
70
89
  end.tap do |list|
71
90
  puts list
@@ -74,4 +93,4 @@ module Awful
74
93
 
75
94
  end
76
95
 
77
- end
96
+ end
@@ -90,6 +90,15 @@ module Awful
90
90
  end
91
91
  end
92
92
 
93
+ desc 'stream_specification NAME', 'enable/disable streams on the table'
94
+ method_option :stream_view_type, aliases: '-t', default: 'NEW_IMAGE', desc: 'view type for the stream (NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES, KEYS_ONLY)'
95
+ method_option :disable, aliases: '-d', default: false, desc: 'disable the stream'
96
+ def stream_specification(name)
97
+ stream_specification = {stream_enabled: !options[:disable]}
98
+ stream_specification.merge!(stream_view_type: options[:stream_view_type].upcase) unless options[:disable]
99
+ dynamodb.update_table(table_name: name, stream_specification: stream_specification)
100
+ end
101
+
93
102
  desc 'delete NAME', 'delete table with NAME'
94
103
  def delete_table(name)
95
104
  confirmation = ask("to delete #{name} and all its data, type the name of table to delete:", :yellow)
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.67"
2
+ VERSION = "0.0.68"
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.67
4
+ version: 0.0.68
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-11-20 00:00:00.000000000 Z
11
+ date: 2015-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler