leofs_manager_client 0.2.16 → 0.4.0
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.
- checksums.yaml +15 -0
- data/lib/leofs_manager_client/leofs_manager_models.rb +45 -11
- data/lib/leofs_manager_client.rb +36 -7
- data/spec/dummy_tcp_server.rb +22 -34
- data/spec/leofs_manager_client_spec.rb +23 -23
- metadata +5 -7
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODBjNTNiNmU3MDRkZjc0NmI2MWFjNzk2Y2MyMzc0OTc0MGY1MGVjMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjRkODI0YmJjNWZjNjFiMGMzOTkwMmIxZjEyNDEwOTQ5ODVkYjkxNA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWVhZWU3YmU3MTFiN2M1OWU4NzA0NjY1M2FlYzhiMDAxN2U3OTk1ZTg5ZTNk
|
10
|
+
YzI4Y2IyMWQwYTljNDQyMjM0YmY4MGMyZGUyYzAxY2MwYWJmZWI3NjdiMTU0
|
11
|
+
NDZiMWI5NWU3ZjRhYWM4M2FhOWRmNDFhNzdhNmI4OWNkZjkwOGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzQyMDI3NTA4YWQyNmU4NTEyMGQ4ODY2OTYwNDI5Yzc3YjE0ZTM0YzZjZWFl
|
14
|
+
MTk5MzcxNGE1ZGFhNTg1MDFmMTE5ZGY4MDFiMDk2YTU3YzllOTkzODk0NDEy
|
15
|
+
MTQ2ZGE5OTUyMGZlYTk3MDE5ZGY1YjQzMjhmMjMwMTZkOWY4ZmE=
|
@@ -20,7 +20,10 @@
|
|
20
20
|
#
|
21
21
|
# ======================================================================
|
22
22
|
module LeoFSManager
|
23
|
+
|
24
|
+
# ==========================
|
23
25
|
# System Information Model
|
26
|
+
# ==========================
|
24
27
|
class Status
|
25
28
|
# Node
|
26
29
|
attr_reader :node_stat
|
@@ -93,7 +96,9 @@ module LeoFSManager
|
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
99
|
+
# ==========================
|
96
100
|
# Assigned file info Model
|
101
|
+
# ==========================
|
97
102
|
class AssignedFile
|
98
103
|
attr_reader :node, :vnode_id, :size, :clock, :checksum, :timestamp, :delete, :num_of_chunks
|
99
104
|
|
@@ -110,7 +115,9 @@ module LeoFSManager
|
|
110
115
|
end
|
111
116
|
end
|
112
117
|
|
118
|
+
# ==========================
|
113
119
|
# Storage Status Model
|
120
|
+
# ==========================
|
114
121
|
class StorageStat
|
115
122
|
attr_reader :active_num_of_objects, :total_num_of_objects,
|
116
123
|
:active_size_of_objects, :total_size_of_objects,
|
@@ -123,15 +130,9 @@ module LeoFSManager
|
|
123
130
|
@total_num_of_objects = h[:total_num_of_objects]
|
124
131
|
@active_size_of_objects = h[:active_size_of_objects]
|
125
132
|
@total_size_of_objects = h[:total_size_of_objects]
|
126
|
-
|
127
|
-
last_compaction_start = h[:last_compaction_start]
|
128
|
-
|
129
|
-
@last_compaction_start = Time.parse(h[:last_compaction_start])
|
130
|
-
end
|
131
|
-
last_compaction_end = h[:last_compaction_end]
|
132
|
-
if last_compaction_end && last_compaction_end != "____-_-__- __:__:__"
|
133
|
-
@last_compaction_end = Time.parse(h[:last_compaction_end])
|
134
|
-
end
|
133
|
+
@ratio_of_active_size = h[:ratio_of_active_size]
|
134
|
+
@last_compaction_start = h[:last_compaction_start]
|
135
|
+
@last_compaction_end = h[:last_compaction_end]
|
135
136
|
end
|
136
137
|
|
137
138
|
def file_size
|
@@ -139,7 +140,9 @@ module LeoFSManager
|
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
|
-
#
|
143
|
+
# ==========================
|
144
|
+
# S3 Credential Model
|
145
|
+
# ==========================
|
143
146
|
class Credential
|
144
147
|
# AWS_ACCESS_KEY_ID
|
145
148
|
attr_reader :access_key_id
|
@@ -152,6 +155,9 @@ module LeoFSManager
|
|
152
155
|
end
|
153
156
|
end
|
154
157
|
|
158
|
+
# ==========================
|
159
|
+
# Login Info Model
|
160
|
+
# ==========================
|
155
161
|
RoleDef = {
|
156
162
|
1 => :general,
|
157
163
|
9 => :admin
|
@@ -176,6 +182,9 @@ module LeoFSManager
|
|
176
182
|
end
|
177
183
|
end
|
178
184
|
|
185
|
+
# ==========================
|
186
|
+
# User Info Model
|
187
|
+
# ==========================
|
179
188
|
class User
|
180
189
|
attr_reader :user_id, :role_id, :access_key_id, :created_at
|
181
190
|
|
@@ -191,7 +200,9 @@ module LeoFSManager
|
|
191
200
|
end
|
192
201
|
end
|
193
202
|
|
194
|
-
#
|
203
|
+
# ==========================
|
204
|
+
# Endpoint Model
|
205
|
+
# ==========================
|
195
206
|
class Endpoint
|
196
207
|
# host of the endpoint
|
197
208
|
attr_reader :endpoint
|
@@ -204,7 +215,9 @@ module LeoFSManager
|
|
204
215
|
end
|
205
216
|
end
|
206
217
|
|
218
|
+
# ==========================
|
207
219
|
# S3-Bucket Model
|
220
|
+
# ==========================
|
208
221
|
class Bucket
|
209
222
|
# name of bucket
|
210
223
|
attr_reader :name
|
@@ -219,4 +232,25 @@ module LeoFSManager
|
|
219
232
|
@created_at = Time.parse(h[:created_at])
|
220
233
|
end
|
221
234
|
end
|
235
|
+
|
236
|
+
# ==========================
|
237
|
+
# Compaction Status Model
|
238
|
+
# ==========================
|
239
|
+
class CompactionStatus
|
240
|
+
attr_reader :status
|
241
|
+
attr_reader :last_compaction_start
|
242
|
+
attr_reader :total_targets
|
243
|
+
attr_reader :num_of_pending_targets
|
244
|
+
attr_reader :num_of_ongoing_targets
|
245
|
+
attr_reader :num_of_out_of_targets
|
246
|
+
|
247
|
+
def initialize(h)
|
248
|
+
@status = h[:status]
|
249
|
+
@last_compaction_start = h[:last_compaction_start]
|
250
|
+
@total_targets = h[:total_targets]
|
251
|
+
@num_of_pending_targets = h[:num_of_pending_targets]
|
252
|
+
@num_of_ongoing_targets = h[:num_of_ongoing_targets]
|
253
|
+
@num_of_out_of_targets = h[:num_of_out_of_targets]
|
254
|
+
end
|
255
|
+
end
|
222
256
|
end
|
data/lib/leofs_manager_client.rb
CHANGED
@@ -26,7 +26,7 @@ require "time"
|
|
26
26
|
require_relative "leofs_manager_client/leofs_manager_models"
|
27
27
|
|
28
28
|
module LeoFSManager
|
29
|
-
VERSION = "0.
|
29
|
+
VERSION = "0.4.0"
|
30
30
|
|
31
31
|
class Client
|
32
32
|
CMD_VERSION = "version"
|
@@ -39,7 +39,10 @@ module LeoFSManager
|
|
39
39
|
CMD_REBALANCE = "rebalance"
|
40
40
|
CMD_WHEREIS = "whereis %s"
|
41
41
|
CMD_DU = "du %s"
|
42
|
-
|
42
|
+
CMD_COMPACT_START = "compact start %s %s %s"
|
43
|
+
CMD_COMPACT_SUSPEND = "compact suspend %s"
|
44
|
+
CMD_COMPACT_RESUME = "compact resume %s"
|
45
|
+
CMD_COMPACT_STATUS = "compact status %s"
|
43
46
|
CMD_PURGE = "purge %s"
|
44
47
|
CMD_CRE_USER = "create-user %s %s"
|
45
48
|
CMD_UPD_USER_ROLE = "update-user-role %s %s"
|
@@ -66,7 +69,7 @@ module LeoFSManager
|
|
66
69
|
connect
|
67
70
|
end
|
68
71
|
|
69
|
-
# servers to connect
|
72
|
+
# servers to connect
|
70
73
|
attr_reader :servers
|
71
74
|
# the server currently connected
|
72
75
|
attr_reader :current_server
|
@@ -81,7 +84,7 @@ module LeoFSManager
|
|
81
84
|
|
82
85
|
# Retrieve LeoFS's system status from LeoFS Manager
|
83
86
|
# Return::
|
84
|
-
# Status
|
87
|
+
# Status
|
85
88
|
def status(node=nil)
|
86
89
|
Status.new(sender(CMD_STATUS % node))
|
87
90
|
end
|
@@ -148,14 +151,38 @@ module LeoFSManager
|
|
148
151
|
StorageStat.new(sender(CMD_DU % node))
|
149
152
|
end
|
150
153
|
|
151
|
-
# Execute '
|
154
|
+
# Execute 'compact start'
|
152
155
|
# Return::
|
153
156
|
# _nil_
|
154
|
-
def
|
155
|
-
sender(
|
157
|
+
def compact_start(node, num_of_targets, num_of_concurrents)
|
158
|
+
sender(CMD_COMPACT_START % [node, num_of_targets, num_of_concurrents])
|
156
159
|
nil
|
157
160
|
end
|
158
161
|
|
162
|
+
# Execute 'compact suspend'
|
163
|
+
# Return::
|
164
|
+
# _nil_
|
165
|
+
def compact_suspend(node)
|
166
|
+
sender(CMD_COMPACT_SUSPEND % node)
|
167
|
+
nil
|
168
|
+
end
|
169
|
+
|
170
|
+
# Execute 'compact suspend'
|
171
|
+
# Return::
|
172
|
+
# _nil_
|
173
|
+
def compact_resume(node)
|
174
|
+
sender(CMD_COMPACT_RESUME % node)
|
175
|
+
nil
|
176
|
+
end
|
177
|
+
|
178
|
+
# Execute 'compact status'
|
179
|
+
# Return::
|
180
|
+
# _nil_
|
181
|
+
def compact_status(node)
|
182
|
+
compaction = sender(CMD_COMPACT_STATUS % node)[:compaction_status]
|
183
|
+
CompactionStatus.new(compaction)
|
184
|
+
end
|
185
|
+
|
159
186
|
# Purge a cache in gateways
|
160
187
|
# Return::
|
161
188
|
# _nil_
|
@@ -341,4 +368,6 @@ if __FILE__ == $PROGRAM_NAME
|
|
341
368
|
p m.status("storage_0@127.0.0.1")
|
342
369
|
p m.get_buckets()
|
343
370
|
p m.whereis("photo/hawaii-0.jpg")
|
371
|
+
p m.du("storage_0@127.0.0.1")
|
372
|
+
p m.compact_status("storage_0@127.0.0.1")
|
344
373
|
end
|
data/spec/dummy_tcp_server.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# ======================================================================
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# LeoFS Manager Client
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Copyright (c) 2012 Rakuten, Inc.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# This file is provided to you under the Apache License,
|
8
8
|
# Version 2.0 (the "License"); you may not use this file
|
9
9
|
# except in compliance with the License. You may obtain
|
10
10
|
# a copy of the License at
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# Unless required by applicable law or agreed to in writing,
|
15
15
|
# software distributed under the License is distributed on an
|
16
16
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
17
17
|
# KIND, either express or implied. See the License for the
|
18
18
|
# specific language governing permissions and limitations
|
19
19
|
# under the License.
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# ======================================================================
|
22
22
|
|
23
23
|
require "socket"
|
@@ -65,7 +65,7 @@ module Dummy
|
|
65
65
|
|
66
66
|
Whereis = {
|
67
67
|
:assigned_info => [
|
68
|
-
{
|
68
|
+
{
|
69
69
|
:node => "storage_0@127.0.0.1",
|
70
70
|
:vnode_id => "",
|
71
71
|
:size => "",
|
@@ -78,35 +78,23 @@ module Dummy
|
|
78
78
|
]
|
79
79
|
}.to_json
|
80
80
|
|
81
|
-
GetEndpoints = {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
81
|
+
GetEndpoints = {:endpoints => [{:endpoint => "s3.amazonaws.com", :created_at=>"2012-09-21 15:08:11 +0900"},
|
82
|
+
{:endpoint => "localhost", :created_at=>"2012-09-21 15:08:11 +0900"},
|
83
|
+
{:endpoint => "foo", :created_at=>"2012-09-21 18:51:08 +0900"},
|
84
|
+
{:endpoint => "leofs.org", :created_at=>"2012-09-21 15:08:11 +0900"}
|
85
|
+
]}.to_json
|
86
|
+
GetBuckets = {:buckets => [{:bucket => "test",
|
87
|
+
:owner => "test",
|
88
|
+
:created_at => "2012-09-24 15:38:49 +0900"
|
89
|
+
}]}.to_json
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
:owner => "test",
|
95
|
-
:created_at => "2012-09-24 15:38:49 +0900"
|
96
|
-
}
|
97
|
-
]
|
98
|
-
}.to_json
|
91
|
+
GetUsers = {:users => [{:access_key_id => "05236",
|
92
|
+
:user_id => "_test_leofs_",
|
93
|
+
:role_id => 1,
|
94
|
+
:created_at => "2012-11-20 15:13:20 +0900"}]}.to_json
|
99
95
|
|
100
|
-
|
101
|
-
|
102
|
-
{ :access_key_id => "05236", :user_id => "_test_leofs_", :role_id => 1, :created_at => "2012-11-20 15:13:20 +0900" }
|
103
|
-
]
|
104
|
-
}.to_json
|
105
|
-
|
106
|
-
CreateUser = {
|
107
|
-
:access_key_id => "xxxxxxxxxxxxxxxxxxxx",
|
108
|
-
:secret_access_key => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
109
|
-
}.to_json
|
96
|
+
CreateUser = {:access_key_id => "xxxxxxxxxxxxxxxxxxxx",
|
97
|
+
:secret_access_key => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}.to_json
|
110
98
|
end
|
111
99
|
|
112
100
|
Argument = "arg" # passed to command which requires some arguments.
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# ======================================================================
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# LeoFS Manager Client
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Copyright (c) 2012 Rakuten, Inc.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# This file is provided to you under the Apache License,
|
8
8
|
# Version 2.0 (the "License"); you may not use this file
|
9
9
|
# except in compliance with the License. You may obtain
|
10
10
|
# a copy of the License at
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# Unless required by applicable law or agreed to in writing,
|
15
15
|
# software distributed under the License is distributed on an
|
16
16
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
17
17
|
# KIND, either express or implied. See the License for the
|
18
18
|
# specific language governing permissions and limitations
|
19
19
|
# under the License.
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# ======================================================================
|
22
22
|
|
23
23
|
require "json"
|
@@ -31,13 +31,13 @@ $DEBUG = false
|
|
31
31
|
|
32
32
|
# key: api_name, value: num of args
|
33
33
|
NoResultAPIs = {
|
34
|
-
:start => 0,
|
35
|
-
:detach => 1,
|
36
|
-
:rebalance => 0,
|
37
|
-
:compact => 1,
|
34
|
+
:start => 0,
|
35
|
+
:detach => 1,
|
36
|
+
:rebalance => 0,
|
37
|
+
:compact => 1,
|
38
38
|
:purge => 1,
|
39
|
-
:set_endpoint => 1,
|
40
|
-
:del_endpoint => 1,
|
39
|
+
:set_endpoint => 1,
|
40
|
+
:del_endpoint => 1,
|
41
41
|
:add_bucket => 2
|
42
42
|
}
|
43
43
|
|
@@ -54,14 +54,14 @@ describe LeoFSManager do
|
|
54
54
|
|
55
55
|
context "there is no last compaction" do
|
56
56
|
subject do
|
57
|
-
StorageStat.new(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
StorageStat.new(:active_num_of_objects => 0,
|
58
|
+
:total_num_of_objects => 0,
|
59
|
+
:active_size_of_objects => 0,
|
60
|
+
:total_size_of_objects => 0,
|
61
|
+
:ratio_of_active_size => "0.0%"
|
62
|
+
:last_compaction_start => "____-_-__- __:__:__",
|
63
|
+
:last_compaction_end => "____-_-__- __:__:__"
|
64
|
+
)
|
65
65
|
end
|
66
66
|
|
67
67
|
it_behaves_like StorageStat
|
@@ -83,7 +83,7 @@ describe LeoFSManager do
|
|
83
83
|
:last_compaction_end => time_str
|
84
84
|
)
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
it_behaves_like StorageStat
|
88
88
|
|
89
89
|
its(:last_compaction_start) { subject.to_s == time_str }
|
@@ -128,7 +128,7 @@ describe LeoFSManager do
|
|
128
128
|
where_info.should be_a AssignedFile
|
129
129
|
where_info.num_of_chunks.should be_a Integer
|
130
130
|
end
|
131
|
-
end
|
131
|
+
end
|
132
132
|
end
|
133
133
|
|
134
134
|
describe "#du" do
|
@@ -140,7 +140,7 @@ describe LeoFSManager do
|
|
140
140
|
describe "#create_user" do
|
141
141
|
it "returns Credential" do
|
142
142
|
subject.create_user("user_id", "password").should be_a Credential
|
143
|
-
end
|
143
|
+
end
|
144
144
|
|
145
145
|
it "goes with only user_id" do
|
146
146
|
subject.create_user("user_id").should be_a Credential
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leofs_manager_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Masaki Matsushita
|
@@ -10,7 +9,7 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
14
|
description: Client for LeoFS Manager
|
16
15
|
email:
|
@@ -31,27 +30,26 @@ files:
|
|
31
30
|
- spec/leofs_manager_client_spec.rb
|
32
31
|
homepage: ''
|
33
32
|
licenses: []
|
33
|
+
metadata: {}
|
34
34
|
post_install_message:
|
35
35
|
rdoc_options: []
|
36
36
|
require_paths:
|
37
37
|
- lib
|
38
38
|
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
39
|
requirements:
|
41
40
|
- - ! '>='
|
42
41
|
- !ruby/object:Gem::Version
|
43
42
|
version: '0'
|
44
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
44
|
requirements:
|
47
45
|
- - ! '>='
|
48
46
|
- !ruby/object:Gem::Version
|
49
47
|
version: '0'
|
50
48
|
requirements: []
|
51
49
|
rubyforge_project:
|
52
|
-
rubygems_version:
|
50
|
+
rubygems_version: 2.0.2
|
53
51
|
signing_key:
|
54
|
-
specification_version:
|
52
|
+
specification_version: 4
|
55
53
|
summary: Client for LeoFS Manager
|
56
54
|
test_files:
|
57
55
|
- spec/dummy_tcp_server.rb
|