lumberg 2.0.0.pre20 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +20 -19
- data/lib/lumberg/format_whm.rb +21 -13
- data/lib/lumberg/version.rb +1 -1
- data/lib/lumberg/whm.rb +10 -9
- data/lib/lumberg/whm/server.rb +4 -0
- data/lib/lumberg/whm/transfer_tool.rb +165 -0
- data/spec/vcr_cassettes/whm/transfer_tool/check.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/create.yml +72 -0
- data/spec/vcr_cassettes/whm/transfer_tool/enqueue.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/pause.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/show_log.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/start.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/status.yml +44 -0
- data/spec/vcr_cassettes/whm/transfer_tool/validate_user.yml +44 -0
- data/spec/whm/server_spec.rb +6 -0
- data/spec/whm/transfer_tool_spec.rb +172 -0
- metadata +25 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9592d20229a7597396c55e15b997aaeda53f9c96
|
4
|
+
data.tar.gz: 1dc200699df461f25dfb1d81e2ec07e4b0bf72e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c67a6453be51e33310a50b630a4e4ceeedcca36901aca1c86050b7d97e94f0354b0d009f27aedebf8182f0709a799906190eab609bdb32f6e99835fd1abaa769
|
7
|
+
data.tar.gz: ab01a5ec1b84502064133d536d19e226529f8151f459cc746e54e8ebbccee05fdd04b8cfa82d0c3336d3baf7df4aee5f82d7842077a239d9caaee41bbb3f05f5
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -7,13 +7,19 @@ beta-ish. Please report any issues you find. :)
|
|
7
7
|
|
8
8
|
[RDoc](http://rdoc.info/github/site5/lumberg/master/frames)
|
9
9
|
|
10
|
-
Confirmed to work with ruby 1.9.3, 2.0.0, 2.1.3 and JRuby 1.9 mode
|
11
|
-
cPanel 11.28+
|
10
|
+
Confirmed to work with ruby 1.9.3, 2.0.0, 2.1.3, 2.2.0 and JRuby 1.9 mode.
|
12
11
|
|
13
12
|
[Build Status]: http://travis-ci.org/site5/lumberg
|
14
13
|
[Build Icon]: https://secure.travis-ci.org/site5/lumberg.png?branch=master
|
15
14
|
|
16
15
|
|
16
|
+
## cPanel Version Targets
|
17
|
+
|
18
|
+
* cPanel 11.4x: _v2.0.0_
|
19
|
+
* cPanel 11.3x: _v2.0.0.pre10_
|
20
|
+
* cPanel 11.2x: _v1.1.1_
|
21
|
+
|
22
|
+
|
17
23
|
## Install
|
18
24
|
|
19
25
|
gem install lumberg
|
@@ -35,9 +41,10 @@ If you are using HTTP Basic Authentication with a username/password:
|
|
35
41
|
|
36
42
|
```ruby
|
37
43
|
server = Lumberg::Whm::Server.new(
|
38
|
-
host:
|
39
|
-
user:
|
40
|
-
hash:
|
44
|
+
host: WHM_HOST,
|
45
|
+
user: USERNAME,
|
46
|
+
hash: 'my_password',
|
47
|
+
basic_auth: true
|
41
48
|
)
|
42
49
|
```
|
43
50
|
|
@@ -133,7 +140,6 @@ p "Found user '#{acct[:user]}' with domain '#{acct[:domain]}'"
|
|
133
140
|
Found user 'newuser' with domain 'newuser.com'
|
134
141
|
```
|
135
142
|
|
136
|
-
|
137
143
|
Suspending an account is simple and the reason for suspension is optional.
|
138
144
|
|
139
145
|
```ruby
|
@@ -221,12 +227,6 @@ correspond to cPanel API modules. cPanel API module coverage is currently
|
|
221
227
|
incomplete and we're seeking contributions. Check out [Extending
|
222
228
|
Lumberg::Cpanel](#extending-lumbergcpanel) for details on how you can help.
|
223
229
|
|
224
|
-
#### Cpanel 11.3x vs 11.4x
|
225
|
-
|
226
|
-
Prefer Lumberg _v2.0.0.pre10_ if you're running Cpanel 11.3x.
|
227
|
-
|
228
|
-
We're targetting Cpanel 11.4x from Lumberg _v2.0.0.pre11_ and above.
|
229
|
-
|
230
230
|
#### Email example
|
231
231
|
|
232
232
|
```ruby
|
@@ -247,9 +247,9 @@ email.add_forwarder(
|
|
247
247
|
fwdopt: "fwd",
|
248
248
|
fwdemail: "dest@other-domain.com"
|
249
249
|
)
|
250
|
-
|
251
250
|
```
|
252
251
|
|
252
|
+
|
253
253
|
## Contributing
|
254
254
|
|
255
255
|
### Extending Lumberg::Cpanel
|
@@ -324,7 +324,7 @@ email.add_forwarder(
|
|
324
324
|
|
325
325
|
- In many cases, you'll name your methods to match up
|
326
326
|
with the documented cPanel API methods. However, the documented method
|
327
|
-
names are sometimes a bit lengthy, confusing, or otherwise
|
327
|
+
names are sometimes a bit lengthy, confusing, or otherwise unwieldy; feel
|
328
328
|
free to give your corresponding method an improved name.
|
329
329
|
- Use [TomDoc](http://tomdoc.org/) documentation for your methods.
|
330
330
|
Be sure to document all required and optional parameters from the
|
@@ -335,6 +335,7 @@ email.add_forwarder(
|
|
335
335
|
other parameters.
|
336
336
|
|
337
337
|
### Sanitizing VCR cassettes
|
338
|
+
|
338
339
|
All HTTP interactions are recorded using VCR and FakeWeb. Please be sure to remove
|
339
340
|
sensitive data from your cassettes. A Rake task is provided for this purpose:
|
340
341
|
```
|
@@ -347,13 +348,13 @@ information still present (check URLs, authorization params, etc.).
|
|
347
348
|
|
348
349
|
* Fork the project.
|
349
350
|
* Make your feature addition or bug fix.
|
350
|
-
* Add tests for it. This is important so
|
351
|
+
* Add tests for it. This is important so we don't break it in a
|
351
352
|
future version unintentionally.
|
352
|
-
* Commit, do not mess with
|
353
|
+
* Commit, do not mess with Rakefile, version, or history.
|
353
354
|
(if you want to have your own version, that is fine but bump version in a
|
354
|
-
commit by itself
|
355
|
-
* Send
|
355
|
+
commit by itself we can ignore when we pull)
|
356
|
+
* Send us a pull request. Bonus points for topic branches.
|
356
357
|
|
357
358
|
## Copyright
|
358
359
|
|
359
|
-
Copyright (c)
|
360
|
+
Copyright (c) 2015 WWWH, LLC. See LICENSE for details.
|
data/lib/lumberg/format_whm.rb
CHANGED
@@ -39,24 +39,26 @@ module Lumberg
|
|
39
39
|
success, message, params = false, nil, {}
|
40
40
|
|
41
41
|
case @type || response_type(response)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
42
|
+
when :action
|
43
|
+
success, message, params = format_action_response(response)
|
44
|
+
when :query
|
45
|
+
success, message, params = format_query_response(response)
|
46
|
+
when :ssl
|
47
|
+
success, message, params = format_ssl_response(response)
|
48
|
+
when :whostmgr
|
49
|
+
success, message, params = format_whostmgr_response(response)
|
50
|
+
when :error
|
51
|
+
message = response['error']
|
52
|
+
when :xfer
|
53
|
+
success, message, params = format_xfer_response(response)
|
54
|
+
else
|
55
|
+
message = "Unknown error occurred #{response.inspect}"
|
54
56
|
end
|
55
57
|
|
56
58
|
params = Whm::symbolize_keys(params)
|
57
59
|
params = Whm::to_bool(params, @boolean_params)
|
58
60
|
|
59
|
-
{success: success, message: message, params: params}
|
61
|
+
{ success: success, message: message, params: params }
|
60
62
|
end
|
61
63
|
|
62
64
|
def response_type(response)
|
@@ -150,5 +152,11 @@ module Lumberg
|
|
150
152
|
return false, "", []
|
151
153
|
end
|
152
154
|
end
|
155
|
+
|
156
|
+
def format_xfer_response(response)
|
157
|
+
metadata = response['metadata']
|
158
|
+
|
159
|
+
return metadata['result'].to_i == 1, metadata['reason'], response['data']
|
160
|
+
end
|
153
161
|
end
|
154
162
|
end
|
data/lib/lumberg/version.rb
CHANGED
data/lib/lumberg/whm.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Lumberg
|
2
2
|
module Whm
|
3
|
-
autoload :Base,
|
4
|
-
autoload :Server,
|
5
|
-
autoload :Account,
|
6
|
-
autoload :Dns,
|
7
|
-
autoload :Reseller,
|
8
|
-
autoload :Cert,
|
3
|
+
autoload :Base, 'lumberg/whm/base'
|
4
|
+
autoload :Server, 'lumberg/whm/server'
|
5
|
+
autoload :Account, 'lumberg/whm/account'
|
6
|
+
autoload :Dns, 'lumberg/whm/dns'
|
7
|
+
autoload :Reseller, 'lumberg/whm/reseller'
|
8
|
+
autoload :Cert, 'lumberg/whm/cert'
|
9
|
+
autoload :TransferTool, 'lumberg/whm/transfer_tool'
|
9
10
|
|
10
11
|
class << self
|
11
12
|
|
@@ -16,7 +17,7 @@ module Lumberg
|
|
16
17
|
arg.map { |elem| symbolize_keys elem }
|
17
18
|
when Hash
|
18
19
|
Hash[
|
19
|
-
arg.map { |key, value|
|
20
|
+
arg.map { |key, value|
|
20
21
|
k = key.is_a?(String) ? key.gsub('-', '_').to_sym : key
|
21
22
|
v = symbolize_keys value
|
22
23
|
[k,v]
|
@@ -57,8 +58,8 @@ module Lumberg
|
|
57
58
|
elsif input == true
|
58
59
|
1
|
59
60
|
elsif input.is_a?(Hash)
|
60
|
-
Hash[
|
61
|
-
input.map {|k,v|
|
61
|
+
Hash[
|
62
|
+
input.map {|k,v|
|
62
63
|
v = from_bool(v)
|
63
64
|
[k,v]
|
64
65
|
}
|
data/lib/lumberg/whm/server.rb
CHANGED
@@ -0,0 +1,165 @@
|
|
1
|
+
module Lumberg
|
2
|
+
module Whm
|
3
|
+
class TransferTool < Base
|
4
|
+
|
5
|
+
# Public: Creates a new transfer session.
|
6
|
+
#
|
7
|
+
# options - Hash options for API call params. (default: {})
|
8
|
+
# :host - String hostname of the remote server.
|
9
|
+
# :user - String username to connect on remote server.
|
10
|
+
# :password - String password for account specified above.
|
11
|
+
#
|
12
|
+
# Returns Hash API Response.
|
13
|
+
def create(options = {})
|
14
|
+
default_options = { remote_server_type: 'auto',
|
15
|
+
port: 22,
|
16
|
+
root_escalation_method: 'sudo',
|
17
|
+
transfer_threads: 2,
|
18
|
+
restore_threads: 2,
|
19
|
+
unrestricted_restore: 1,
|
20
|
+
compressed: 1,
|
21
|
+
unencrypted: 0,
|
22
|
+
use_backups: 1,
|
23
|
+
low_priority: 0,
|
24
|
+
enable_custom_pkgacct: 0 }
|
25
|
+
|
26
|
+
options.merge!("api.version" => "1")
|
27
|
+
|
28
|
+
server.force_response_type = :xfer
|
29
|
+
|
30
|
+
server.perform_request(
|
31
|
+
'create_remote_root_transfer_session',
|
32
|
+
default_options.merge(options)
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Public: Checks a given transfer session ID.
|
37
|
+
#
|
38
|
+
# transfer_session_id - String ID of the transfer session.
|
39
|
+
#
|
40
|
+
# Returns Hash API Response.
|
41
|
+
def check(transfer_session_id)
|
42
|
+
options = { transfer_session_id: transfer_session_id }
|
43
|
+
|
44
|
+
server.force_response_type = :xfer
|
45
|
+
|
46
|
+
server.perform_request(
|
47
|
+
'retrieve_transfer_session_remote_analysis',
|
48
|
+
options.merge("api.version" => "1")
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Public: Validates a system user, preventing account conflicts.
|
53
|
+
#
|
54
|
+
# username - String username to validate.
|
55
|
+
#
|
56
|
+
# Returns Hash API Response.
|
57
|
+
def validate_user(username)
|
58
|
+
options = { user: username }
|
59
|
+
|
60
|
+
server.force_response_type = :xfer
|
61
|
+
|
62
|
+
server.perform_request(
|
63
|
+
'validate_system_user',
|
64
|
+
options.merge("api.version" => "1")
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Public: Enqueues a transfer session.
|
69
|
+
#
|
70
|
+
# options - Hash options for API call params. (default: {})
|
71
|
+
# :transfer_session_id - String ID of the transfer session.
|
72
|
+
# :queue - String transfer queue name. Can be one of the
|
73
|
+
# following: LegacyAccountBackup,
|
74
|
+
# FeatureListRemoteRoot, PackageRemoteRoot,
|
75
|
+
# AccountLocal, AccountRemoteRoot and
|
76
|
+
# AccountRemoteUser.
|
77
|
+
# (default: 'AccountRemoteRoot')
|
78
|
+
# :size - Integer account size in Bytes.
|
79
|
+
# :other_arguments - Doc here
|
80
|
+
# https://documentation.cpanel.net/display/SDK/WHM+API+1+-+enqueue_transfer_item
|
81
|
+
#
|
82
|
+
# Returns Hash API Reponse.
|
83
|
+
def enqueue(options = {})
|
84
|
+
default_options = { "api.version" => "1" }
|
85
|
+
|
86
|
+
options["module"] = options.delete(:queue) || "AccountRemoteRoot"
|
87
|
+
|
88
|
+
if %w(AccountRemoteRoot AccountRemoteUser AccountLocal).include?(options["module"])
|
89
|
+
options[:localuser] = options.delete(:localuser) || options[:user]
|
90
|
+
end
|
91
|
+
|
92
|
+
server.force_response_type = :xfer
|
93
|
+
|
94
|
+
server.perform_request('enqueue_transfer_item', default_options.merge(options))
|
95
|
+
end
|
96
|
+
|
97
|
+
# Public: Starts or restarts a transfer.
|
98
|
+
#
|
99
|
+
# transfer_session_id - String ID of the transfer session.
|
100
|
+
#
|
101
|
+
# Returns Hash API Response.
|
102
|
+
def start(transfer_session_id)
|
103
|
+
options = { transfer_session_id: transfer_session_id }
|
104
|
+
|
105
|
+
server.force_response_type = :xfer
|
106
|
+
|
107
|
+
server.perform_request(
|
108
|
+
'start_transfer_session',
|
109
|
+
options.merge("api.version" => "1")
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Public: Gets migration status.
|
114
|
+
#
|
115
|
+
# transfer_session_id - String ID of the transfer session.
|
116
|
+
#
|
117
|
+
# Returns Hash API Response.
|
118
|
+
def status(transfer_session_id)
|
119
|
+
options = { transfer_session_id: transfer_session_id }
|
120
|
+
|
121
|
+
server.force_response_type = :xfer
|
122
|
+
|
123
|
+
server.perform_request(
|
124
|
+
'get_transfer_session_state',
|
125
|
+
options.merge("api.version" => "1")
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Public: Shows transfer log.
|
130
|
+
#
|
131
|
+
# transfer_session_id - String ID of the transfer session.
|
132
|
+
# type - Symbol log type, can be either `:common` or
|
133
|
+
# `:error`. (default: :common)
|
134
|
+
#
|
135
|
+
# Returns Hash API Response.
|
136
|
+
def show_log(transfer_session_id, log_type = :common)
|
137
|
+
options = { logfile: log_type == :common ? 'master.log' : 'master.error_log',
|
138
|
+
transfer_session_id: transfer_session_id }
|
139
|
+
|
140
|
+
server.force_response_type = :xfer
|
141
|
+
|
142
|
+
server.perform_request(
|
143
|
+
'fetch_transfer_session_log',
|
144
|
+
options.merge("api.version" => "1")
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Public: Pauses a given transfer session.
|
149
|
+
#
|
150
|
+
# transfer_session_id - String ID of the transfer session.
|
151
|
+
#
|
152
|
+
# Returns Hash API Response.
|
153
|
+
def pause(transfer_session_id)
|
154
|
+
options = { transfer_session_id: transfer_session_id }
|
155
|
+
|
156
|
+
server.force_response_type = :xfer
|
157
|
+
|
158
|
+
server.perform_request(
|
159
|
+
'pause_transfer_session',
|
160
|
+
options.merge("api.version" => "1")
|
161
|
+
)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/retrieve_transfer_session_remote_analysis?api.version=1&transfer_session_id=x
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Tue, 06 Jan 2015 15:00:03 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"metadata":{"reason":"OK","result":"1","version":1,"command":"retrieve_transfer_session_remote_analysis"},"data":{"transfer_session_id":"x","local":{"dbs":{"dbs":{"MYSQL":{"db_db":{"owner":"db"}},"PGSQL":{}},"users":{"MYSQL":{"db_db":{"owner":"db"}},"PGSQL":{}}},"domains":{"db.local":"db","*":"nobody"},"users":{"named":1,"sync":1,"cpaneleximscanner":1,"rpc":1,"mail":1,"xfs":1,"nfsnobody":1,"cpanelhorde":1,"mysql":1,"shutdown":1,"cpanel":1,"operator":1,"cpanelroundcube":1,"vcsa":1,"dbus":1,"db":1,"news":1,"uucp":1,"haldaemon":1,"adm":1,"cpanelphpmyadmin":1,"root":1,"dovenull":1,"rpcuser":1,"gopher":1,"cpses":1,"cpaneleximfilter":1,"cpanellogaholic":1,"bin":1,"mailman":1,"mailnull":1,"cpanellogin":1,"pcap":1,"avahi-autoipd":1,"sshd":1,"lp":1,"cpanelphppgadmin":1,"games":1,"daemon":1,"smmsp":1,"dovecot":1,"ftp":1,"nobody":1,"nscd":1,"halt":1},"dedicated_ips":{},"available_ips":[],"groups":{"kmem":1,"audio":1,"utempter":1,"named":1,"man":1,"disk":1,"mail":1,"cpaneleximscanner":1,"rpc":1,"xfs":1,"cpanelhorde":1,"nfsnobody":1,"mysql":1,"slocate":1,"compiler":1,"cpanel":1,"screen":1,"cpanelroundcube":1,"vcsa":1,"dbus":1,"mailtrap":1,"proftpd":1,"wheel":1,"db":1,"mem":1,"news":1,"dip":1,"haldaemon":1,"uucp":1,"adm":1,"cpanelphpmyadmin":1,"root":1,"dovenull":1,"rpcuser":1,"gopher":1,"cpses":1,"cpaneleximfilter":1,"cpanellogaholic":1,"bin":1,"floppy":1,"mailman":1,"mailnull":1,"users":1,"cpanellogin":1,"pcap":1,"sshd":1,"utmp":1,"tty":1,"avahi-autoipd":1,"sys":1,"lp":1,"games":1,"cpanelphppgadmin":1,"smmsp":1,"daemon":1,"dovecot":1,"ftp":1,"nobody":1,"lock":1,"nscd":1}},"options":{"skip_reseller_privs":"0","unrestricted":"1"},"config":{"shared_mysql_server":"0"},"remote":{"has_owners":1,"has_package_extensions":1,"cpversion":"11.30","has_disk_used":1,"host":"192.168.1.100","dbs":{"dbs":{"MYSQL":{"mylogin_pres411":{"owner":"mylogin"}}},"PGSQL":{}},"users":{"MYSQL":{"mylogin_pres411":{"owner":"mylogin"}},"PGSQL":{}},"resellers":{"reseller":1,"root":1},"conflicts":{},"has_xfertool":1,"server_type":"WHM1130","version":"11.44.1.23"},"items":{"packages":[{"name":"reseller_one","featurelist":"default"}],"accounts":[{"has_dedicated_ip":0,"owner":"root","bytesused":73682944,"user":"mylogin","domain":"mylogin-account.local"},{"has_dedicated_ip":0,"owner":"reseller","bytesused":172032,"user":"reseller","domain":"reseller-test.com"}]}}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Tue, 06 Jan 2015 15:00:04 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/create_remote_root_transfer_session?api.version=1&compressed=1&enable_custom_pkgacct=0&host=192.168.1.100&low_priority=0&password=t00r&port=22&remote_server_type=auto&restore_threads=2&root_escalation_method=sudo&transfer_threads=2&unencrypted=0&unrestricted_restore=1&use_backups=1&user=mylogin
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Tue, 06 Jan 2015 14:34:06 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: ASCII-8BIT
|
41
|
+
string: !binary |-
|
42
|
+
eyJtZXRhZGF0YSI6eyJyZXN1bHQiOiIxIiwicmVhc29uIjoiT0siLCJjb21t
|
43
|
+
YW5kIjoiY3JlYXRlX3JlbW90ZV9yb290X3RyYW5zZmVyX3Nlc3Npb24iLCJ2
|
44
|
+
ZXJzaW9uIjoxfSwiZGF0YSI6eyJhbmFseXplX3Jhd291dCI6IkZldGNoaW5n
|
45
|
+
IGluZm9ybWF0aW9uIGZyb20gcmVtb3RlIGhvc3Q6IOKAnDE5Mi4xNjguMS4x
|
46
|
+
MDDigJ0g4oCmIOKAplxuRG9uZVxuRmV0Y2hpbmcgaW5mb3JtYXRpb24gZnJv
|
47
|
+
bSByZW1vdGUgaG9zdDog4oCcMTkyLjE2OC4xLjEwMOKAnSDigKYg4oCmXG5E
|
48
|
+
b25lXG4iLCJjcmVhdGVfcmF3b3V0IjoiQmFzaWMgY3JlZGVudGlhbCBjaGVj
|
49
|
+
ayDigKYg4oCmXG5Eb25lXG5GZXRjaGluZyBpbmZvcm1hdGlvbiBmcm9tIHJl
|
50
|
+
bW90ZSBob3N0OiDigJwxOTIuMTY4LjEuMTAw4oCdIOKApiDigKZcbkRvbmVc
|
51
|
+
bkZldGNoaW5nIFdITSBWZXJzaW9uIOKAplxuRG9uZVxuVGVzdGluZyDigJwx
|
52
|
+
OTIuMTY4LjEuMTAw4oCdIGZvciB0cmFuc2ZlciBzdHJlYW1pbmcgc3VwcG9y
|
53
|
+
dCB3aXRoIHBhc3N3b3JkIGF1dGhlbnRpY2F0aW9uLi4uLjxzdHJvbmc+VGhl
|
54
|
+
IHN5c3RlbSBpcyB1bmFibGUgdG8gc3RyZWFtIGFjY291bnQgdHJhbnNmZXJz
|
55
|
+
IHdpdGggcGFzc3dvcmQgYXV0aGVudGljYXRpb246PC9zdHJvbmc+IOKAnFN0
|
56
|
+
cmVhbWluZyBub3Qgc3VwcG9ydGVkOiBGZXRjaGluZyBzdHJlYW0gZnJvbSBS
|
57
|
+
ZW1vdGUgV0hNIHVzaW5nIOKAnGh0dHBz4oCdIGZyb20gaG9zdCDigJwxOTIu
|
58
|
+
MTY4LjEuMTAw4oCdIOKAplxuSFRUUC8xLjEgNDAxIEFjY2VzcyBEZW5pZWRc
|
59
|
+
clxuXG7igJ1cbkZldGNoaW5nIGluZm9ybWF0aW9uIGZyb20gcmVtb3RlIGhv
|
60
|
+
c3Q6IOKAnDE5Mi4xNjguMS4xMDDigJ0g4oCmIOKAplxuRG9uZVxuVGVzdGlu
|
61
|
+
ZyDigJwxOTIuMTY4LjEuMTAw4oCdIGZvciB0cmFuc2ZlciBzdHJlYW1pbmcg
|
62
|
+
c3VwcG9ydCB3aXRoIGFjY2Vzc2hhc2ggYXV0aGVudGljYXRpb24uLi4uPHN0
|
63
|
+
cm9uZz5UaGUgc3lzdGVtIGlzIHVuYWJsZSB0byBzdHJlYW0gYWNjb3VudCB0
|
64
|
+
cmFuc2ZlcnMgd2l0aCBhY2Nlc3NoYXNoIGF1dGhlbnRpY2F0aW9uOjwvc3Ry
|
65
|
+
b25nPiDigJxTdHJlYW1pbmcgbm90IHN1cHBvcnRlZDogRmV0Y2hpbmcgc3Ry
|
66
|
+
ZWFtIGZyb20gUmVtb3RlIFdITSB1c2luZyDigJxodHRwc+KAnSBmcm9tIGhv
|
67
|
+
c3Qg4oCcMTkyLjE2OC4xLjEwMOKAnSDigKZcbkFjY2VzcyBkZW5pZWRcclxu
|
68
|
+
RG9uZVxu4oCdXG5SZW1vdGUgU2VydmVyIFR5cGU6IOKAnFdITTExMzDigJ1c
|
69
|
+
biIsInRyYW5zZmVyX3Nlc3Npb25faWQiOiJ4In19
|
70
|
+
http_version:
|
71
|
+
recorded_at: Tue, 06 Jan 2015 14:34:06 GMT
|
72
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/enqueue_transfer_item?api.version=1&localuser=another&module=AccountRemoteRoot&size=73682944&transfer_session_id=x&user=another
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Tue, 06 Jan 2015 19:32:42 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"metadata":{"reason":"OK","result":"1","version":1,"command":"enqueue_transfer_item"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Tue, 06 Jan 2015 19:32:42 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/pause_transfer_session?api.version=1&transfer_session_id=x
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Wed, 07 Jan 2015 13:36:27 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"metadata":{"command":"pause_transfer_session","result":"1","version":1,"reason":"OK"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Wed, 07 Jan 2015 13:36:27 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/fetch_transfer_session_log?api.version=1&logfile=master.log&transfer_session_id=x
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Wed, 07 Jan 2015 13:18:00 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"metadata":{"reason":"OK","command":"fetch_transfer_session_log","version":1,"result":"1"},"data":{"log":"{\"type\":\"control\",\"contents\":{\"action\":\"start\",\"child_number\":0},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"initiator\",\"child_number\":0,\"msg\":\"copyacct\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"version\",\"child_number\":0,\"msg\":\"1.9\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"queue_count\",\"child_number\":0,\"msg\":\"1\",\"queue\":\"TRANSFER\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"queue_size\",\"child_number\":0,\"msg\":\"73682944\",\"queue\":\"TRANSFER\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"queue_count\",\"child_number\":0,\"msg\":\"1\",\"queue\":\"RESTORE\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"queue_size\",\"child_number\":0,\"msg\":\"73682944\",\"queue\":\"RESTORE\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"remotehost\",\"child_number\":0,\"msg\":\"192.168.1.100\"},\"pid\":\"30831\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"start\",\"item\":\"another\",\"logfile\":\"item-TRANSFER_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"queue\":\"TRANSFER\"},\"pid\":\"30833\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"process-item\",\"item\":\"another\",\"logfile\":\"item-TRANSFER_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"msg\":\"item-TRANSFER_AccountRemoteRoot_another\",\"queue\":\"TRANSFER\"},\"pid\":\"30833\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"start-item\",\"item\":\"another\",\"logfile\":\"item-TRANSFER_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"msg\":{\"size\":\"73682944\"},\"queue\":\"TRANSFER\"},\"pid\":\"30833\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"success-item\",\"item\":\"another\",\"logfile\":\"item-TRANSFER_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"msg\":{\"altered_items\":0,\"message\":null,\"dangerous_items\":0,\"contents\":{\"altered_items\":null,\"dangerous_items\":null,\"skipped_items\":null,\"warnings\":null},\"skipped_items\":0,\"warnings\":0,\"size\":\"73682944\"},\"queue\":\"TRANSFER\"},\"pid\":\"30833\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"complete\",\"child_number\":1,\"queue\":\"TRANSFER\"},\"pid\":\"30833\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"start\",\"item\":\"another\",\"logfile\":\"item-RESTORE_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"queue\":\"RESTORE\"},\"pid\":\"30835\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"process-item\",\"item\":\"another\",\"logfile\":\"item-RESTORE_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"msg\":\"item-RESTORE_AccountRemoteRoot_another\",\"queue\":\"RESTORE\"},\"pid\":\"30835\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"start-item\",\"item\":\"another\",\"logfile\":\"item-RESTORE_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"msg\":{\"size\":\"73682944\"},\"queue\":\"RESTORE\"},\"pid\":\"30835\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"success-item\",\"item\":\"another\",\"logfile\":\"item-RESTORE_AccountRemoteRoot_another\",\"item_type\":\"AccountRemoteRoot\",\"local_item\":\"another\",\"item_name\":\"Account\",\"child_number\":1,\"msg\":{\"altered_items\":0,\"message\":null,\"dangerous_items\":0,\"contents\":{\"altered_items\":[],\"dangerous_items\":[],\"skipped_items\":[],\"warnings\":[]},\"skipped_items\":0,\"warnings\":0,\"size\":\"73682944\"},\"queue\":\"RESTORE\"},\"pid\":\"30835\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"complete\",\"child_number\":1,\"queue\":\"RESTORE\"},\"pid\":\"30835\"}\n{\"type\":\"control\",\"contents\":{\"action\":\"complete\",\"child_number\":0},\"pid\":\"30831\"}\n"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Wed, 07 Jan 2015 13:18:00 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/start_transfer_session?api.version=1&transfer_session_id=x
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Tue, 06 Jan 2015 19:36:46 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"data":{"pid":30831},"metadata":{"reason":"OK","result":"1","version":1,"command":"start_transfer_session"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Tue, 06 Jan 2015 19:36:46 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/get_transfer_session_state?api.version=1&transfer_session_id=x
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Wed, 07 Jan 2015 13:13:35 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"data":{"state_name":"COMPLETED"},"metadata":{"reason":"OK","version":1,"result":"1","command":"get_transfer_session_state"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Wed, 07 Jan 2015 13:13:35 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://myhost.com:2087/json-api/validate_system_user?api.version=1&user=another
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- WHM root:iscool
|
12
|
+
Accept-Encoding:
|
13
|
+
- deflate
|
14
|
+
User-Agent:
|
15
|
+
- Faraday v0.9.0
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- cpsrvd/11.44.1.23
|
25
|
+
X-Keep-Alive-Count:
|
26
|
+
- '1'
|
27
|
+
Connection:
|
28
|
+
- Keep-Alive
|
29
|
+
Keep-Alive:
|
30
|
+
- timeout=70, max=200
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Date:
|
34
|
+
- Tue, 06 Jan 2015 16:05:59 GMT
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache
|
37
|
+
Content-Type:
|
38
|
+
- text/plain; charset="utf-8"
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"data":{"reserved":0,"valid_for_transfer":1,"exists":0,"valid_for_new":1},"metadata":{"version":1,"result":"1","command":"validate_system_user","reason":"OK"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Tue, 06 Jan 2015 16:05:59 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
data/spec/whm/server_spec.rb
CHANGED
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lumberg/whm'
|
3
|
+
|
4
|
+
module Lumberg
|
5
|
+
describe Whm::TransferTool do
|
6
|
+
let(:source_server) { '192.168.1.100' }
|
7
|
+
let(:username) { 'mylogin' }
|
8
|
+
let(:password) { 't00r' }
|
9
|
+
let(:xfer_id) { 'x' }
|
10
|
+
|
11
|
+
before do
|
12
|
+
@server = Whm::Server.new(host: @whm_host, hash: @whm_hash)
|
13
|
+
@xfer_tool = Whm::TransferTool.new(server: @server.dup)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#create' do
|
17
|
+
use_vcr_cassette 'whm/transfer_tool/create'
|
18
|
+
|
19
|
+
subject { @xfer_tool.create host: source_server, user: username, password: password }
|
20
|
+
|
21
|
+
its([:success]) { should be_true }
|
22
|
+
its([:message]) { should eq 'OK' }
|
23
|
+
its([:params]) { should include :transfer_session_id }
|
24
|
+
|
25
|
+
it 'has a session ID' do
|
26
|
+
subject[:params][:transfer_session_id].should_not be_empty
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#check' do
|
31
|
+
use_vcr_cassette 'whm/transfer_tool/check'
|
32
|
+
|
33
|
+
subject { @xfer_tool.check xfer_id }
|
34
|
+
|
35
|
+
its([:success]) { should be_true }
|
36
|
+
its([:message]) { should eq 'OK' }
|
37
|
+
its([:params]) { should include :transfer_session_id }
|
38
|
+
|
39
|
+
it 'has local server data' do
|
40
|
+
subject[:params][:local].should_not be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'has remote server data' do
|
44
|
+
subject[:params][:remote].should_not be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#validate_user' do
|
49
|
+
use_vcr_cassette 'whm/transfer_tool/validate_user'
|
50
|
+
|
51
|
+
subject { @xfer_tool.validate_user 'another' }
|
52
|
+
|
53
|
+
its([:success]) { should be_true }
|
54
|
+
its([:message]) { should eq 'OK' }
|
55
|
+
|
56
|
+
it 'checks if user does not exist on local server' do
|
57
|
+
subject[:params][:exists].should eq 0
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'checks if account is not reserved' do
|
61
|
+
subject[:params][:reserved].should eq 0
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'checks if it is possible to create an account with that given login' do
|
65
|
+
subject[:params][:valid_for_new].should eq 1
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'checks if it is possible to migrate account to local server' do
|
69
|
+
subject[:params][:valid_for_transfer].should eq 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#enqueue' do
|
74
|
+
context 'enqueueing a migration' do
|
75
|
+
use_vcr_cassette 'whm/transfer_tool/enqueue'
|
76
|
+
|
77
|
+
subject do
|
78
|
+
@xfer_tool.enqueue(
|
79
|
+
transfer_session_id: xfer_id,
|
80
|
+
size: 73682944, user: 'another')
|
81
|
+
end
|
82
|
+
|
83
|
+
its([:success]) { should be_true }
|
84
|
+
its([:message]) { should eq 'OK' }
|
85
|
+
its([:params]) { should be_nil }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'copying package' do
|
89
|
+
let(:enqueue_transfer_options) do
|
90
|
+
{ transfer_session_id: xfer_id,
|
91
|
+
package: 'some_package' }
|
92
|
+
end
|
93
|
+
|
94
|
+
let(:queue) { 'PackageRemoteRoot' }
|
95
|
+
|
96
|
+
before do
|
97
|
+
stub_request(
|
98
|
+
:get,
|
99
|
+
/enqueue_transfer_item\?api\.version=1&module=PackageRemoteRoot&package=some_package&transfer_session_id=x/
|
100
|
+
).to_return(
|
101
|
+
status: 200,
|
102
|
+
body: '{"metadata":{"reason":"OK","result":"1","version":1,"command":"enqueue_transfer_item"}}'
|
103
|
+
)
|
104
|
+
|
105
|
+
enqueue_transfer_options.merge!(
|
106
|
+
"module" => "PackageRemoteRoot",
|
107
|
+
"api.version" => "1"
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'enqueues migration to PackageRemoteRoot queue and does not pass :localuser to cPanel/WHM' do
|
112
|
+
Lumberg::Whm::Server.any_instance.should_receive(:perform_request)
|
113
|
+
.with 'enqueue_transfer_item', enqueue_transfer_options
|
114
|
+
|
115
|
+
@xfer_tool.enqueue enqueue_transfer_options.merge(queue: queue)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#start' do
|
121
|
+
use_vcr_cassette 'whm/transfer_tool/start'
|
122
|
+
|
123
|
+
subject { @xfer_tool.start xfer_id }
|
124
|
+
|
125
|
+
its([:success]) { should be_true }
|
126
|
+
its([:message]) { should eq 'OK' }
|
127
|
+
its([:params]) { should include :pid }
|
128
|
+
|
129
|
+
it 'sets PID for current migration' do
|
130
|
+
subject[:params][:pid].should be_an Integer
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#status' do
|
135
|
+
use_vcr_cassette 'whm/transfer_tool/status'
|
136
|
+
|
137
|
+
subject { @xfer_tool.status xfer_id }
|
138
|
+
|
139
|
+
its([:success]) { should be_true }
|
140
|
+
its([:message]) { should eq 'OK' }
|
141
|
+
its([:params]) { should include :state_name }
|
142
|
+
|
143
|
+
it 'returns current status' do
|
144
|
+
subject[:params][:state_name].should_not be_empty
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#show_log' do
|
149
|
+
use_vcr_cassette 'whm/transfer_tool/show_log'
|
150
|
+
|
151
|
+
subject { @xfer_tool.show_log xfer_id }
|
152
|
+
|
153
|
+
its([:success]) { should be_true }
|
154
|
+
its([:message]) { should eq 'OK' }
|
155
|
+
its([:params]) { should include :log }
|
156
|
+
|
157
|
+
it 'shows log for current transfer' do
|
158
|
+
subject[:params][:log].should_not be_empty
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#pause' do
|
163
|
+
use_vcr_cassette 'whm/transfer_tool/pause'
|
164
|
+
|
165
|
+
subject { @xfer_tool.pause xfer_id }
|
166
|
+
|
167
|
+
its([:success]) { should be_true }
|
168
|
+
its([:message]) { should eq 'OK' }
|
169
|
+
its([:params]) { should be_nil }
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumberg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Mazzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.8.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.8.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/lumberg/whm/dns.rb
|
163
163
|
- lib/lumberg/whm/reseller.rb
|
164
164
|
- lib/lumberg/whm/server.rb
|
165
|
+
- lib/lumberg/whm/transfer_tool.rb
|
165
166
|
- lib/lumberg/whostmgr.rb
|
166
167
|
- lib/lumberg/whostmgr/base.rb
|
167
168
|
- lib/lumberg/whostmgr/ssl.rb
|
@@ -394,6 +395,14 @@ files:
|
|
394
395
|
- spec/vcr_cassettes/whm/server/systemloadavg.yml
|
395
396
|
- spec/vcr_cassettes/whm/server/themes.yml
|
396
397
|
- spec/vcr_cassettes/whm/server/version.yml
|
398
|
+
- spec/vcr_cassettes/whm/transfer_tool/check.yml
|
399
|
+
- spec/vcr_cassettes/whm/transfer_tool/create.yml
|
400
|
+
- spec/vcr_cassettes/whm/transfer_tool/enqueue.yml
|
401
|
+
- spec/vcr_cassettes/whm/transfer_tool/pause.yml
|
402
|
+
- spec/vcr_cassettes/whm/transfer_tool/show_log.yml
|
403
|
+
- spec/vcr_cassettes/whm/transfer_tool/start.yml
|
404
|
+
- spec/vcr_cassettes/whm/transfer_tool/status.yml
|
405
|
+
- spec/vcr_cassettes/whm/transfer_tool/validate_user.yml
|
397
406
|
- spec/vcr_cassettes/whostmgr/ssl/create.yml
|
398
407
|
- spec/vcr_cassettes/whostmgr/ssl/remove.yml
|
399
408
|
- spec/vcr_cassettes/whostmgr/ssl/remove_data.yml
|
@@ -403,6 +412,7 @@ files:
|
|
403
412
|
- spec/whm/dns_spec.rb
|
404
413
|
- spec/whm/reseller_spec.rb
|
405
414
|
- spec/whm/server_spec.rb
|
415
|
+
- spec/whm/transfer_tool_spec.rb
|
406
416
|
- spec/whm/whm_spec.rb
|
407
417
|
- spec/whostmgr/ssl_spec.rb
|
408
418
|
homepage: ''
|
@@ -420,9 +430,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
420
430
|
version: '0'
|
421
431
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
422
432
|
requirements:
|
423
|
-
- - "
|
433
|
+
- - ">="
|
424
434
|
- !ruby/object:Gem::Version
|
425
|
-
version:
|
435
|
+
version: '0'
|
426
436
|
requirements: []
|
427
437
|
rubyforge_project: lumberg
|
428
438
|
rubygems_version: 2.2.2
|
@@ -659,6 +669,14 @@ test_files:
|
|
659
669
|
- spec/vcr_cassettes/whm/server/systemloadavg.yml
|
660
670
|
- spec/vcr_cassettes/whm/server/themes.yml
|
661
671
|
- spec/vcr_cassettes/whm/server/version.yml
|
672
|
+
- spec/vcr_cassettes/whm/transfer_tool/check.yml
|
673
|
+
- spec/vcr_cassettes/whm/transfer_tool/create.yml
|
674
|
+
- spec/vcr_cassettes/whm/transfer_tool/enqueue.yml
|
675
|
+
- spec/vcr_cassettes/whm/transfer_tool/pause.yml
|
676
|
+
- spec/vcr_cassettes/whm/transfer_tool/show_log.yml
|
677
|
+
- spec/vcr_cassettes/whm/transfer_tool/start.yml
|
678
|
+
- spec/vcr_cassettes/whm/transfer_tool/status.yml
|
679
|
+
- spec/vcr_cassettes/whm/transfer_tool/validate_user.yml
|
662
680
|
- spec/vcr_cassettes/whostmgr/ssl/create.yml
|
663
681
|
- spec/vcr_cassettes/whostmgr/ssl/remove.yml
|
664
682
|
- spec/vcr_cassettes/whostmgr/ssl/remove_data.yml
|
@@ -668,6 +686,7 @@ test_files:
|
|
668
686
|
- spec/whm/dns_spec.rb
|
669
687
|
- spec/whm/reseller_spec.rb
|
670
688
|
- spec/whm/server_spec.rb
|
689
|
+
- spec/whm/transfer_tool_spec.rb
|
671
690
|
- spec/whm/whm_spec.rb
|
672
691
|
- spec/whostmgr/ssl_spec.rb
|
673
692
|
has_rdoc:
|