coreos_ami 0.0.1
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 +7 -0
- data/.gitignore +13 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +2 -0
- data/bin/coreos_ami +22 -0
- data/coreos_ami.gemspec +25 -0
- data/lib/coreos_ami/version.rb +3 -0
- data/lib/coreos_ami.rb +46 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d421d6693f39a68d9e10f7c7c3abff1c7f818e3
|
4
|
+
data.tar.gz: ca262611bff4a20622e82536dcf27e69e922e91d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5694f25f39e5a31579cd49ee75b82ad6f7531331548834d6523110ccdd5f02283d33cf6af3f78b3db3db7bb7189a97450c35f4ac942ff1705c4632c07a764f98
|
7
|
+
data.tar.gz: 6d6789ca250c3b82349d402dcecf52d4eb205600e254a5cf6d85349702b1b5a2c1ca40f0f211255a5227ef843691ab4b98e3346b3367b76c588e31b644c46ca4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Richard Lister
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# coreos_ami
|
2
|
+
|
3
|
+
Ruby gem to discover CoreOS AMIs for AWS.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'coreos_ami'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install coreos_ami
|
23
|
+
```
|
24
|
+
|
25
|
+
## Library usage
|
26
|
+
|
27
|
+
### Get AMI for a given channel and release
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'coreos_ami'
|
31
|
+
CoreOS.channel('stable').ami
|
32
|
+
=> "ami-8297d4ea"
|
33
|
+
```
|
34
|
+
|
35
|
+
Default region will be set to environment variable
|
36
|
+
`AWS_DEFAULT_REGION` (or `us-east-1` if empty). Virtualization type
|
37
|
+
will default to `hvm`, and release will default to `current`.
|
38
|
+
|
39
|
+
Different channels, releases, and virtualization type may be
|
40
|
+
requested:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
CoreOS.channel('beta').ami(release: '522.5.0', virtualization: 'pv')
|
44
|
+
=> "ami-3ed7a456"
|
45
|
+
```
|
46
|
+
|
47
|
+
### Get list of AMIs
|
48
|
+
|
49
|
+
Return a hash of all AMIs for requested channel and release:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
CoreOS.channel('stable').amis
|
53
|
+
=> {"amis"=>[{"name"=>"eu-central-1", "pv"=>"ami-88c1f295", "hvm"=>"ami-8ec1f293"}, {"name"=>"ap-northeast-1", "pv"=>"ami-ea5c46eb", "hvm"=>"ami-e85c46e9"}, {"name"=>"sa-east-1", "pv"=>"ami-2fe95632", "hvm"=>"ami-2de95630"}, {"name"=>"ap-southeast-2", "pv"=>"ami-4fd3a775", "hvm"=>"ami-4dd3a777"}, {"name"=>"ap-southeast-1", "pv"=>"ami-70dcf622", "hvm"=>"ami-72dcf620"}, {"name"=>"us-east-1", "pv"=>"ami-8097d4e8", "hvm"=>"ami-8297d4ea"}, {"name"=>"us-west-2", "pv"=>"ami-f3702bc3", "hvm"=>"ami-f1702bc1"}, {"name"=>"us-west-1", "pv"=>"ami-26b5ad63", "hvm"=>"ami-24b5ad61"}, {"name"=>"eu-west-1", "pv"=>"ami-5b911f2c", "hvm"=>"ami-5d911f2a"}]}
|
54
|
+
```
|
55
|
+
|
56
|
+
### Command-line client
|
57
|
+
|
58
|
+
A simple command-line tool is included to perform the same requests,
|
59
|
+
with similar defaults:
|
60
|
+
|
61
|
+
```
|
62
|
+
$ coreos_ami -c beta -r 522.5.0 -v pv
|
63
|
+
ami-3ed7a456
|
64
|
+
```
|
65
|
+
|
66
|
+
Use `-a` or `--all` to list all AMIs:
|
67
|
+
|
68
|
+
```
|
69
|
+
$ coreos_ami -a -c stable
|
70
|
+
NAME PV HVM
|
71
|
+
eu-central-1 ami-88c1f295 ami-8ec1f293
|
72
|
+
ap-northeast-1 ami-ea5c46eb ami-e85c46e9
|
73
|
+
sa-east-1 ami-2fe95632 ami-2de95630
|
74
|
+
ap-southeast-2 ami-4fd3a775 ami-4dd3a777
|
75
|
+
ap-southeast-1 ami-70dcf622 ami-72dcf620
|
76
|
+
us-east-1 ami-8097d4e8 ami-8297d4ea
|
77
|
+
us-west-2 ami-f3702bc3 ami-f1702bc1
|
78
|
+
us-west-1 ami-26b5ad63 ami-24b5ad61
|
79
|
+
eu-west-1 ami-5b911f2c ami-5d911f2a
|
80
|
+
```
|
data/Rakefile
ADDED
data/bin/coreos_ami
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#-*- mode: ruby; -*-
|
3
|
+
|
4
|
+
require 'coreos_ami'
|
5
|
+
require 'trollop'
|
6
|
+
|
7
|
+
opts = Trollop::options do
|
8
|
+
opt :all, 'Show all AMIs'
|
9
|
+
opt :channel, 'Channel: stable, beta or alpha', type: :string, default: 'stable'
|
10
|
+
opt :release, 'Release version', type: :string, default: 'current'
|
11
|
+
opt :virtualization, 'Virtualization type: hvm or pv', type: :string, default: 'hvm'
|
12
|
+
end
|
13
|
+
|
14
|
+
if opts[:all]
|
15
|
+
columns = [ 'name', 'pv', 'hvm' ]
|
16
|
+
amis = CoreOS.channel(opts[:channel]).amis(release: opts[:release])['amis'].map do |region|
|
17
|
+
region.values_at(*columns).join("\t")
|
18
|
+
end
|
19
|
+
puts columns.map(&:upcase).join("\t\t"), amis
|
20
|
+
else
|
21
|
+
puts CoreOS.channel(opts[:channel]).ami(opts)
|
22
|
+
end
|
data/coreos_ami.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coreos_ami/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coreos_ami"
|
8
|
+
spec.version = CoreosAmi::VERSION
|
9
|
+
spec.authors = ["Richard Lister"]
|
10
|
+
spec.email = ["rlister+gh@gmail.com"]
|
11
|
+
spec.summary = %q{Discover CoreOS AMIs.}
|
12
|
+
spec.description = %q{Discover CoreOS AMIs.}
|
13
|
+
spec.homepage = "https://github.com/rlister/coreos_ami"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency('trollop')
|
25
|
+
end
|
data/lib/coreos_ami.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'coreos_ami/version'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class CoreOS
|
6
|
+
DEFAULTS = {
|
7
|
+
release: :current,
|
8
|
+
virtualization: :hvm,
|
9
|
+
region: ENV['AWS_DEFAULT_REGION'] || 'us-east-1'
|
10
|
+
}
|
11
|
+
|
12
|
+
def initialize(channel = :stable)
|
13
|
+
@channel = channel
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.channel(channel_name)
|
17
|
+
new(channel_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def base_url
|
21
|
+
"http://#{@channel}.release.core-os.net/amd64-usr"
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(uri)
|
25
|
+
begin
|
26
|
+
Net::HTTP.get_response(URI.parse(uri)).body.chomp
|
27
|
+
rescue => e
|
28
|
+
raise "Error with coreos url: #{uri}: #{e.message}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
## return hash of all AMIs for release version
|
33
|
+
def amis(opt = {})
|
34
|
+
args = DEFAULTS.merge(opt)
|
35
|
+
path = [ base_url, args[:release].to_s, 'coreos_production_ami_all.json' ].join('/')
|
36
|
+
JSON.parse(get(path))
|
37
|
+
end
|
38
|
+
|
39
|
+
## return AMI name as string
|
40
|
+
def ami(opt = {})
|
41
|
+
args = DEFAULTS.merge(opt)
|
42
|
+
path = [ base_url, args[:release].to_s, "coreos_production_ami_#{args[:virtualization]}_#{args[:region]}.txt" ].join('/')
|
43
|
+
get(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coreos_ami
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Lister
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: trollop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Discover CoreOS AMIs.
|
56
|
+
email:
|
57
|
+
- rlister+gh@gmail.com
|
58
|
+
executables:
|
59
|
+
- coreos_ami
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/coreos_ami
|
70
|
+
- coreos_ami.gemspec
|
71
|
+
- lib/coreos_ami.rb
|
72
|
+
- lib/coreos_ami/version.rb
|
73
|
+
homepage: https://github.com/rlister/coreos_ami
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Discover CoreOS AMIs.
|
97
|
+
test_files: []
|