euca 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/euca.gemspec +1 -1
- data/lib/euca.rb +4 -1
- data/lib/euca/api.rb +8 -0
- data/lib/euca/api/address.rb +29 -0
- data/lib/euca/api/instance.rb +31 -0
- data/lib/euca/api/keypair.rb +23 -0
- data/lib/euca/model.rb +9 -6
- data/lib/euca/version.rb +1 -1
- data/spec/address_spec.rb +26 -0
- data/spec/fixtures/address.yml +5 -0
- data/spec/fixtures/instance.yml +19 -0
- data/spec/fixtures/keypairs.yml +2 -0
- data/spec/instance_spec.rb +21 -0
- data/spec/keypair_spec.rb +24 -0
- data/spec/model_spec.rb +1 -1
- data/spec/support/minitest_helper.rb +3 -0
- data/test2.p +17 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDc1ZDIwODNiNjJlZTMxODc4ZjdkMGJjYjdiNWI1NjY1ZjBlZGRjYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmMyYjgxZGMxOTZkNjdjMzU0MTIxZDc1ZGQ1NDUyMmVjNjdlZjBiYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWE1YTVlMDI3OWU5YTMyNDI5ZTQzOWQxMGNlNTRkODc0OTY1ZjYxOTg5MDVl
|
10
|
+
ZjEzNGFmOWQyOGFkODNhOTdkMzg1Y2RlMWYwMjFlOWI0OWNkYWU1N2NhNzU2
|
11
|
+
MTJlOWQ1YmE5MjgxNmNkMmNlZTU5NGVmMmFkMzk0NDE5ZTdlMTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGRiMWZkMTQ0MjkyZGNiMTgxZmI5Zjg3MDY1NGU2YTQ1Zjk4ZWU3YWJhNDRi
|
14
|
+
ZDczOGZmNmJiMDIxNjJiNGNiNjdmNjhhMjU1OTI2YzkxN2IwMGJhZDEyODc5
|
15
|
+
MTY3MDQwZjU3YTI2Njc2NTI0OGU0NTZiZWI4ZTA3MzYyYTdjYjI=
|
data/euca.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.5"
|
21
21
|
spec.add_development_dependency "rake"
|
22
22
|
spec.add_development_dependency "minitest"
|
23
|
-
spec.add_dependency 'pult', '~> 0.0.
|
23
|
+
spec.add_dependency 'pult', '~> 0.0.5'
|
24
24
|
spec.add_dependency 'vhs', '~> 0.0.1'
|
25
25
|
spec.add_dependency 'activesupport', '~> 4.0.2'
|
26
26
|
end
|
data/lib/euca.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'pult'
|
2
2
|
require 'vhs'
|
3
3
|
require "euca/version"
|
4
|
-
require "euca/
|
4
|
+
require "euca/api"
|
5
5
|
|
6
6
|
module Euca
|
7
7
|
BIN_NAME="euca2ools".freeze
|
8
8
|
BIN_VERSION="euca-version".freeze
|
9
|
+
UBUNTU_13_10="qmi-c4c45230"
|
10
|
+
UBUNTU_12_04="qmi-b58041dd"
|
11
|
+
T1_NANO="t1.nano"
|
9
12
|
|
10
13
|
def self.has_cli?
|
11
14
|
!(self.version =~ /\d+\.\d+\.\d+/).nil?
|
data/lib/euca/api.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Euca
|
2
|
+
class Address
|
3
|
+
|
4
|
+
include Euca::Model
|
5
|
+
|
6
|
+
TYPE_ID = "address"
|
7
|
+
TYPE_ATTRS = %w(type_id ip instance_id)
|
8
|
+
|
9
|
+
def self.create force = false
|
10
|
+
!force ? find_by(instance_id: "None") || allocate : allocate
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.destroy ip
|
14
|
+
euca("release-address", ip)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.associate instance_id, ip
|
18
|
+
euca("associate-address", "-i", instance_id, ip)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.allocate
|
24
|
+
euca("allocate-address").first
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Euca
|
2
|
+
class Instance
|
3
|
+
|
4
|
+
include Euca::Model
|
5
|
+
|
6
|
+
TYPE_ID = "instance"
|
7
|
+
TYPE_ATTRS = %w(type_id id image public_dns_name private_dns_name status group
|
8
|
+
ami_launch_index product_code instance_type launched_at zone kernel_id
|
9
|
+
ramdisk_id platform monitoring public_ip private_ip vpc_id subnet_id
|
10
|
+
root_type lifecycle spot_id license placement_group virtualization hypervisor
|
11
|
+
client_token security_group_id tenancy ebs_optimized)
|
12
|
+
|
13
|
+
def self.create *args
|
14
|
+
euca("run-instances",*args).first
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.destroy id
|
18
|
+
euca("terminate-instances",id).first
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.where *args
|
22
|
+
describe "--filter", *args
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.find_by *args
|
26
|
+
where(*args).first
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Euca
|
2
|
+
class Keypair
|
3
|
+
|
4
|
+
include Euca::Model
|
5
|
+
|
6
|
+
TYPE_ID = "keypair"
|
7
|
+
TYPE_ATTRS = %w(type id fingerprint)
|
8
|
+
|
9
|
+
def self.create email, path = "~/.ssh"
|
10
|
+
put :debug, email, path
|
11
|
+
|
12
|
+
keyfile = "#{path}/#{email}.id"
|
13
|
+
keypairs = euca("create-keypair", email, ">", keyfile)
|
14
|
+
sh("chmod 600 #{keyfile}")
|
15
|
+
{"id" => email}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.destroy id
|
19
|
+
euca("delete-keypair", id).first
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/euca/model.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'euca'
|
2
1
|
require 'euca/wrapper'
|
3
2
|
require 'active_support/inflector'
|
4
3
|
module Euca
|
@@ -13,12 +12,16 @@ module Euca
|
|
13
12
|
def all
|
14
13
|
describe
|
15
14
|
end
|
16
|
-
|
17
|
-
|
15
|
+
|
16
|
+
def where query = {}
|
17
|
+
all.select{ |m|
|
18
|
+
s = m.select{ |k,v| query.keys.include?(k.to_sym) }
|
19
|
+
s.values.sort == query.values.sort
|
20
|
+
}
|
21
|
+
end
|
22
|
+
def find_by query = {}
|
23
|
+
where(query).first
|
18
24
|
end
|
19
|
-
def find_by *args
|
20
|
-
where(*args).first
|
21
|
-
end
|
22
25
|
def find id
|
23
26
|
describe(id).first
|
24
27
|
end
|
data/lib/euca/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'support/minitest_helper'
|
2
|
+
require 'euca/api/address'
|
3
|
+
|
4
|
+
module Euca
|
5
|
+
describe Address do
|
6
|
+
|
7
|
+
it "finds unassociated ip unless foce given on create" do
|
8
|
+
wrapper = Address.wrapper
|
9
|
+
fixture = Address.wrapper.parse(fixture(:address)["free"])
|
10
|
+
|
11
|
+
mock = MiniTest::Mock.new
|
12
|
+
mock.expect :run, fixture, [ "describe-addresses" ]
|
13
|
+
mock.expect :run, fixture, [ "allocate-address" ]
|
14
|
+
|
15
|
+
|
16
|
+
Address.instance_variable_set "@wrapper",mock
|
17
|
+
|
18
|
+
address = Address.create
|
19
|
+
|
20
|
+
address["ip"].must_equal "46.149.28.166"
|
21
|
+
|
22
|
+
address = Address.create(true)
|
23
|
+
address["ip"].must_equal "46.149.28.166"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
registry: |
|
2
|
+
RESERVATION r-c5627bef 7e36d16f-19c1-404a-babb-36c8e3c6ddd9 default
|
3
|
+
INSTANCE i-c3d0e9df qmi-b58041dd i-46-149-29-23.compute.is-1.greenqloud.com running default 0 t1.nano 2014-02-17T01:19:04.000+00:00 is-1a 10.0.0.1 10.0.0.1
|
4
|
+
|
5
|
+
host: |
|
6
|
+
RESERVATION r-230d75e3 7e36d16f-19c1-404a-babb-36c8e3c6ddd9 default
|
7
|
+
INSTANCE i-6e13180f qmi-b58041dd i-46-149-29-252.compute.is-1.greenqloud.com running default 0 t1.nano 2014-02-16T16:56:07.000+00:00 is-1a 0.0.0.0 0.0.0.0
|
8
|
+
|
9
|
+
valid: |
|
10
|
+
RESERVATION r-230d75e3 7e36d16f-19c1-404a-babb-36c8e3c6ddd9 default
|
11
|
+
INSTANCE i-6e13180f qmi-b58041dd i-46-149-29-252.compute.is-1.greenqloud.com running default 0 t1.nano 2014-02-16T16:56:07.000+00:00 is-1a
|
12
|
+
|
13
|
+
invalid: |
|
14
|
+
RESERVATION r-230d75e3 7e36d16f-19c1-404a-babb-36c8e3c6ddd9 default
|
15
|
+
INSTANCE
|
16
|
+
|
17
|
+
dokku: |
|
18
|
+
RESERVATION r-230d75e3 7e36d16f-19c1-404a-babb-36c8e3c6ddd9 default
|
19
|
+
INSTANCE i-29940840 qmi-b58041dd i-46-149-29-252.compute.is-1.greenqloud.com running default 0 t1.nano 2014-02-16T16:56:07.000+00:00 is-1a 0.0.0.0 0.0.0.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'support/minitest_helper'
|
2
|
+
require 'euca/api/instance'
|
3
|
+
|
4
|
+
module Euca
|
5
|
+
describe Instance do
|
6
|
+
|
7
|
+
it "finds unassociated ip unless foce given on create" do
|
8
|
+
wrapper = Instance.wrapper
|
9
|
+
fixture = Instance.wrapper.parse(fixture(:instance)["valid"])
|
10
|
+
|
11
|
+
mock = MiniTest::Mock.new
|
12
|
+
mock.expect :run, fixture, [ "run-instances", "-t", Euca::T1_NANO, Euca::UBUNTU_13_10 ]
|
13
|
+
|
14
|
+
Instance.instance_variable_set "@wrapper",mock
|
15
|
+
|
16
|
+
instance = Instance.create "-t", Euca::T1_NANO, Euca::UBUNTU_13_10
|
17
|
+
|
18
|
+
instance["public_dns_name"].must_equal "i-46-149-29-252.compute.is-1.greenqloud.com"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'support/minitest_helper'
|
2
|
+
|
3
|
+
module Euca
|
4
|
+
describe Keypair do
|
5
|
+
|
6
|
+
it "generates ssh key for given email" do
|
7
|
+
wrapper = Keypair.wrapper
|
8
|
+
fixture = Keypair.wrapper.parse(fixture(:keypairs)["test"])
|
9
|
+
|
10
|
+
mock = MiniTest::Mock.new
|
11
|
+
mock.expect :run, fixture, [ "create-keypair", "test@best.com", ">", "~/.ssh/test@best.com.id" ]
|
12
|
+
mock.expect :run, fixture, [ "describe-keypairs", "test@best.com" ]
|
13
|
+
|
14
|
+
Keypair.instance_variable_set "@wrapper",mock
|
15
|
+
|
16
|
+
keypair = Keypair.create "test@best.com"
|
17
|
+
|
18
|
+
keypair["id"].must_equal "test@best.com"
|
19
|
+
|
20
|
+
Keypair.find(keypair["id"])["fingerprint"].wont_be_nil
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/model_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Euca::Model do
|
|
20
20
|
wrapper = MiniTest::Mock.new
|
21
21
|
wrapper.expect :run, api.send(:wrapper).parse(fixture(:images)["all"]), [ "describe-images" ]
|
22
22
|
|
23
|
-
|
23
|
+
Api.instance_variable_set "@wrapper", wrapper
|
24
24
|
|
25
25
|
images = api.euca("describe-images")
|
26
26
|
images.first["name"].must_equal "Ubuntu Server 12.04.1"
|
data/test2.p
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
KEYPAIR test2 96:f2:50:98:96:0c:16:42:a7:da:a7:6b:c9:67:98:d4
|
2
|
+
-----BEGIN RSA PRIVATE KEY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::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Onur Uyar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
61
|
+
version: 0.0.5
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
68
|
+
version: 0.0.5
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vhs
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,13 +109,24 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- euca.gemspec
|
111
111
|
- lib/euca.rb
|
112
|
+
- lib/euca/api.rb
|
113
|
+
- lib/euca/api/address.rb
|
114
|
+
- lib/euca/api/instance.rb
|
115
|
+
- lib/euca/api/keypair.rb
|
112
116
|
- lib/euca/model.rb
|
113
117
|
- lib/euca/version.rb
|
114
118
|
- lib/euca/wrapper.rb
|
119
|
+
- spec/address_spec.rb
|
120
|
+
- spec/fixtures/address.yml
|
115
121
|
- spec/fixtures/images.yml
|
122
|
+
- spec/fixtures/instance.yml
|
123
|
+
- spec/fixtures/keypairs.yml
|
124
|
+
- spec/instance_spec.rb
|
125
|
+
- spec/keypair_spec.rb
|
116
126
|
- spec/model_spec.rb
|
117
127
|
- spec/support/minitest_helper.rb
|
118
128
|
- spec/wrapper_spec.rb
|
129
|
+
- test2.p
|
119
130
|
homepage: ''
|
120
131
|
licenses:
|
121
132
|
- MIT
|
@@ -141,7 +152,13 @@ signing_key:
|
|
141
152
|
specification_version: 4
|
142
153
|
summary: Ultra thin Ruby wrapper for euca2ools command line tools
|
143
154
|
test_files:
|
155
|
+
- spec/address_spec.rb
|
156
|
+
- spec/fixtures/address.yml
|
144
157
|
- spec/fixtures/images.yml
|
158
|
+
- spec/fixtures/instance.yml
|
159
|
+
- spec/fixtures/keypairs.yml
|
160
|
+
- spec/instance_spec.rb
|
161
|
+
- spec/keypair_spec.rb
|
145
162
|
- spec/model_spec.rb
|
146
163
|
- spec/support/minitest_helper.rb
|
147
164
|
- spec/wrapper_spec.rb
|