radosgw-s3 0.7 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.rdoc +1 -1
- data/lib/ceph/radosgw.rb +0 -31
- data/lib/ceph/user.rb +66 -0
- data/lib/radosgw-s3.rb +1 -2
- data/lib/s3/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c656861081019bf06272ea5ebf0374e875a138c9
|
4
|
+
data.tar.gz: 994d3a34d1c5db3333d3916d5025b9aa84f40e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac5ff07dfd50528e00a90499dd186743bb649645f05541256867f91383efc02a1f743ba15e9c43c0d351789ab30b15ea00ccabbe074b245a403c3ea3b16fd229
|
7
|
+
data.tar.gz: 9dbddb1c18a6fb51b5e57b0e7a4ba1ec25e98e4aae379789bee955894e873b08b10e54d8e9809b5a5e8da788170335b8f3e8ab808c3f6068e22afdfc66dd7185
|
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -26,7 +26,7 @@ radosgw-admin guide to {create radosgw user}[http://docs.ceph.com/docs/master/ra
|
|
26
26
|
|
27
27
|
=== create user
|
28
28
|
|
29
|
-
service.user_create("UID_NAME")
|
29
|
+
service.user_create("UID_NAME", "DISPLAY_NAME")
|
30
30
|
|
31
31
|
It will give you the access_key and secret_key in hash format
|
32
32
|
|
data/lib/ceph/radosgw.rb
CHANGED
@@ -5,8 +5,6 @@ module CEPH
|
|
5
5
|
class Radosgw
|
6
6
|
|
7
7
|
attr_reader :username, :ipaddress, :user_password, :uid
|
8
|
-
|
9
|
-
|
10
8
|
def initialize(options)
|
11
9
|
raise ArgumentError, "Missing :username." if !options[:username]
|
12
10
|
raise ArgumentError, "Missing :ipaddress." if !options[:ipaddress]
|
@@ -17,34 +15,5 @@ module CEPH
|
|
17
15
|
@user_password = options.fetch(:user_password)
|
18
16
|
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
def user_create(uid)
|
23
|
-
ceph_user_json = ""
|
24
|
-
Net::SSH.start( @ipaddress, @username, :password => @user_password ) do|ssh|
|
25
|
-
ceph_user_json = ssh.exec!("sudo radosgw-admin user create --uid='#{uid}' --display-name='radosgw demo user from s3 gem'")
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
ceph_user_hash = JSON.parse(ceph_user_json)
|
30
|
-
secret_hash = {"access_key" => "#{ceph_user_hash['keys'][0]['access_key']}", "secret_key" => "#{ceph_user_hash['keys'][0]['secret_key']}" }
|
31
|
-
secret_hash
|
32
|
-
end
|
33
|
-
|
34
|
-
def user_usage(uid)
|
35
|
-
user_usage_json = ""
|
36
|
-
Net::SSH.start( @ipaddress, @username, :password => @user_password ) do|ssh|
|
37
|
-
user_usage_json = ssh.exec!("sudo radosgw-admin user stats --uid='#{uid}'")
|
38
|
-
end
|
39
|
-
|
40
|
-
if user_usage_json.include? "ERROR: can't read user header: (2) No such file or directory"
|
41
|
-
usage_hash = {"total_objects" => "0", "total_bytes" => "0", "last_update" => "#{Time.now}" }
|
42
|
-
else
|
43
|
-
user_usage_hash = JSON.parse(user_usage_json)
|
44
|
-
usage_hash = {"total_objects" => "#{user_usage_hash['stats']['total_entries']}", "total_bytes" => "#{user_usage_hash['stats']['total_bytes_rounded']}", "last_update" => "#{user_usage_hash['last_stats_update']}" }
|
45
|
-
usage_hash
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
18
|
end
|
50
19
|
end
|
data/lib/ceph/user.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
module CEPH
|
2
|
+
class User < Radosgw
|
3
|
+
def execution(command)
|
4
|
+
radosgw_json =
|
5
|
+
begin
|
6
|
+
Net::SSH.start( @ipaddress, @username, :password => @user_password ) do|ssh|
|
7
|
+
radosgw_json = ssh.exec!(command)
|
8
|
+
end
|
9
|
+
rescue Timeout::Error
|
10
|
+
return "Timed out Error"
|
11
|
+
rescue Errno::EHOSTUNREACH
|
12
|
+
return "Host unreachable Error"
|
13
|
+
rescue Errno::ECONNREFUSED
|
14
|
+
return "Connection refused Error"
|
15
|
+
rescue Net::SSH::AuthenticationFailed
|
16
|
+
return "Authentication failure Error"
|
17
|
+
end
|
18
|
+
return radosgw_json
|
19
|
+
end
|
20
|
+
|
21
|
+
def exists(uid)
|
22
|
+
ceph_user_json = ""
|
23
|
+
ceph_user_json = execution("sudo radosgw-admin user info --uid='#{uid}'")
|
24
|
+
begin
|
25
|
+
JSON.parse(ceph_user_json)
|
26
|
+
return true
|
27
|
+
rescue JSON::ParserError => e
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def create(uid, display_name)
|
33
|
+
ceph_user_json = ""
|
34
|
+
ceph_user_json = execution("sudo radosgw-admin user create --uid='#{uid}' --display-name='#{display_name}'")
|
35
|
+
begin
|
36
|
+
ceph_user_hash = JSON.parse(ceph_user_json)
|
37
|
+
secret_hash = {"access_key" => "#{ceph_user_hash['keys'][0]['access_key']}", "secret_key" => "#{ceph_user_hash['keys'][0]['secret_key']}" }
|
38
|
+
secret_hash
|
39
|
+
rescue JSON::ParserError => e
|
40
|
+
return ceph_user_json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def usage(uid)
|
45
|
+
user_usage_json = ""
|
46
|
+
if exists(uid)
|
47
|
+
user_usage_json = execution("sudo radosgw-admin user stats --uid='#{uid}'")
|
48
|
+
|
49
|
+
if user_usage_json.include? "ERROR: can't read user header: (2) No such file or directory"
|
50
|
+
usage_hash = {"total_objects" => "0", "total_bytes" => "0", "last_update" => "#{Time.now}" }
|
51
|
+
else
|
52
|
+
begin
|
53
|
+
user_usage_hash = JSON.parse(user_usage_json)
|
54
|
+
usage_hash = {"total_objects" => "#{user_usage_hash['stats']['total_entries']}", "total_bytes" => "#{user_usage_hash['stats']['total_bytes_rounded']}", "last_update" => "#{user_usage_hash['last_stats_update']}" }
|
55
|
+
usage_hash
|
56
|
+
rescue JSON::ParserError => e
|
57
|
+
return user_usage_json
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
return "could not fetch user info: no user info saved"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
data/lib/radosgw-s3.rb
CHANGED
@@ -7,7 +7,6 @@ require "net/https"
|
|
7
7
|
require "openssl"
|
8
8
|
require "rexml/document"
|
9
9
|
require "time"
|
10
|
-
|
11
10
|
require "proxies"
|
12
11
|
require "s3/objects_extension"
|
13
12
|
require "s3/buckets_extension"
|
@@ -20,8 +19,8 @@ require "s3/request"
|
|
20
19
|
require "s3/service"
|
21
20
|
require "s3/signature"
|
22
21
|
require "s3/version"
|
23
|
-
|
24
22
|
require "ceph/radosgw"
|
23
|
+
require "ceph/user"
|
25
24
|
|
26
25
|
module S3
|
27
26
|
# Default (and only) host serving S3 stuff
|
data/lib/s3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radosgw-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Alrin, Kishorekumar Neelamegam, Rajthilak, Kuba Kuźma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: proxies
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- README.rdoc
|
126
126
|
- Rakefile
|
127
127
|
- lib/ceph/radosgw.rb
|
128
|
+
- lib/ceph/user.rb
|
128
129
|
- lib/radosgw-s3.rb
|
129
130
|
- lib/s3/bucket.rb
|
130
131
|
- lib/s3/buckets_extension.rb
|
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
165
|
version: 1.3.6
|
165
166
|
requirements: []
|
166
167
|
rubyforge_project: s3
|
167
|
-
rubygems_version: 2.4.
|
168
|
+
rubygems_version: 2.4.7
|
168
169
|
signing_key:
|
169
170
|
specification_version: 4
|
170
171
|
summary: Library for accessing ceph objects and buckets
|