Class: Lumberg::Whm::TransferTool

Inherits:
Base
  • Object
show all
Defined in:
lib/lumberg/whm/transfer_tool.rb

Instance Attribute Summary

Attributes inherited from Base

#server

Instance Method Summary collapse

Methods inherited from Base

#initialize, #setup_server

Constructor Details

This class inherits a constructor from Lumberg::Whm::Base

Instance Method Details

#check(transfer_session_id) ⇒ Object

Public: Checks a given transfer session ID.

transfer_session_id - String ID of the transfer session.

Returns Hash API Response.


41
42
43
44
45
46
47
48
49
50
# File 'lib/lumberg/whm/transfer_tool.rb', line 41

def check(transfer_session_id)
  options = { transfer_session_id: transfer_session_id }

  server.force_response_type = :xfer

  server.perform_request(
    'retrieve_transfer_session_remote_analysis',
    options.merge("api.version" => "1")
  )
end

#create(options = {}) ⇒ Object

Public: Creates a new transfer session.

options - Hash options for API call params. (default: {})

:host              - String hostname of the remote server.
:user              - String username to connect on remote server.
:password          - String password for account specified above.

Returns Hash API Response.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lumberg/whm/transfer_tool.rb', line 13

def create(options = {})
  default_options = { remote_server_type: 'auto',
                      port: 22,
                      root_escalation_method: 'sudo',
                      transfer_threads: 2,
                      restore_threads: 2,
                      unrestricted_restore: 1,
                      compressed: 1,
                      unencrypted: 0,
                      use_backups: 1,
                      low_priority: 0,
                      enable_custom_pkgacct: 0 }

  options.merge!("api.version" => "1")

  server.force_response_type = :xfer

  server.perform_request(
    'create_remote_root_transfer_session',
    default_options.merge(options)
  )
end

#enqueue(options = {}) ⇒ Object

Public: Enqueues a transfer session.

options - Hash options for API call params. (default: {})

:transfer_session_id - String ID of the transfer session.
:queue               - String transfer queue name. Can be one of the
                       following: LegacyAccountBackup,
                       FeatureListRemoteRoot, PackageRemoteRoot,
                       AccountLocal, AccountRemoteRoot and
                       AccountRemoteUser.
                       (default: 'AccountRemoteRoot')
:size                - Integer account size in Bytes.
:other_arguments     - Doc here
https://documentation.cpanel.net/display/SDK/WHM+API+1+-+enqueue_transfer_item

Returns Hash API Reponse.


83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/lumberg/whm/transfer_tool.rb', line 83

def enqueue(options = {})
  default_options = { "api.version" => "1" }

  options["module"] = options.delete(:queue) || "AccountRemoteRoot"

  if %w(AccountRemoteRoot AccountRemoteUser AccountLocal).include?(options["module"])
    options[:localuser] = options.delete(:localuser) || options[:user]
  end

  server.force_response_type = :xfer

  server.perform_request('enqueue_transfer_item', default_options.merge(options))
end

#pause(transfer_session_id) ⇒ Object

Public: Pauses a given transfer session.

transfer_session_id - String ID of the transfer session.

Returns Hash API Response.


153
154
155
156
157
158
159
160
161
162
# File 'lib/lumberg/whm/transfer_tool.rb', line 153

def pause(transfer_session_id)
  options = { transfer_session_id: transfer_session_id }

  server.force_response_type = :xfer

  server.perform_request(
    'pause_transfer_session',
    options.merge("api.version" => "1")
  )
end

#show_log(transfer_session_id, log_type = :common) ⇒ Object

Public: Shows transfer log.

transfer_session_id - String ID of the transfer session. type - Symbol log type, can be either `:common` or

`:error`. (default: :common)

Returns Hash API Response.


136
137
138
139
140
141
142
143
144
145
146
# File 'lib/lumberg/whm/transfer_tool.rb', line 136

def show_log(transfer_session_id, log_type = :common)
  options = { logfile: log_type == :common ? 'master.log' : 'master.error_log',
              transfer_session_id: transfer_session_id }

  server.force_response_type = :xfer

  server.perform_request(
    'fetch_transfer_session_log',
    options.merge("api.version" => "1")
  )
end

#start(transfer_session_id) ⇒ Object

Public: Starts or restarts a transfer.

transfer_session_id - String ID of the transfer session.

Returns Hash API Response.


102
103
104
105
106
107
108
109
110
111
# File 'lib/lumberg/whm/transfer_tool.rb', line 102

def start(transfer_session_id)
  options = { transfer_session_id: transfer_session_id }

  server.force_response_type = :xfer

  server.perform_request(
    'start_transfer_session',
    options.merge("api.version" => "1")
  )
end

#status(transfer_session_id) ⇒ Object

Public: Gets migration status.

transfer_session_id - String ID of the transfer session.

Returns Hash API Response.


118
119
120
121
122
123
124
125
126
127
# File 'lib/lumberg/whm/transfer_tool.rb', line 118

def status(transfer_session_id)
  options = { transfer_session_id: transfer_session_id }

  server.force_response_type = :xfer

  server.perform_request(
    'get_transfer_session_state',
    options.merge("api.version" => "1")
  )
end

#validate_user(username) ⇒ Object

Public: Validates a system user, preventing account conflicts.

username - String username to validate.

Returns Hash API Response.


57
58
59
60
61
62
63
64
65
66
# File 'lib/lumberg/whm/transfer_tool.rb', line 57

def validate_user(username)
  options = { user: username }

  server.force_response_type = :xfer

  server.perform_request(
    'validate_system_user',
    options.merge("api.version" => "1")
  )
end