awful 0.0.132 → 0.0.133
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/ami.rb +5 -5
- data/lib/awful/dynamodb_streams.rb +3 -3
- data/lib/awful/ec2.rb +14 -14
- data/lib/awful/s3.rb +5 -5
- data/lib/awful/security_group.rb +3 -1
- 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: f20fa5e02041068d58d0a6eb5303dccf56af9bf4
|
4
|
+
data.tar.gz: ac99595963ec8e583cf7e80fa96866f15e884b56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a87db67e4ddea50a875c5f2b38d149921536227585b7abcaf0e79470b817ed47fc17788057ccb54b6a9c54992529fdf05c4945c705887738e52ec5f2481cb67
|
7
|
+
data.tar.gz: 924d74990c82d76e26acd21317557df931d96f14f80439680af6cf1573840038e3873068e12cb8aced59cf644def20e2d6b8ac6909fced12aee4e510a417e7f7
|
data/lib/awful/ami.rb
CHANGED
@@ -37,7 +37,7 @@ module Awful
|
|
37
37
|
def ls(name = /./)
|
38
38
|
images(options).select do |image|
|
39
39
|
image.name.match(name)
|
40
|
-
end.
|
40
|
+
end.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(',') ]
|
@@ -52,7 +52,7 @@ module Awful
|
|
52
52
|
def delete(id)
|
53
53
|
images(options).find do |image|
|
54
54
|
image.image_id.match(id)
|
55
|
-
end.
|
55
|
+
end.output do |ami|
|
56
56
|
if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow
|
57
57
|
ec2.deregister_image(image_id: ami.image_id)
|
58
58
|
end
|
@@ -61,7 +61,7 @@ module Awful
|
|
61
61
|
|
62
62
|
desc 'dump IDS', 'describe images'
|
63
63
|
def dump(*ids)
|
64
|
-
ec2.describe_images(image_ids: ids).images.
|
64
|
+
ec2.describe_images(image_ids: ids).images.output do |images|
|
65
65
|
images.each do |image|
|
66
66
|
puts YAML.dump(stringify_keys(image.to_hash))
|
67
67
|
end
|
@@ -71,7 +71,7 @@ module Awful
|
|
71
71
|
desc 'tags ID [TAGS]', 'get tags for AMI, or set multiple tags as key:value'
|
72
72
|
def tags(id, *tags)
|
73
73
|
if tags.empty?
|
74
|
-
ec2.describe_images(image_ids: [id]).images.first.tags.
|
74
|
+
ec2.describe_images(image_ids: [id]).images.first.tags.output do |list|
|
75
75
|
print_table list.map { |t| [t.key, t.value] }
|
76
76
|
end
|
77
77
|
else
|
@@ -104,7 +104,7 @@ module Awful
|
|
104
104
|
image.name.match(name)
|
105
105
|
end.sort_by(&:creation_date).last(options[:count]).map do |image|
|
106
106
|
image.image_id
|
107
|
-
end.
|
107
|
+
end.output do |list|
|
108
108
|
puts list
|
109
109
|
end
|
110
110
|
end
|
@@ -36,14 +36,14 @@ module Awful
|
|
36
36
|
|
37
37
|
desc 'dump ARN', 'describe the stream with ARN as yaml'
|
38
38
|
def dump(arn)
|
39
|
-
streams.describe_stream(stream_arn: arn).stream_description.
|
39
|
+
streams.describe_stream(stream_arn: arn).stream_description.output do |stream|
|
40
40
|
puts YAML.dump(stringify_keys(stream.to_hash))
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
desc 'shards ARN', 'list shards for stream with ARN'
|
45
45
|
def shards(arn)
|
46
|
-
streams.describe_stream(stream_arn: arn).stream_description.shards.
|
46
|
+
streams.describe_stream(stream_arn: arn).stream_description.shards.output do |shards|
|
47
47
|
puts shards.map(&:shard_id)
|
48
48
|
end
|
49
49
|
end
|
@@ -52,7 +52,7 @@ module Awful
|
|
52
52
|
def get_records(arn, shard_id)
|
53
53
|
iterator = streams.get_shard_iterator(stream_arn: arn, shard_id: shard_id, shard_iterator_type: 'TRIM_HORIZON').shard_iterator
|
54
54
|
|
55
|
-
streams.get_records(shard_iterator: iterator).records.
|
55
|
+
streams.get_records(shard_iterator: iterator).records.output do |records|
|
56
56
|
print_table records.map { |r| [r.event_id, r.event_name, r.dynamodb.sequence_number, r.dynamodb.size_bytes] }
|
57
57
|
end
|
58
58
|
end
|
data/lib/awful/ec2.rb
CHANGED
@@ -56,7 +56,7 @@ module Awful
|
|
56
56
|
instances.select! { |i| tag_name(i, '').match(name) } if name
|
57
57
|
|
58
58
|
## output
|
59
|
-
instances.
|
59
|
+
instances.output do |list|
|
60
60
|
if options[:long]
|
61
61
|
print_table list.map { |i|
|
62
62
|
[
|
@@ -81,7 +81,7 @@ module Awful
|
|
81
81
|
def dump(name)
|
82
82
|
ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
|
83
83
|
instance.instance_id == name or tag_name(instance) == name
|
84
|
-
end.
|
84
|
+
end.output do |instance|
|
85
85
|
puts YAML.dump(stringify_keys(instance.to_hash))
|
86
86
|
end
|
87
87
|
end
|
@@ -106,7 +106,7 @@ module Awful
|
|
106
106
|
opt[:network_interfaces] ? (opt[:network_interfaces][0][:subnet_id] = subnet) : (opt[:subnet_id] = subnet)
|
107
107
|
end
|
108
108
|
|
109
|
-
(opt[:tags] = opt.fetch(:tags, [])).find_index { |t| t[:key] == 'Name' }.
|
109
|
+
(opt[:tags] = opt.fetch(:tags, [])).find_index { |t| t[:key] == 'Name' }.output do |index|
|
110
110
|
opt[:tags][index || 0] = {key: 'Name', value: name}
|
111
111
|
end
|
112
112
|
|
@@ -135,7 +135,7 @@ module Awful
|
|
135
135
|
## report DNS or IP for instance
|
136
136
|
ec2.describe_instances(instance_ids: ids).map(&:reservations).flatten.map(&:instances).flatten.map do |instance|
|
137
137
|
instance.public_dns_name or instance.public_ip_address or instance.private_ip_address
|
138
|
-
end.
|
138
|
+
end.output do |list|
|
139
139
|
puts list
|
140
140
|
end
|
141
141
|
end
|
@@ -143,7 +143,7 @@ module Awful
|
|
143
143
|
desc 'az', 'list availability zones'
|
144
144
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
145
145
|
def az
|
146
|
-
ec2.describe_availability_zones.availability_zones.
|
146
|
+
ec2.describe_availability_zones.availability_zones.output do |zones|
|
147
147
|
if options[:long]
|
148
148
|
print_table zones.map { |z| [z.zone_name, z.state, z.messages.join(',')] }
|
149
149
|
else
|
@@ -154,14 +154,14 @@ module Awful
|
|
154
154
|
|
155
155
|
desc 'allocate', 'allocate a new elastic IP address'
|
156
156
|
def allocate
|
157
|
-
ec2.allocate_address(domain: 'vpc').first.
|
157
|
+
ec2.allocate_address(domain: 'vpc').first.output do |eip|
|
158
158
|
puts eip.allocation_id, eip.public_ip
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
desc 'associate NAME IP', 'associate a public ip with an instance'
|
163
163
|
def associate(name, eip)
|
164
|
-
ec2.associate_address(instance_id: find_instance(name), allocation_id: eip).map(&:association_id).
|
164
|
+
ec2.associate_address(instance_id: find_instance(name), allocation_id: eip).map(&:association_id).output do |id|
|
165
165
|
puts id
|
166
166
|
end
|
167
167
|
end
|
@@ -170,7 +170,7 @@ module Awful
|
|
170
170
|
def addresses
|
171
171
|
ec2.describe_addresses.map(&:addresses).flatten.map do |ip|
|
172
172
|
[ ip.allocation_id, ip.public_ip, ip.instance_id, ip.domain ]
|
173
|
-
end.
|
173
|
+
end.output do |list|
|
174
174
|
print_table list
|
175
175
|
end
|
176
176
|
end
|
@@ -179,7 +179,7 @@ module Awful
|
|
179
179
|
def dns(name)
|
180
180
|
ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
|
181
181
|
instance.instance_id == name or (n = tag_name(instance) and n.match(name))
|
182
|
-
end.public_dns_name.
|
182
|
+
end.public_dns_name.output do |dns|
|
183
183
|
puts dns
|
184
184
|
end
|
185
185
|
end
|
@@ -189,7 +189,7 @@ module Awful
|
|
189
189
|
# opt = load_cfg(options)
|
190
190
|
# ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
|
191
191
|
# instance.instance_id == name or (n = tag_name(instance) and n.match(name))
|
192
|
-
# end.
|
192
|
+
# end.output do |instance|
|
193
193
|
# ec2.modify_instance_attribute(instance_id: instance.instance_id, user_data: {
|
194
194
|
# #value: Base64.strict_encode64(opt[:user_data])
|
195
195
|
# value: opt[:user_data]
|
@@ -201,8 +201,8 @@ module Awful
|
|
201
201
|
def user_data(name)
|
202
202
|
ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
|
203
203
|
instance.instance_id == name or tag_name(instance) == name
|
204
|
-
end.
|
205
|
-
ec2.describe_instance_attribute(instance_id: instance.instance_id, attribute: 'userData').user_data.value.
|
204
|
+
end.output do |instance|
|
205
|
+
ec2.describe_instance_attribute(instance_id: instance.instance_id, attribute: 'userData').user_data.value.output do |user_data|
|
206
206
|
puts Base64.strict_decode64(user_data)
|
207
207
|
end
|
208
208
|
end
|
@@ -212,7 +212,7 @@ module Awful
|
|
212
212
|
def stop(name)
|
213
213
|
ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
|
214
214
|
instance.instance_id == name or (n = tag_name(instance) and n == name)
|
215
|
-
end.instance_id.
|
215
|
+
end.instance_id.output do |id|
|
216
216
|
if yes? "Really stop instance #{name} (#{id})?", :yellow
|
217
217
|
ec2.stop_instances(instance_ids: Array(id))
|
218
218
|
end
|
@@ -223,7 +223,7 @@ module Awful
|
|
223
223
|
def start(name)
|
224
224
|
ec2.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.find do |instance|
|
225
225
|
instance.instance_id == name or (n = tag_name(instance) and n == name)
|
226
|
-
end.instance_id.
|
226
|
+
end.instance_id.output do |id|
|
227
227
|
ec2.start_instances(instance_ids: Array(id))
|
228
228
|
end
|
229
229
|
end
|
data/lib/awful/s3.rb
CHANGED
@@ -35,7 +35,7 @@ module Awful
|
|
35
35
|
def buckets(name = /./)
|
36
36
|
s3.list_buckets.buckets.select do |bucket|
|
37
37
|
bucket.name.match(/#{name}/)
|
38
|
-
end.
|
38
|
+
end.output do |list|
|
39
39
|
if options[:long]
|
40
40
|
print_table list.map { |b| [ b.name, b.creation_date ] }
|
41
41
|
else
|
@@ -48,7 +48,7 @@ module Awful
|
|
48
48
|
def objects(bucket, prefix = nil)
|
49
49
|
s3_resource.bucket(bucket).objects(prefix: prefix).map do |object|
|
50
50
|
object.key
|
51
|
-
end.
|
51
|
+
end.output { |list| puts list }
|
52
52
|
end
|
53
53
|
|
54
54
|
desc 'exists? NAME', 'test if bucket exists'
|
@@ -57,12 +57,12 @@ module Awful
|
|
57
57
|
s3.head_bucket(bucket: bucket_name) && true
|
58
58
|
rescue Aws::S3::Errors::NotFound
|
59
59
|
false
|
60
|
-
end.
|
60
|
+
end.output(&method(:puts))
|
61
61
|
end
|
62
62
|
|
63
63
|
desc 'empty? NAME', 'test if bucket is empty'
|
64
64
|
def empty?(bucket_name)
|
65
|
-
s3.list_objects(bucket: bucket_name, max_keys: 1).contents.empty?.
|
65
|
+
s3.list_objects(bucket: bucket_name, max_keys: 1).contents.empty?.output(&method(:puts))
|
66
66
|
end
|
67
67
|
|
68
68
|
desc 'tagged [NAME_PREFIX]', 'list buckets matching given tags'
|
@@ -89,7 +89,7 @@ module Awful
|
|
89
89
|
tags.any? do |set|
|
90
90
|
conditions.any? { |c| c.call(set) }
|
91
91
|
end && bucket
|
92
|
-
end.select{|b| b}.
|
92
|
+
end.select{|b| b}.output do |buckets|
|
93
93
|
puts buckets.map(&:name)
|
94
94
|
end
|
95
95
|
end
|
data/lib/awful/security_group.rb
CHANGED
@@ -91,7 +91,9 @@ module Awful
|
|
91
91
|
## invoked from code, process ip_permissions objects as args
|
92
92
|
perms = ip_permissions.map do |p|
|
93
93
|
p.to_hash.tap do |h|
|
94
|
-
h
|
94
|
+
h.each do |k,v|
|
95
|
+
h[k] = nil if (v.respond_to?(:empty?) && v.empty?) # no empty arrays, e.g. user_group_id_pairs, prefix_list_ids
|
96
|
+
end
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
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.133
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|