fog 0.0.14 → 0.0.15
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.
- data/Rakefile +17 -2
- data/VERSION +1 -1
- data/bin/fog +60 -31
- data/fog.gemspec +34 -2
- data/lib/fog.rb +1 -0
- data/lib/fog/aws/ec2.rb +1 -0
- data/lib/fog/aws/models/ec2/addresses.rb +1 -1
- data/lib/fog/aws/models/ec2/volume.rb +1 -1
- data/lib/fog/aws/models/ec2/volumes.rb +4 -2
- data/lib/fog/aws/s3.rb +1 -0
- data/lib/fog/collection.rb +1 -1
- data/lib/fog/connection.rb +8 -9
- data/lib/fog/rackspace.rb +31 -0
- data/lib/fog/rackspace/files.rb +62 -0
- data/lib/fog/rackspace/models/servers/server.rb +51 -0
- data/lib/fog/rackspace/models/servers/servers.rb +52 -0
- data/lib/fog/rackspace/requests/files/get_containers.rb +56 -0
- data/lib/fog/rackspace/requests/files/head_containers.rb +41 -0
- data/lib/fog/rackspace/requests/servers/create_server.rb +84 -0
- data/lib/fog/rackspace/requests/servers/delete_server.rb +37 -0
- data/lib/fog/rackspace/requests/servers/get_flavors.rb +41 -0
- data/lib/fog/rackspace/requests/servers/get_images.rb +42 -0
- data/lib/fog/rackspace/requests/servers/get_server_details.rb +49 -0
- data/lib/fog/rackspace/requests/servers/get_servers.rb +40 -0
- data/lib/fog/rackspace/requests/servers/get_servers_details.rb +49 -0
- data/lib/fog/rackspace/servers.rb +49 -0
- data/spec/aws/models/ec2/instance_spec.rb +38 -9
- data/spec/aws/models/ec2/volume_spec.rb +2 -2
- data/spec/rackspace/requests/files/get_containers_spec.rb +11 -0
- data/spec/rackspace/requests/files/head_containers_spec.rb +11 -0
- data/spec/rackspace/requests/servers/create_server_spec.rb +21 -0
- data/spec/rackspace/requests/servers/delete_server_spec.rb +11 -0
- data/spec/rackspace/requests/servers/get_flavors_spec.rb +11 -0
- data/spec/rackspace/requests/servers/get_images_spec.rb +11 -0
- data/spec/rackspace/requests/servers/get_server_details_spec.rb +11 -0
- data/spec/rackspace/requests/servers/get_servers_details_spec.rb +11 -0
- data/spec/rackspace/requests/servers/get_servers_spec.rb +11 -0
- data/spec/spec_helper.rb +23 -9
- metadata +34 -2
data/Rakefile
CHANGED
@@ -39,12 +39,12 @@ end
|
|
39
39
|
namespace :specs do
|
40
40
|
|
41
41
|
task :with_mocking do
|
42
|
-
Fog.
|
42
|
+
Fog.mock!
|
43
43
|
Rake::Task[:spec].invoke
|
44
44
|
end
|
45
45
|
|
46
46
|
task :without_mocking do
|
47
|
-
Fog.
|
47
|
+
Fog.mock!
|
48
48
|
Rake::Task[:spec].invoke
|
49
49
|
end
|
50
50
|
|
@@ -95,3 +95,18 @@ begin
|
|
95
95
|
rescue LoadError
|
96
96
|
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
97
97
|
end
|
98
|
+
|
99
|
+
namespace :fog do
|
100
|
+
|
101
|
+
desc 'Provide a sample yaml file for credentials'
|
102
|
+
task :yml do
|
103
|
+
puts('Copy the following sample to ~/.fog and fill in with your credentials as needed:')
|
104
|
+
print("\n")
|
105
|
+
print(":aws_access_key_id: INTENTIONALLY_LEFT_BLANK\n")
|
106
|
+
print(":aws_secret_access_key: INTENTIONALLY_LEFT_BLANK\n")
|
107
|
+
print(":rackspace_api_key: INTENTIONALLY_LEFT_BLANK\n")
|
108
|
+
print(":rackspace_username: INTENTIONALLY_LEFT_BLANK\n")
|
109
|
+
print("\n")
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/bin/fog
CHANGED
@@ -3,48 +3,77 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
|
|
3
3
|
require 'irb'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
-
|
7
|
-
@credentials
|
8
|
-
|
9
|
-
|
6
|
+
def credentials
|
7
|
+
@credentials ||= begin
|
8
|
+
if ARGV[0] && File.exists?(File.expand_path(ARGV[0]))
|
9
|
+
YAML.load(File.open(File.expand_path(ARGV[0])).read)
|
10
|
+
elsif File.exists?(File.expand_path('~/.fog'))
|
11
|
+
YAML.load(File.open(File.expand_path('~/.fog')).read)
|
12
|
+
end
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
)
|
16
|
+
module AWS
|
17
|
+
class << self
|
18
|
+
if credentials[:aws_access_key_id] && credentials[:aws_secret_access_key]
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
)
|
20
|
+
@@ec2 = Fog::AWS::EC2.new(
|
21
|
+
:aws_access_key_id => credentials[:aws_access_key_id],
|
22
|
+
:aws_secret_access_key => credentials[:aws_secret_access_key]
|
23
|
+
)
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
@@s3 = Fog::AWS::S3.new(
|
26
|
+
:aws_access_key_id => credentials[:aws_access_key_id],
|
27
|
+
:aws_secret_access_key => credentials[:aws_secret_access_key]
|
28
|
+
)
|
25
29
|
|
26
|
-
def
|
27
|
-
|
28
|
-
end
|
30
|
+
def addresses
|
31
|
+
@@ec2.addresses
|
32
|
+
end
|
29
33
|
|
30
|
-
def
|
31
|
-
|
32
|
-
end
|
34
|
+
def buckets
|
35
|
+
@@s3.buckets
|
36
|
+
end
|
33
37
|
|
34
|
-
def
|
35
|
-
|
36
|
-
end
|
38
|
+
def instances
|
39
|
+
@@ec2.instances
|
40
|
+
end
|
37
41
|
|
38
|
-
def
|
39
|
-
|
40
|
-
end
|
42
|
+
def key_pairs
|
43
|
+
@@ec2.key_pairs
|
44
|
+
end
|
41
45
|
|
42
|
-
def
|
43
|
-
|
46
|
+
def security_groups
|
47
|
+
@@ec2.security_groups
|
48
|
+
end
|
49
|
+
|
50
|
+
def snapshots
|
51
|
+
@@ec2.snapshots
|
52
|
+
end
|
53
|
+
|
54
|
+
def volumes
|
55
|
+
@@ec2.volumes
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
44
60
|
end
|
45
61
|
|
46
|
-
|
47
|
-
|
62
|
+
module Rackspace
|
63
|
+
class << self
|
64
|
+
if credentials[:rackspace_api_key] && credentials[:rackspace_username]
|
65
|
+
|
66
|
+
@@servers = Fog::Rackspace::Servers.new(
|
67
|
+
:rackspace_api_key => credentials[:rackspace_api_key],
|
68
|
+
:rackspace_username => credentials[:rackspace_username]
|
69
|
+
)
|
70
|
+
|
71
|
+
def servers
|
72
|
+
@@servers.servers
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
48
77
|
end
|
49
78
|
|
50
79
|
ARGV.clear # Avoid passing args to IRB
|
data/fog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fog}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["geemus (Wesley Beary)"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-15}
|
13
13
|
s.default_executable = %q{fog}
|
14
14
|
s.description = %q{brings clouds to you}
|
15
15
|
s.email = %q{me@geemus.com}
|
@@ -136,6 +136,20 @@ Gem::Specification.new do |s|
|
|
136
136
|
"lib/fog/errors.rb",
|
137
137
|
"lib/fog/model.rb",
|
138
138
|
"lib/fog/parser.rb",
|
139
|
+
"lib/fog/rackspace.rb",
|
140
|
+
"lib/fog/rackspace/files.rb",
|
141
|
+
"lib/fog/rackspace/models/servers/server.rb",
|
142
|
+
"lib/fog/rackspace/models/servers/servers.rb",
|
143
|
+
"lib/fog/rackspace/requests/files/get_containers.rb",
|
144
|
+
"lib/fog/rackspace/requests/files/head_containers.rb",
|
145
|
+
"lib/fog/rackspace/requests/servers/create_server.rb",
|
146
|
+
"lib/fog/rackspace/requests/servers/delete_server.rb",
|
147
|
+
"lib/fog/rackspace/requests/servers/get_flavors.rb",
|
148
|
+
"lib/fog/rackspace/requests/servers/get_images.rb",
|
149
|
+
"lib/fog/rackspace/requests/servers/get_server_details.rb",
|
150
|
+
"lib/fog/rackspace/requests/servers/get_servers.rb",
|
151
|
+
"lib/fog/rackspace/requests/servers/get_servers_details.rb",
|
152
|
+
"lib/fog/rackspace/servers.rb",
|
139
153
|
"lib/fog/response.rb",
|
140
154
|
"spec/aws/models/ec2/address_spec.rb",
|
141
155
|
"spec/aws/models/ec2/addresses_spec.rb",
|
@@ -205,6 +219,15 @@ Gem::Specification.new do |s|
|
|
205
219
|
"spec/aws/requests/simpledb/put_attributes_spec.rb",
|
206
220
|
"spec/aws/requests/simpledb/select_spec.rb",
|
207
221
|
"spec/lorem.txt",
|
222
|
+
"spec/rackspace/requests/files/get_containers_spec.rb",
|
223
|
+
"spec/rackspace/requests/files/head_containers_spec.rb",
|
224
|
+
"spec/rackspace/requests/servers/create_server_spec.rb",
|
225
|
+
"spec/rackspace/requests/servers/delete_server_spec.rb",
|
226
|
+
"spec/rackspace/requests/servers/get_flavors_spec.rb",
|
227
|
+
"spec/rackspace/requests/servers/get_images_spec.rb",
|
228
|
+
"spec/rackspace/requests/servers/get_server_details_spec.rb",
|
229
|
+
"spec/rackspace/requests/servers/get_servers_details_spec.rb",
|
230
|
+
"spec/rackspace/requests/servers/get_servers_spec.rb",
|
208
231
|
"spec/spec.opts",
|
209
232
|
"spec/spec_helper.rb"
|
210
233
|
]
|
@@ -282,6 +305,15 @@ Gem::Specification.new do |s|
|
|
282
305
|
"spec/aws/requests/simpledb/list_domains_spec.rb",
|
283
306
|
"spec/aws/requests/simpledb/put_attributes_spec.rb",
|
284
307
|
"spec/aws/requests/simpledb/select_spec.rb",
|
308
|
+
"spec/rackspace/requests/files/get_containers_spec.rb",
|
309
|
+
"spec/rackspace/requests/files/head_containers_spec.rb",
|
310
|
+
"spec/rackspace/requests/servers/create_server_spec.rb",
|
311
|
+
"spec/rackspace/requests/servers/delete_server_spec.rb",
|
312
|
+
"spec/rackspace/requests/servers/get_flavors_spec.rb",
|
313
|
+
"spec/rackspace/requests/servers/get_images_spec.rb",
|
314
|
+
"spec/rackspace/requests/servers/get_server_details_spec.rb",
|
315
|
+
"spec/rackspace/requests/servers/get_servers_details_spec.rb",
|
316
|
+
"spec/rackspace/requests/servers/get_servers_spec.rb",
|
285
317
|
"spec/spec_helper.rb"
|
286
318
|
]
|
287
319
|
|
data/lib/fog.rb
CHANGED
data/lib/fog/aws/ec2.rb
CHANGED
data/lib/fog/aws/s3.rb
CHANGED
data/lib/fog/collection.rb
CHANGED
data/lib/fog/connection.rb
CHANGED
@@ -36,7 +36,7 @@ unless Fog.mocking?
|
|
36
36
|
|
37
37
|
def request(params)
|
38
38
|
params[:path] ||= ''
|
39
|
-
unless params[:path][0] == '/'
|
39
|
+
unless params[:path][0..0] == '/'
|
40
40
|
params[:path] = '/' + params[:path].to_s
|
41
41
|
end
|
42
42
|
if params[:query] && !params[:query].empty?
|
@@ -56,19 +56,18 @@ unless Fog.mocking?
|
|
56
56
|
|
57
57
|
if params[:body]
|
58
58
|
if params[:body].is_a?(String)
|
59
|
-
|
59
|
+
connection.write(params[:body])
|
60
60
|
else
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
connection.write(chunk)
|
61
|
+
while chunk = params[:body].read(CHUNK_SIZE)
|
62
|
+
connection.write(chunk)
|
63
|
+
end
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
67
|
response = Fog::Response.new
|
69
68
|
response.request = params
|
70
69
|
response.status = connection.readline[9..11].to_i
|
71
|
-
if params[:expects] && params[:expects]
|
70
|
+
if params[:expects] && ![*params[:expects]].include?(response.status)
|
72
71
|
error = true
|
73
72
|
end
|
74
73
|
while true
|
@@ -81,9 +80,9 @@ unless Fog.mocking?
|
|
81
80
|
end
|
82
81
|
|
83
82
|
unless params[:method] == 'HEAD'
|
84
|
-
if error || params[:parser]
|
83
|
+
if (error && params[:error_parser]) || params[:parser]
|
85
84
|
if error
|
86
|
-
parser =
|
85
|
+
parser = params[:error_parser]
|
87
86
|
elsif params[:parser]
|
88
87
|
parser = params[:parser]
|
89
88
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Rackspace
|
6
|
+
|
7
|
+
def self.reload
|
8
|
+
load 'fog/rackspace/files.rb'
|
9
|
+
load 'fog/rackspace/servers.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.authenticate(options)
|
13
|
+
connection = Fog::Connection.new("https://auth.api.rackspacecloud.com")
|
14
|
+
response = connection.request({
|
15
|
+
:expects => 204,
|
16
|
+
:headers => {
|
17
|
+
'X-Auth-Key' => options[:rackspace_api_key],
|
18
|
+
'X-Auth-User' => options[:rackspace_username]
|
19
|
+
},
|
20
|
+
:host => 'auth.api.rackspacecloud.com',
|
21
|
+
:method => 'GET',
|
22
|
+
:path => 'v1.0'
|
23
|
+
})
|
24
|
+
response.headers.reject do |key, value|
|
25
|
+
!['X-Server-Management-Url', 'X-Storage-Url', 'X-CDN-Management-Url', 'X-Auth-Token'].include?(key)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
Fog::Rackspace.reload
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Fog
|
2
|
+
module Rackspace
|
3
|
+
class Files
|
4
|
+
|
5
|
+
def self.reload
|
6
|
+
load "fog/rackspace/requests/files/get_containers.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
credentials = Fog::Rackspace.authenticate(options)
|
11
|
+
@auth_token = credentials['X-Auth-Token']
|
12
|
+
cdn_uri = URI.parse(credentials['X-CDN-Management-Url'])
|
13
|
+
@cdn_host = cdn_uri.host
|
14
|
+
@cdn_path = cdn_uri.path
|
15
|
+
@cdn_port = cdn_uri.port
|
16
|
+
@cdn_scheme = cdn_uri.scheme
|
17
|
+
storage_uri = URI.parse(credentials['X-Storage-Url'])
|
18
|
+
@storage_host = storage_uri.host
|
19
|
+
@storage_path = storage_uri.path
|
20
|
+
@storage_port = storage_uri.port
|
21
|
+
@storage_scheme = storage_uri.scheme
|
22
|
+
@connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def cdn_request(params)
|
26
|
+
response = @connection.request({
|
27
|
+
:body => params[:body],
|
28
|
+
:expects => params[:expects],
|
29
|
+
:headers => {
|
30
|
+
'X-Auth-Token' => @auth_token
|
31
|
+
},
|
32
|
+
:host => @cdn_host,
|
33
|
+
:method => params[:method],
|
34
|
+
:path => "#{@cdn_path}/#{params[:path]}"
|
35
|
+
})
|
36
|
+
unless response.status == 204
|
37
|
+
response.body = JSON.parse(response.body)
|
38
|
+
end
|
39
|
+
response
|
40
|
+
end
|
41
|
+
|
42
|
+
def storage_request(params)
|
43
|
+
response = @connection.request({
|
44
|
+
:body => params[:body],
|
45
|
+
:expects => params[:expects],
|
46
|
+
:headers => {
|
47
|
+
'X-Auth-Token' => @auth_token
|
48
|
+
},
|
49
|
+
:host => @storage_host,
|
50
|
+
:method => params[:method],
|
51
|
+
:path => "#{@storage_path}/#{params[:path]}"
|
52
|
+
})
|
53
|
+
unless response.status == 204
|
54
|
+
response.body = JSON.parse(response.body)
|
55
|
+
end
|
56
|
+
response
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
Fog::Rackspace::Files.reload
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Rackspace
|
3
|
+
class Server
|
4
|
+
|
5
|
+
class Server < Fog::Model
|
6
|
+
|
7
|
+
attribute :admin_pass, 'adminPass'
|
8
|
+
attribute :id
|
9
|
+
attribute :name
|
10
|
+
attribute :image_id, 'imageId'
|
11
|
+
attribute :flavor_id, 'flavorId'
|
12
|
+
attribute :host_id, 'hostId'
|
13
|
+
attribute :status
|
14
|
+
attribute :personality
|
15
|
+
attribute :progress
|
16
|
+
attribute :addresses
|
17
|
+
attribute :metadata
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
connection.delete_server(@id)
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def reload
|
25
|
+
new_attributes = servers.get(@id).attributes
|
26
|
+
merge_attributes(new_attributes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def save
|
30
|
+
options = { :metadata => @metadata, :name => @name, :personality => @personality }
|
31
|
+
options = options.reject {|key, value| value.nil?}
|
32
|
+
data = connection.create_server(@flavor_id, @image_id, options)
|
33
|
+
merge_attributes(data.body['server'])
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def servers
|
38
|
+
@servers
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def servers=(new_servers)
|
44
|
+
@servers = new_servers
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|