euca 0.0.6 → 0.0.7

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2YxMDBlZGVjNDk5MzNjZWM1MjVhMTFjNDRkMGJhNjUzMzE1MmQ0Zg==
4
+ ZDc1ZDIwODNiNjJlZTMxODc4ZjdkMGJjYjdiNWI1NjY1ZjBlZGRjYw==
5
5
  data.tar.gz: !binary |-
6
- OGE2MDZkYWE5NmFhMmU0Yzg3ZTllMzY1YThlMTAxNDM2MjlmMmQ2OA==
6
+ ZmMyYjgxZGMxOTZkNjdjMzU0MTIxZDc1ZGQ1NDUyMmVjNjdlZjBiYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWU0NzQwNWJkN2IzNDZjMWFjNmNmY2Q5MWI1N2ViMDI3MmE4YWUwZmFjOWZk
10
- NjA0NzY5OGJmZTlmOWYxMDk0NWFkMTIxMTljZTE2NDJmOWFmYjk2MmJmNGI1
11
- OWE5NTg1MmIzMmU1YWM3ZWMyOTlmNTBmZWJkYTFhOGJkNTMwYzM=
9
+ MWE1YTVlMDI3OWU5YTMyNDI5ZTQzOWQxMGNlNTRkODc0OTY1ZjYxOTg5MDVl
10
+ ZjEzNGFmOWQyOGFkODNhOTdkMzg1Y2RlMWYwMjFlOWI0OWNkYWU1N2NhNzU2
11
+ MTJlOWQ1YmE5MjgxNmNkMmNlZTU5NGVmMmFkMzk0NDE5ZTdlMTE=
12
12
  data.tar.gz: !binary |-
13
- MTY5MzI3MGU3YTVmMGYxNThjYmQ2OTc2NjdhNGE3ODQ5OWEyNzcyMTA3MTE4
14
- Mjg5Y2I4NTAwNzNkMDFhZGU1MGM3NjdjM2I5YWM1ZDFmZjVkMGNkY2Y4MDA1
15
- NTQ0YjU0MmUwZmVmMGIxZjE5NzcwNmQ3NjRlMDg0MTM2NDEyNWM=
13
+ NGRiMWZkMTQ0MjkyZGNiMTgxZmI5Zjg3MDY1NGU2YTQ1Zjk4ZWU3YWJhNDRi
14
+ ZDczOGZmNmJiMDIxNjJiNGNiNjdmNjhhMjU1OTI2YzkxN2IwMGJhZDEyODc5
15
+ MTY3MDQwZjU3YTI2Njc2NTI0OGU0NTZiZWI4ZTA3MzYyYTdjYjI=
@@ -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.4'
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
@@ -1,11 +1,14 @@
1
1
  require 'pult'
2
2
  require 'vhs'
3
3
  require "euca/version"
4
- require "euca/model"
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?
@@ -0,0 +1,8 @@
1
+ require "euca/model"
2
+ require "euca/api/address"
3
+ require "euca/api/instance"
4
+ require "euca/api/keypair"
5
+ module Euca
6
+ module Api
7
+ end
8
+ end
@@ -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
@@ -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
- def where *args
17
- describe "--filter", *args
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
@@ -1,3 +1,3 @@
1
1
  module Euca
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -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,5 @@
1
+ free: |
2
+ ADDRESS 46.149.28.166 None standard
3
+
4
+ associated: |
5
+ ADDRESS 46.149.18.35 i-29940840 standard
@@ -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,2 @@
1
+ test: |
2
+ KEYPAIR test@best.com a3:99:e7:22:6d:b7:c7:1f:5a:bf:3e:b8:9f:05:fa:00
@@ -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
@@ -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
- api.instance_variable_set "@wrapper", wrapper
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"
@@ -2,6 +2,9 @@ require "minitest/pride"
2
2
  require "minitest/autorun"
3
3
  require 'euca'
4
4
  require 'yaml'
5
+ require 'pult'
6
+
7
+ Pult.log_level = 0
5
8
 
6
9
  class MiniTest::Spec
7
10
 
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-----
3
+ MIICXAIBAAKBgQCQ5yW6YkMmdxuuKpApnTroV5mkF0BJuWUV7jXCVJ1rUCOn2UfR
4
+ dan4kc+1ULqGu5EZfrsaba442Ijx0537A3tjj9T1DCOxOA5ocn2syQmkaLD2oTKK
5
+ 8aeZvYx4PoWL6E2zfB4vKiQHNpAcTs9druCbGGiShMI8bpjw4u0M9pVkSwIDAQAB
6
+ AoGAQOpMzKMY0jKqA+ytiPcXXN9hxVFlS6Hy11BQZS7jFyBf2OJOelfsPZ+VHfV8
7
+ mr+M0Y8k40IfuvfG4g+bxshYjiNkdU5kM5PHDuQUanWzvwaDySaU8z+qWCRPrZl6
8
+ NB8/gK0Q+zKuqoJMlI/SfaDWtTBwPdcXKb4SUjuIa1bRmAECQQDgFUdIGy0zq8D6
9
+ ythuVntNPGqc1re1kWEqTWpA/42XYtSRa3LDlxg3KpA3auAnsArhnxpPojDHQ1hb
10
+ mHc6UP6LAkEApYq6k2aq3udxqMbufm4P5/Oknqw8hi/2UeM9n20Kyh6hJNv1bZRa
11
+ Ie7ngGG47hwkc0lqMVCWa4TjC6HQMlGpQQJASg5eN3Nb1fbOWVQOgTCtoVH1Pg4s
12
+ OqJoRU2+burGRaDQ9ZpYHFHkG99COD5nBFbG0df+HxFQI5qbKfJSfQBljwJAXv4f
13
+ mEv2y1hWUXpuCuDPgdO+6Ep/pKTLHSxgBScGZPt0jvklec8Cdaxo7bOl8gT2Ka28
14
+ ITZUSriDrP4awXU4wQJBAIVzp2obMSWIhWmZ9VjEVxRH8QFT1byqmOzn5uuh/Rci
15
+ 7ecBKKg3BTLnfArzgcjqqu2bEUAyx1HvWH6vnWB6MIM=
16
+ -----END RSA PRIVATE KEY-----
17
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: euca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
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-21 00:00:00.000000000 Z
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.4
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.4
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