cloudservers 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ ================================================================================
2
+ 0.4.2 (2012/01/13)
3
+ ================================================================================
4
+ o Test fixtures.
5
+ o Fix issue with paths, applicable for ruby 1.9.
6
+ o Change ConnectionException to Connection.
7
+ o Accept all 20x status codes to support OpenStack.
8
+
1
9
  ================================================================================
2
10
  0.4.1 (2011/02/02)
3
11
  ================================================================================
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
data/cloudservers.gemspec CHANGED
@@ -1,11 +1,8 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ require './lib/cloudservers/version'
5
2
 
6
3
  Gem::Specification.new do |s|
7
4
  s.name = %q{cloudservers}
8
- s.version = "0.4.1"
5
+ s.version = CloudServers::VERSION
9
6
 
10
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
8
  s.authors = ["H. Wade Minter", "Mike Mayo", "Dan Prince"]
@@ -22,7 +19,6 @@ Gem::Specification.new do |s|
22
19
  "README.rdoc",
23
20
  "Rakefile",
24
21
  "TODO",
25
- "VERSION",
26
22
  "cloudservers.gemspec",
27
23
  "lib/cloudservers.rb",
28
24
  "lib/cloudservers/authentication.rb",
@@ -33,6 +29,7 @@ Gem::Specification.new do |s|
33
29
  "lib/cloudservers/image.rb",
34
30
  "lib/cloudservers/server.rb",
35
31
  "lib/cloudservers/shared_ip_group.rb",
32
+ "lib/cloudservers/version.rb",
36
33
  "test/cloudservers_authentication_test.rb",
37
34
  "test/cloudservers_connection_test.rb",
38
35
  "test/cloudservers_exception_test.rb",
@@ -21,7 +21,7 @@ module CloudServers
21
21
  raise CloudServers::Exception::Connection, "Unable to connect to #{server}"
22
22
  end
23
23
  response = server.get(path,hdrhash)
24
- if (response.code == "204")
24
+ if (response.code =~ /^20./)
25
25
  connection.authtoken = response["x-auth-token"]
26
26
  connection.svrmgmthost = URI.parse(response["x-server-management-url"]).host
27
27
  connection.svrmgmtpath = URI.parse(response["x-server-management-url"]).path
@@ -86,7 +86,7 @@ module CloudServers
86
86
  retry
87
87
  rescue CloudServers::Exception::ExpiredAuthToken
88
88
  raise CloudServers::Exception::Connection, "Authentication token expired and you have requested not to retry" if @retry_auth == false
89
- CloudFiles::Authentication.new(self)
89
+ CloudServers::Authentication.new(self)
90
90
  retry
91
91
  end
92
92
 
@@ -331,7 +331,7 @@ module CloudServers
331
331
  end
332
332
  @http[server].start
333
333
  rescue
334
- raise CloudServers::Exception::ConnectionException, "Unable to connect to #{server}"
334
+ raise CloudServers::Exception::Connection, "Unable to connect to #{server}"
335
335
  end
336
336
  end
337
337
  end
@@ -10,7 +10,6 @@ module CloudServers
10
10
  attr_reader :hostId
11
11
  attr_reader :imageId
12
12
  attr_reader :flavorId
13
- attr_reader :metadata
14
13
  attr_accessor :adminPass
15
14
 
16
15
  # This class is the representation of a single Cloud Server object. The constructor finds the server identified by the specified
@@ -54,7 +53,6 @@ module CloudServers
54
53
  @hostId = data["hostId"]
55
54
  @imageId = data["imageId"]
56
55
  @flavorId = data["flavorId"]
57
- @metadata = data["metadata"]
58
56
  true
59
57
  end
60
58
  alias :refresh :populate
@@ -0,0 +1,3 @@
1
+ module CloudServers
2
+ VERSION = '0.4.2'
3
+ end
data/lib/cloudservers.rb CHANGED
@@ -20,7 +20,6 @@ module CloudServers
20
20
  AUTH_USA = "https://auth.api.rackspacecloud.com"
21
21
  AUTH_UK = "https://lon.auth.api.rackspacecloud.com"
22
22
 
23
- VERSION = IO.read(File.dirname(__FILE__) + '/../VERSION')
24
23
  require 'net/http'
25
24
  require 'net/https'
26
25
  require 'uri'
@@ -34,6 +33,7 @@ module CloudServers
34
33
  end
35
34
 
36
35
  $:.unshift(File.dirname(__FILE__))
36
+ require 'cloudservers/version'
37
37
  require 'cloudservers/authentication'
38
38
  require 'cloudservers/connection'
39
39
  require 'cloudservers/server'
@@ -4,31 +4,6 @@ require 'tempfile'
4
4
 
5
5
  class CloudServersServersTest < Test::Unit::TestCase
6
6
 
7
- CREATE_SERVER_JSON = %{{
8
- "server" : {
9
- "id" : 1234,
10
- "name" : "sample-server",
11
- "imageId" : 2,
12
- "flavorId" : 1,
13
- "hostId" : "e4d909c290d0fb1ca068ffaddf22cbd0",
14
- "adminPass" : "blah",
15
- "status" : "BUILD",
16
- "progress" : 60,
17
- "addresses" : {
18
- "public" : [
19
- "67.23.10.132"
20
- ],
21
- "private" : [
22
- "10.176.42.16"
23
- ]
24
- },
25
- "metadata" : {
26
- "Racker" : "Fanatical"
27
- }
28
- }
29
- }}
30
-
31
-
32
7
  include TestConnection
33
8
 
34
9
  def setup
@@ -37,53 +12,8 @@ CREATE_SERVER_JSON = %{{
37
12
 
38
13
  def test_list_servers
39
14
 
40
- json_response = %{{
41
- "servers" : [
42
- {
43
- "id" : 1234,
44
- "name" : "sample-server",
45
- "imageId" : 2,
46
- "flavorId" : 1,
47
- "hostId" : "e4d909c290d0fb1ca068ffaddf22cbd0",
48
- "status" : "BUILD",
49
- "progress" : 60,
50
- "addresses" : {
51
- "public" : [
52
- "67.23.10.132",
53
- "67.23.10.131"
54
- ],
55
- "private" : [
56
- "10.176.42.16"
57
- ]
58
- },
59
- "metadata" : {
60
- "Server Label" : "Web Head 1",
61
- "Image Version" : "2.1"
62
- }
63
- },
64
- {
65
- "id" : 5678,
66
- "name" : "sample-server2",
67
- "imageId" : 2,
68
- "flavorId" : 1,
69
- "hostId" : "9e107d9d372bb6826bd81d3542a419d6",
70
- "status" : "ACTIVE",
71
- "addresses" : {
72
- "public" : [
73
- "67.23.10.133"
74
- ],
75
- "private" : [
76
- "10.176.42.17"
77
- ]
78
- },
79
- "metadata" : {
80
- "Server Label" : "DB 1"
81
- }
82
- }
83
- ]
84
- }}
85
15
  response = mock()
86
- response.stubs(:code => "200", :body => json_response)
16
+ response.stubs(:code => "200", :body => fixture('list_servers.json'))
87
17
 
88
18
  @conn.stubs(:csreq).returns(response)
89
19
  servers=@conn.list_servers
@@ -189,7 +119,7 @@ json_response = %{{
189
119
  def test_create_server_with_local_file_personality
190
120
 
191
121
  response = mock()
192
- response.stubs(:code => "200", :body => CREATE_SERVER_JSON)
122
+ response.stubs(:code => "200", :body => fixture('create_server.json'))
193
123
  @conn.stubs(:csreq).returns(response)
194
124
 
195
125
  tmp = Tempfile.open('ruby_cloud_servers')
@@ -205,7 +135,7 @@ json_response = %{{
205
135
  def test_create_server_with_personalities
206
136
 
207
137
  response = mock()
208
- response.stubs(:code => "200", :body => CREATE_SERVER_JSON)
138
+ response.stubs(:code => "200", :body => fixture('create_server.json'))
209
139
  @conn.stubs(:csreq).returns(response)
210
140
 
211
141
  server = @conn.create_server(:name => "sample-server", :imageId => 2, :flavorId => 2, :metadata => {'Racker' => 'Fanatical'}, :personality => [{:path => '/root/hello.txt', :contents => "Hello there!"}, {:path => '/root/.ssh/authorized_keys', :contents => ""}])
@@ -234,33 +164,8 @@ json_response = %{{
234
164
  private
235
165
  def get_test_server
236
166
 
237
- json_response = %{{
238
- "server" : {
239
- "id" : 1234,
240
- "name" : "sample-server",
241
- "imageId" : 2,
242
- "flavorId" : 1,
243
- "hostId" : "e4d909c290d0fb1ca068ffaddf22cbd0",
244
- "status" : "BUILD",
245
- "progress" : 60,
246
- "addresses" : {
247
- "public" : [
248
- "67.23.10.132",
249
- "67.23.10.131"
250
- ],
251
- "private" : [
252
- "10.176.42.16"
253
- ]
254
- },
255
- "metadata" : {
256
- "Server Label" : "Web Head 1",
257
- "Image Version" : "2.1"
258
- }
259
- }
260
- }}
261
-
262
167
  response = mock()
263
- response.stubs(:code => "200", :body => json_response)
168
+ response.stubs(:code => "200", :body => fixture('test_server.json'))
264
169
 
265
170
  @conn=get_test_connection
266
171
 
@@ -0,0 +1,23 @@
1
+ {
2
+ "server" : {
3
+ "id" : 1234,
4
+ "name" : "sample-server",
5
+ "imageId" : 2,
6
+ "flavorId" : 1,
7
+ "hostId" : "e4d909c290d0fb1ca068ffaddf22cbd0",
8
+ "adminPass" : "blah",
9
+ "status" : "BUILD",
10
+ "progress" : 60,
11
+ "addresses" : {
12
+ "public" : [
13
+ "67.23.10.132"
14
+ ],
15
+ "private" : [
16
+ "10.176.42.16"
17
+ ]
18
+ },
19
+ "metadata" : {
20
+ "Racker" : "Fanatical"
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "servers" : [
3
+ {
4
+ "id" : 1234,
5
+ "name" : "sample-server",
6
+ "imageId" : 2,
7
+ "flavorId" : 1,
8
+ "hostId" : "e4d909c290d0fb1ca068ffaddf22cbd0",
9
+ "status" : "BUILD",
10
+ "progress" : 60,
11
+ "addresses" : {
12
+ "public" : [
13
+ "67.23.10.132",
14
+ "67.23.10.131"
15
+ ],
16
+ "private" : [
17
+ "10.176.42.16"
18
+ ]
19
+ },
20
+ "metadata" : {
21
+ "Server Label" : "Web Head 1",
22
+ "Image Version" : "2.1"
23
+ }
24
+ },
25
+ {
26
+ "id" : 5678,
27
+ "name" : "sample-server2",
28
+ "imageId" : 2,
29
+ "flavorId" : 1,
30
+ "hostId" : "9e107d9d372bb6826bd81d3542a419d6",
31
+ "status" : "ACTIVE",
32
+ "addresses" : {
33
+ "public" : [
34
+ "67.23.10.133"
35
+ ],
36
+ "private" : [
37
+ "10.176.42.17"
38
+ ]
39
+ },
40
+ "metadata" : {
41
+ "Server Label" : "DB 1"
42
+ }
43
+ }
44
+ ]
45
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "server" : {
3
+ "id" : 1234,
4
+ "name" : "sample-server",
5
+ "imageId" : 2,
6
+ "flavorId" : 1,
7
+ "hostId" : "e4d909c290d0fb1ca068ffaddf22cbd0",
8
+ "status" : "BUILD",
9
+ "progress" : 60,
10
+ "addresses" : {
11
+ "public" : [
12
+ "67.23.10.132",
13
+ "67.23.10.131"
14
+ ],
15
+ "private" : [
16
+ "10.176.42.16"
17
+ ]
18
+ },
19
+ "metadata" : {
20
+ "Server Label" : "Web Head 1",
21
+ "Image Version" : "2.1"
22
+ }
23
+ }
24
+ }
data/test/test_helper.rb CHANGED
@@ -19,3 +19,11 @@ def get_test_connection
19
19
  end
20
20
 
21
21
  end
22
+
23
+ def fixture_path
24
+ File.expand_path("../fixtures", __FILE__)
25
+ end
26
+
27
+ def fixture(file)
28
+ File.read(fixture_path + '/' + file)
29
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudservers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - H. Wade Minter
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-02-02 00:00:00 -05:00
20
+ date: 2012-01-13 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -60,10 +60,14 @@ files:
60
60
  - lib/cloudservers/image.rb
61
61
  - lib/cloudservers/server.rb
62
62
  - lib/cloudservers/shared_ip_group.rb
63
+ - lib/cloudservers/version.rb
63
64
  - test/cloudservers_authentication_test.rb
64
65
  - test/cloudservers_connection_test.rb
65
66
  - test/cloudservers_exception_test.rb
66
67
  - test/cloudservers_servers_test.rb
68
+ - test/fixtures/create_server.json
69
+ - test/fixtures/list_servers.json
70
+ - test/fixtures/test_server.json
67
71
  - test/test_helper.rb
68
72
  has_rdoc: true
69
73
  homepage: https://github.com/rackspace/ruby-cloudservers