nephophobia 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws.rb +2 -3
- data/lib/nephophobia/client.rb +19 -2
- data/lib/nephophobia/version.rb +1 -1
- data/test/lib/aws_test.rb +1 -1
- data/test/lib/nephophobia/compute_test.rb +2 -8
- data/test/lib/nephophobia/image_test.rb +1 -9
- data/test/lib/nephophobia/project_test.rb +2 -2
- data/test/lib/nephophobia/user_test.rb +1 -1
- data/test/test_helper.rb +2 -2
- metadata +2 -2
data/lib/aws.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
##
|
2
2
|
# Taken from geemus/fog
|
3
|
-
#
|
4
|
-
# TODO: document
|
5
3
|
|
6
4
|
require "cgi"
|
7
5
|
require "openssl"
|
8
6
|
require "base64"
|
9
7
|
|
10
8
|
class AWS
|
9
|
+
attr_writer :path
|
10
|
+
|
11
11
|
def initialize options
|
12
12
|
@host = options[:host]
|
13
13
|
@port = options[:port]
|
14
|
-
@path = options[:path]
|
15
14
|
@access_key = options[:access_key]
|
16
15
|
@secret_key = options[:secret_key]
|
17
16
|
@project = options[:project]
|
data/lib/nephophobia/client.rb
CHANGED
@@ -10,7 +10,6 @@ module Nephophobia
|
|
10
10
|
|
11
11
|
def initialize options
|
12
12
|
@port = options[:port] || 8773
|
13
|
-
@path = options[:path] || "/services/Cloud"
|
14
13
|
|
15
14
|
@connection = Hugs::Client.new(
|
16
15
|
:host => options[:host],
|
@@ -24,7 +23,6 @@ module Nephophobia
|
|
24
23
|
@aws = AWS.new(
|
25
24
|
:host => options[:host],
|
26
25
|
:port => @port,
|
27
|
-
:path => @path,
|
28
26
|
:access_key => options[:access_key],
|
29
27
|
:secret_key => options[:secret_key],
|
30
28
|
:project => options[:project]
|
@@ -40,6 +38,7 @@ module Nephophobia
|
|
40
38
|
# +params+: A Hash containing the
|
41
39
|
|
42
40
|
def raw method, params
|
41
|
+
@aws.path = @path
|
43
42
|
response = @connection.send method, @path, :query => @aws.signed_params(method, params)
|
44
43
|
response.body = Hashify.convert response.body.root
|
45
44
|
|
@@ -60,6 +59,7 @@ module Nephophobia
|
|
60
59
|
# Provide a simple interface to the EC2 Compute resources.
|
61
60
|
|
62
61
|
def compute
|
62
|
+
@path = "/services/Cloud"
|
63
63
|
@compute ||= Nephophobia::Compute.new self
|
64
64
|
end
|
65
65
|
|
@@ -67,7 +67,24 @@ module Nephophobia
|
|
67
67
|
# Provide a simple interface to the EC2 Image resources.
|
68
68
|
|
69
69
|
def image
|
70
|
+
@path = "/services/Cloud"
|
70
71
|
@image ||= Nephophobia::Image.new self
|
71
72
|
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Provide a simple interface to the OpenStack Project resources.
|
76
|
+
|
77
|
+
def project
|
78
|
+
@path = "/services/Admin/"
|
79
|
+
@project ||= Nephophobia::Project.new self
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Provide a simple interface to the OpenStack User resources.
|
84
|
+
|
85
|
+
def user
|
86
|
+
@path = "/services/Admin/"
|
87
|
+
@user ||= Nephophobia::User.new self
|
88
|
+
end
|
72
89
|
end
|
73
90
|
end
|
data/lib/nephophobia/version.rb
CHANGED
data/test/lib/aws_test.rb
CHANGED
@@ -6,7 +6,6 @@ describe AWS do
|
|
6
6
|
@aws = AWS.new(
|
7
7
|
:host => "example.com",
|
8
8
|
:port => 8773,
|
9
|
-
:path => "/services/Cloud",
|
10
9
|
:access_key => "9c01b833-3047-4f2e-bb2a-5c8dc7c8ae9c",
|
11
10
|
:secret_key => "3ae9d9f0-2723-480a-99eb-776f05950506",
|
12
11
|
:project => "production"
|
@@ -14,6 +13,7 @@ describe AWS do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
it "returns signed query params" do
|
16
|
+
@aws.path = "/services/Cloud"
|
17
17
|
result = @aws.signed_params "get", "Action" => "DescribeInstances"
|
18
18
|
|
19
19
|
result.must_equal "AWSAccessKeyId=9c01b833-3047-4f2e-bb2a-5c8dc7c8ae9c%3Aproduction&Action=DescribeInstances&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=1999-12-31T19%3A59%3A59Z&Version=2010-11-15&Signature=x0wJmpbCeXpNcwVuTmB7E59zmlyTRkjDxjlO%2BCQi4z4%3D"
|
@@ -1,13 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Nephophobia::Compute do
|
4
|
-
before { @compute =
|
5
|
-
|
6
|
-
describe "#compute" do
|
7
|
-
it "has compute decorator" do
|
8
|
-
USER_CLIENT.must_respond_to :compute
|
9
|
-
end
|
10
|
-
end
|
4
|
+
before { @compute = USER_CLIENT.compute }
|
11
5
|
|
12
6
|
describe "#all" do
|
13
7
|
it "returns all instances" do
|
@@ -57,7 +51,7 @@ describe Nephophobia::Compute do
|
|
57
51
|
|
58
52
|
VCR.use_cassette "compute_create_with_optional_params" do
|
59
53
|
response = @compute.create @image_id, params
|
60
|
-
|
54
|
+
|
61
55
|
response.name.must_equal "testserver1"
|
62
56
|
response.description.must_equal "test description"
|
63
57
|
end
|
@@ -1,15 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Nephophobia::Image do
|
4
|
-
before
|
5
|
-
@image = Nephophobia::Image.new USER_CLIENT
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#image" do
|
9
|
-
it "has image decorator" do
|
10
|
-
USER_CLIENT.must_respond_to :image
|
11
|
-
end
|
12
|
-
end
|
4
|
+
before { @image = USER_CLIENT.image }
|
13
5
|
|
14
6
|
describe "#all" do
|
15
7
|
it "returns all images" do
|
@@ -2,8 +2,8 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe Nephophobia::Project do
|
4
4
|
before do
|
5
|
-
@project =
|
6
|
-
@user =
|
5
|
+
@project = ADMIN_CLIENT.project
|
6
|
+
@user = ADMIN_CLIENT.user
|
7
7
|
@user_name = "foobar_user"
|
8
8
|
@project_name = "foobar_project"
|
9
9
|
end
|
data/test/test_helper.rb
CHANGED
@@ -19,8 +19,7 @@ class MiniTest::Unit::TestCase
|
|
19
19
|
:host => "10.1.170.32",
|
20
20
|
:access_key => "1d7a687b-0065-44d6-9611-5bf6c6c72424",
|
21
21
|
:secret_key => "fd3053fd-25c2-48f8-b893-9f22661ec63c",
|
22
|
-
:project => "production"
|
23
|
-
:path => "/services/Admin/"
|
22
|
+
:project => "production"
|
24
23
|
)
|
25
24
|
|
26
25
|
def cassette_for cassette
|
@@ -44,4 +43,5 @@ class Time
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
46
|
+
|
47
47
|
MiniTest::Unit.autorun
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nephophobia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Dewey
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-03-
|
14
|
+
date: 2011-03-06 00:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|