awsutils 2.1.7 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/awsutils/ec2latestimage.rb +43 -14
- data/lib/awsutils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f7be6a7b15199b892d2e54109ff3da6a684586b12abf22a9103764cdcee21c19
|
4
|
+
data.tar.gz: 0cc296c1b47c529ee5925f42e49d676cfe12c0527880b45bfe9edbb03d9c6a0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 972a9b9365e220317071483ccc34f8b740df251be2f14d4112beb5cee555ffaceded4a66f39391be86d724e498e73da7d737e96e755aa5d7ea901d9d76566239
|
7
|
+
data.tar.gz: 15b3ed991715a078fe8079a65c15c382374cd0bd2779750ffda433e60b84620f7bbb0911c48b472a3724fbd4302e7a9cc8cca7f543047f0d98deacac05db3686
|
@@ -7,15 +7,40 @@ module AwsUtils
|
|
7
7
|
class Ec2LatestImage
|
8
8
|
def releases
|
9
9
|
@releases ||= begin
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
parsed_releases =
|
11
|
+
if opts[:ownedbyme]
|
12
|
+
fail 'AWS_OWNER_ID not defined' unless ENV['AWS_OWNER_ID']
|
13
|
+
|
14
|
+
require 'aws-sdk'
|
15
|
+
|
16
|
+
ubuntu_images =
|
17
|
+
connection.describe_images(owners: [ENV['AWS_OWNER_ID']]).images.select do |image|
|
18
|
+
image.name =~ %r{^ubuntu\/}
|
19
|
+
end
|
20
|
+
|
21
|
+
ubuntu_images.map do |image|
|
22
|
+
{
|
23
|
+
ami: image.image_id,
|
24
|
+
distro_version: image.name.split('/')[3].split('-')[2],
|
25
|
+
release: image.name.split('/')[3].split('-')[5..-1].join('-'),
|
26
|
+
type: image.name.split('/')[2] + ':' + image.root_device_type,
|
27
|
+
arch: image.architecture,
|
28
|
+
region: opts[:region] # overriding this because images API doesn't list a region
|
29
|
+
}
|
30
|
+
end
|
31
|
+
else
|
32
|
+
resp = JSON.parse(
|
33
|
+
Net::HTTP.get(
|
34
|
+
URI("http://cloud-images.ubuntu.com/locator/ec2/releasesTable?_=#{(Time.now.to_f*1000).to_i}")
|
35
|
+
).sub(/\],\n\]/, "]\n]")
|
36
|
+
)
|
37
|
+
parse_releases_array(resp['aaData'])
|
38
|
+
end
|
39
|
+
|
40
|
+
parsed_releases.select do |rel|
|
41
|
+
rel[:region] == opts[:region] &&
|
17
42
|
rel[:distro_version] == "#{opts[:release]}" &&
|
18
|
-
rel[:arch]
|
43
|
+
%w(amd64 x86_64).include?(rel[:arch])
|
19
44
|
end
|
20
45
|
end
|
21
46
|
end
|
@@ -28,18 +53,18 @@ module AwsUtils
|
|
28
53
|
|
29
54
|
def print_releases
|
30
55
|
# Print a header
|
31
|
-
printf("%-13s %-10s %-
|
56
|
+
printf("%-13s %-10s %-20s %-9s\n", 'ID', 'Version', 'Type', 'Release')
|
32
57
|
|
33
|
-
puts('-' *
|
58
|
+
puts('-' * 72)
|
34
59
|
|
35
60
|
# Print the releases
|
36
61
|
releases.each do |rel|
|
37
62
|
printf(
|
38
|
-
"%-13s %-10s %-
|
63
|
+
"%-13s %-10s %-20s %-9s\n",
|
39
64
|
rel[:ami],
|
40
65
|
rel[:distro_version],
|
41
|
-
rel[:
|
42
|
-
rel[:
|
66
|
+
rel[:type],
|
67
|
+
rel[:release]
|
43
68
|
)
|
44
69
|
end
|
45
70
|
end
|
@@ -83,7 +108,11 @@ module AwsUtils
|
|
83
108
|
end
|
84
109
|
|
85
110
|
def opts
|
86
|
-
@opts ||= Trollop.options
|
111
|
+
@opts ||= Trollop.options do
|
112
|
+
opt :release, 'Ubuntu release', short: 'r', default: '16.04 LTS'
|
113
|
+
opt :ownedbyme, 'Images owned by $AWS_OWNER_ID', short: 'o', default: false
|
114
|
+
opt :region, 'Image region', short: 'R', default: 'us-east-1'
|
115
|
+
end
|
87
116
|
end
|
88
117
|
end
|
89
118
|
end
|
data/lib/awsutils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awsutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Herot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
version: '0'
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.
|
249
|
+
rubygems_version: 2.7.7
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: A set of tools for interacting with AWS (summary)
|