fog-radosgw 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/fog-radosgw.gemspec +2 -1
- data/lib/fog/radosgw/core.rb +66 -3
- data/lib/fog/radosgw/provisioning.rb +4 -13
- data/lib/fog/radosgw/requests/provisioning/create_user.rb +3 -3
- data/lib/fog/radosgw/requests/provisioning/delete_user.rb +1 -1
- data/lib/fog/radosgw/requests/provisioning/get_user.rb +1 -1
- data/lib/fog/radosgw/requests/usage/get_usage.rb +1 -1
- data/lib/fog/radosgw/usage.rb +0 -10
- data/lib/fog/radosgw/version.rb +1 -1
- data/tests/helper.rb +1 -1
- metadata +19 -3
data/fog-radosgw.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.extra_rdoc_files = %w[README.md LICENSE.md]
|
23
23
|
|
24
24
|
s.add_dependency 'fog-json'
|
25
|
-
s.add_dependency 'fog'
|
25
|
+
s.add_dependency 'fog-xml'
|
26
|
+
s.add_dependency 'fog-core', '>=1.21.0'
|
26
27
|
s.add_development_dependency 'rake'
|
27
28
|
s.add_development_dependency 'yard'
|
28
29
|
s.add_development_dependency 'shindo'
|
data/lib/fog/radosgw/core.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog'
|
1
|
+
require 'fog/core'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Radosgw
|
@@ -72,7 +72,7 @@ module Fog
|
|
72
72
|
|
73
73
|
def update_radosgw_user(user_id, user)
|
74
74
|
path = "admin/user"
|
75
|
-
user_id =
|
75
|
+
user_id = escape(user_id)
|
76
76
|
params = {
|
77
77
|
:method => 'POST',
|
78
78
|
:path => path,
|
@@ -125,9 +125,72 @@ module Fog
|
|
125
125
|
"#{@scheme}://#{@host}:#{@port}"
|
126
126
|
end
|
127
127
|
|
128
|
+
def escape(string)
|
129
|
+
string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
|
130
|
+
"%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def signature(params, expires)
|
135
|
+
headers = params[:headers] || {}
|
136
|
+
|
137
|
+
string_to_sign =
|
138
|
+
<<-DATA
|
139
|
+
#{params[:method].to_s.upcase}
|
140
|
+
#{headers['Content-MD5']}
|
141
|
+
#{headers['Content-Type']}
|
142
|
+
#{expires}
|
143
|
+
DATA
|
144
|
+
|
145
|
+
amz_headers, canonical_amz_headers = {}, ''
|
146
|
+
for key, value in headers
|
147
|
+
if key[0..5] == 'x-amz-'
|
148
|
+
amz_headers[key] = value
|
149
|
+
end
|
150
|
+
end
|
151
|
+
amz_headers = amz_headers.sort {|x, y| x[0] <=> y[0]}
|
152
|
+
for key, value in amz_headers
|
153
|
+
canonical_amz_headers << "#{key}:#{value}\n"
|
154
|
+
end
|
155
|
+
string_to_sign << canonical_amz_headers
|
156
|
+
|
157
|
+
|
158
|
+
query_string = ''
|
159
|
+
if params[:query]
|
160
|
+
query_args = []
|
161
|
+
for key in params[:query].keys.sort
|
162
|
+
if VALID_QUERY_KEYS.include?(key)
|
163
|
+
value = params[:query][key]
|
164
|
+
if value
|
165
|
+
query_args << "#{key}=#{value}"
|
166
|
+
else
|
167
|
+
query_args << key
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
if query_args.any?
|
172
|
+
query_string = '?' + query_args.join('&')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
canonical_path = (params[:path] || object_to_path(params[:object_name])).to_s
|
177
|
+
canonical_path = '/' + canonical_path if canonical_path[0..0] != '/'
|
178
|
+
if params[:bucket_name]
|
179
|
+
canonical_resource = "/#{params[:bucket_name]}#{canonical_path}"
|
180
|
+
else
|
181
|
+
canonical_resource = canonical_path
|
182
|
+
end
|
183
|
+
canonical_resource << query_string
|
184
|
+
string_to_sign << canonical_resource
|
185
|
+
|
186
|
+
hmac = Fog::HMAC.new('sha1', @radosgw_secret_access_key)
|
187
|
+
signed_string = hmac.sign(string_to_sign)
|
188
|
+
Base64.encode64(signed_string).chomp!
|
189
|
+
end
|
190
|
+
|
128
191
|
def signed_headers(params)
|
129
192
|
expires = Fog::Time.now.to_date_header
|
130
|
-
auth =
|
193
|
+
auth = signature(params,expires)
|
131
194
|
awskey = @radosgw_access_key_id
|
132
195
|
headers = {
|
133
196
|
'Date' => expires,
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'fog/radosgw/core'
|
2
|
+
require 'fog/json'
|
3
|
+
require 'fog/xml'
|
2
4
|
|
3
5
|
module Fog
|
4
6
|
module Radosgw
|
@@ -55,23 +57,12 @@ module Fog
|
|
55
57
|
@persistent = options[:persistent] || false
|
56
58
|
@path_style = options[:path_style] || false
|
57
59
|
|
58
|
-
@
|
59
|
-
|
60
|
-
@s3_connection = Fog::Storage.new(
|
61
|
-
:provider => 'AWS',
|
62
|
-
:aws_access_key_id => @radosgw_access_key_id,
|
63
|
-
:aws_secret_access_key => @radosgw_secret_access_key,
|
64
|
-
:host => @host,
|
65
|
-
:port => @port,
|
66
|
-
:scheme => @scheme,
|
67
|
-
:path_style => @path_style,
|
68
|
-
:connection_options => @connection_options
|
69
|
-
)
|
60
|
+
@connection = Fog::Xml::Connection.new(radosgw_uri, @persistent, @connection_options)
|
70
61
|
end
|
71
62
|
|
72
63
|
def request(params, parse_response = true, &block)
|
73
64
|
begin
|
74
|
-
response = @
|
65
|
+
response = @connection.request(params.merge({
|
75
66
|
:host => @host,
|
76
67
|
:path => "#{@path}/#{params[:path]}",
|
77
68
|
}), &block)
|
@@ -10,9 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
path = "admin/user"
|
13
|
-
user_id =
|
14
|
-
display_name =
|
15
|
-
email =
|
13
|
+
user_id = escape(user_id)
|
14
|
+
display_name = escape(display_name)
|
15
|
+
email = escape(email)
|
16
16
|
query = "?uid=#{user_id}&display-name=#{display_name}&email=#{email}&format=json"
|
17
17
|
params = {
|
18
18
|
:method => 'PUT',
|
data/lib/fog/radosgw/usage.rb
CHANGED
@@ -45,16 +45,6 @@ module Fog
|
|
45
45
|
@radosgw_secret_access_key = options[:radosgw_secret_access_key]
|
46
46
|
@connection_options = options[:connection_options] || {}
|
47
47
|
@persistent = options[:persistent] || false
|
48
|
-
|
49
|
-
@s3_connection = Fog::Storage.new(
|
50
|
-
:provider => 'AWS',
|
51
|
-
:aws_access_key_id => @radosgw_access_key_id,
|
52
|
-
:aws_secret_access_key => @radosgw_secret_access_key,
|
53
|
-
:host => @host,
|
54
|
-
:port => @port,
|
55
|
-
:scheme => @scheme,
|
56
|
-
:connection_options => @connection_options
|
57
|
-
)
|
58
48
|
end
|
59
49
|
end
|
60
50
|
end
|
data/lib/fog/radosgw/version.rb
CHANGED
data/tests/helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
ENV['FOG_RC'] = ENV['FOG_RC'] || File.expand_path('../.fog', __FILE__)
|
2
2
|
ENV['FOG_CREDENTIAL'] = ENV['FOG_CREDENTIAL'] || 'default'
|
3
3
|
|
4
|
-
require 'fog'
|
4
|
+
require 'fog/core'
|
5
5
|
require 'fog/test_helpers/formats_helper'
|
6
6
|
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-radosgw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog-json
|
@@ -28,7 +28,23 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: fog
|
31
|
+
name: fog-xml
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fog-core
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|