Class: SolusVM::Server

Inherits:
Base
  • Object
show all
Defined in:
lib/solusvm/server.rb

Overview

SolusVM::Server is the class for working with virtual servers.

Constant Summary

Constant Summary

Constants inherited from Base

Base::VALID_SERVER_TYPES

Instance Attribute Summary

Attributes inherited from Base

#returned_parameters

Instance Method Summary (collapse)

Methods inherited from Base

#api_endpoint, #api_id, #api_key, #api_login, #api_options, #conn, #initialize, #log_messages, #parse_error, #parse_response, #parse_returned_params_as_list, #perform_request, #ssl_option, #statusmsg, #successful?, #validate_server_type

Constructor Details

This class inherits a constructor from SolusVM::Base

Instance Method Details

- (Object) add_ip(vid)

Adds an IP address for a specific server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • the IP as a String.



175
176
177
178
# File 'lib/solusvm/server.rb', line 175

def add_ip(vid)
  perform_request(action: 'vserver-addip', vserverid: vid)
  returned_parameters['ipaddress']
end

- (Object) boot(vid)

Boots a server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the server was successfully booted.



47
48
49
# File 'lib/solusvm/server.rb', line 47

def boot(vid)
  perform_request(action: 'vserver-boot', vserverid: vid)
end

- (Object) change_bootorder(vid, bootorder)

Changes server boot order

Parameters:

  • vid

    The virtual server ID in SolusVM

  • bootorder

    The boot order, one of the following:

Options Hash (bootorder):

  • :cd (Object)

    Hard Disk CDROM

  • :dc (Object)

    CDROM Hard Disk

  • :c (Object)

    Hard Disk

  • :d (Object)

    CDROM

Returns:

  • true if the boot order was successfully changed.



250
251
252
# File 'lib/solusvm/server.rb', line 250

def change_bootorder(vid, bootorder)
  perform_request(action: 'vserver-bootorder', vserverid: vid, bootorder: bootorder.to_s)
end

- (Object) change_consolepass(vid, new_password)

Changes server console password.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • new_password

    The new console password

Returns:

  • true if the server's console password was successfully changed.



216
217
218
# File 'lib/solusvm/server.rb', line 216

def change_consolepass(vid, new_password)
  perform_request(action: 'vserver-consolepass', vserverid: vid, consolepassword: new_password)
end

- (Object) change_hostname(vid, hostname)

Changes server hostname.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • hostname

    The new hostname

Returns:

  • true if the server's hostname was successfully changed.



260
261
262
# File 'lib/solusvm/server.rb', line 260

def change_hostname(vid, hostname)
  perform_request(action: 'vserver-hostname', vserverid: vid, hostname: hostname)
end

- (Object) change_owner(vid, client_id)

Changes server owner.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • client_id

    The new client ID

Returns:

  • true if the server's owner was successfully changed.



206
207
208
# File 'lib/solusvm/server.rb', line 206

def change_owner(vid, client_id)
  perform_request(action: 'vserver-changeowner', vserverid: vid, clientid: client_id)
end

- (Object) change_plan(vid, plan)

Changes server plan.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • plan

    The new plan ID

Returns:

  • true if the server's plan was successfully changed.



196
197
198
# File 'lib/solusvm/server.rb', line 196

def change_plan(vid, plan)
  perform_request(action: 'vserver-change', vserverid: vid, plan: plan)
end

- (Object) change_rootpassword(vid, new_password)

Changes server root password.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • new_password

    The new root password

Returns:

  • true if the server's root password was successfully changed.



236
237
238
# File 'lib/solusvm/server.rb', line 236

def change_rootpassword(vid, new_password)
  perform_request(action: 'vserver-rootpassword', vserverid: vid, rootpassword: new_password)
end

- (Object) change_vncpass(vid, new_password)

Changes server VNC password.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • new_password

    The new VNC password

Returns:

  • true if the server's VNC password was successfully changed.



226
227
228
# File 'lib/solusvm/server.rb', line 226

def change_vncpass(vid, new_password)
  perform_request(action: 'vserver-vncpass', vserverid: vid, vncpassword: new_password)
end

- (Object) console(vid, params = {})

Retrieves server console information.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • params (defaults to: {})

    A Hash to pass optional parameters to vserver-console call:

  • returns

    a Hash

Options Hash (params):

  • :access (Object)

    A String that can be 'enable' or 'disable'

  • :time (Object)

    An Integer that can be 1|2|3|4|5|6|7|8



292
293
294
295
# File 'lib/solusvm/server.rb', line 292

def console(vid, params = {})
  perform_request(action: 'vserver-console', vserverid: vid, access: params[:access], time: params[:time])
  returned_parameters
end

- (Object) create(hostname, password, options = {})

Creates a new virtual server.

Parameters:

  • hostname

    The server hostname

  • password

    The server password

  • options (defaults to: {})

    A Hash of options

Options Hash (options):

  • :type (Object)

    openvz|xen|xen hvm|kvm

  • :node (Object)

    name of node

  • :nodegroup (Object)

    name of nodegroup

  • :username (Object)

    client username

  • :plan (Object)

    plan name

  • :template (Object)

    template or iso name

  • :ips (Object)

    amount of ips

  • :hvmt (Object)

    0|1 Default is 0. This allows to define templates & isos for Xen HVM

  • :custommemory (Object)

    overide plan memory with this amount

  • :customdiskspace (Object)

    overide plan diskspace with this amount

  • :custombandwidth (Object)

    overide plan bandwidth with this amount

  • :customcpu (Object)

    overide plan cpu cores with this amount

  • :customextraip (Object)

    add this amount of extra ips

  • :issuelicense (Object)

    1|2 1 = cPanel monthly, 2 = cPanel yearly

Returns:

  • a Hash with the new server info, or false if the server was not created successfully.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/solusvm/server.rb', line 28

def create(hostname, password, options = {})
  options.reverse_merge!(
    type:         'xen',
    username:     nil,
    ips:          1,
    node:         nil,
    plan:         nil,
    template:     nil,
    password:     password,
    hostname:     hostname
  ).merge!(action: 'vserver-create')
  perform_request(options) && returned_parameters
end

- (Object) del_ip(vid, ip_address)

Deletes an IP address for a specific server.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • ip_address

    The IP address to remove

Returns:

  • true if the IP was successfully deleted.



186
187
188
# File 'lib/solusvm/server.rb', line 186

def del_ip(vid, ip_address)
  perform_request(action: 'vserver-delip', vserverid: vid, ipaddr: ip_address)
end

- (Boolean) exists?(vid)

Checks if a specific server exists.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • (Boolean)

    true if the server exists.



155
156
157
158
# File 'lib/solusvm/server.rb', line 155

def exists?(vid)
  perform_request(action: 'vserver-checkexists', vserverid: vid)
  !!statusmsg.match(/Virtual server exists/i)
end

- (Object) info(vid, reboot = false)

Retrieves server information.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • a Hash.



269
270
271
272
# File 'lib/solusvm/server.rb', line 269

def info(vid, reboot = false)
  perform_request(action: 'vserver-info', vserverid: vid, reboot: reboot)
  returned_parameters
end

- (Object) info_all(vid)

Retrieves all available server information.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • a Hash.



302
303
304
305
# File 'lib/solusvm/server.rb', line 302

def info_all(vid)
  perform_request(action: 'vserver-infoall', vserverid: vid)
  returned_parameters
end

- (Object) mountiso(vid, iso)

Mounts a given ISO image.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • iso

    The ISO image to mount

Returns:

  • true if the ISO was mounted successfully.



323
324
325
# File 'lib/solusvm/server.rb', line 323

def mountiso(vid, iso)
  perform_request(action: 'vserver-mountiso', vserverid: vid, iso: iso)
end

- (Object) network_disable(vid)

Disables Network Mode.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if Network Mode was successfully disabled.



119
120
121
# File 'lib/solusvm/server.rb', line 119

def network_disable(vid)
  perform_request(action: 'vserver-network-disable', vserverid: vid)
end

- (Object) network_enable(vid)

Enable Network Mode.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if Network Mode was successfully enabled.



110
111
112
# File 'lib/solusvm/server.rb', line 110

def network_enable(vid)
  perform_request(action: 'vserver-network-enable', vserverid: vid)
end

- (Object) pae_disable(vid)

Disables PAE.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if PAE was successfully disabled.



137
138
139
# File 'lib/solusvm/server.rb', line 137

def pae_disable(vid)
  perform_request(action: 'vserver-pae', vserverid: vid, pae: "off")
end

- (Object) pae_enable(vid)

Enable PAE.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if PAE was successfully enabled.



128
129
130
# File 'lib/solusvm/server.rb', line 128

def pae_enable(vid)
  perform_request(action: 'vserver-pae', vserverid: vid, pae: "on")
end

- (Object) reboot(vid)

Reboots a server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the server was successfully rebooted.



56
57
58
# File 'lib/solusvm/server.rb', line 56

def reboot(vid)
  perform_request(action: 'vserver-reboot', vserverid: vid)
end

- (Object) rebuild(vid, template)

Rebuilds a server using a given template.

Parameters:

  • vid

    The virtual server ID in SolusVM

  • template

    The template to use

Returns:

  • true if the server was successfully rebuilt.



313
314
315
# File 'lib/solusvm/server.rb', line 313

def rebuild(vid, template)
  perform_request(action: 'vserver-rebuild', vserverid: vid, template: template)
end

- (Object) resume(vid)

Resumes a server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the server was successfully resumed.



74
75
76
# File 'lib/solusvm/server.rb', line 74

def resume(vid)
  perform_request(action: 'vserver-unsuspend', vserverid: vid)
end

- (Object) shutdown(vid)

Shuts down a server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the server was successfully shutdown.



83
84
85
# File 'lib/solusvm/server.rb', line 83

def shutdown(vid)
  perform_request(action: 'vserver-shutdown', vserverid: vid)
end

- (Object) status(vid)

Checks the status of specific server (disabled|online|offline).

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • the server's status.



165
166
167
168
# File 'lib/solusvm/server.rb', line 165

def status(vid)
  perform_request(action: 'vserver-status', vserverid: vid)
  statusmsg
end

- (Object) suspend(vid)

Suspends a server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the server was successfully suspended.



65
66
67
# File 'lib/solusvm/server.rb', line 65

def suspend(vid)
  perform_request(action: 'vserver-suspend', vserverid: vid)
end

- (Object) terminate(vid, deleteclient = false)

Terminates a server.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the server was successfully terminated.



146
147
148
# File 'lib/solusvm/server.rb', line 146

def terminate(vid, deleteclient = false)
  perform_request(action: 'vserver-terminate', vserverid: vid, deleteclient: deleteclient)
end

- (Object) tun_disable(vid)

Disable TUN/TAP.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if TUN/TAP was successfully disabled.



101
102
103
# File 'lib/solusvm/server.rb', line 101

def tun_disable(vid)
  perform_request(action: 'vserver-tun-disable', vserverid: vid)
end

- (Object) tun_enable(vid)

Enable TUN/TAP.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if TUN/TAP was successfully enabled.



92
93
94
# File 'lib/solusvm/server.rb', line 92

def tun_enable(vid)
  perform_request(action: 'vserver-tun-enable', vserverid: vid)
end

- (Object) unmountiso(vid)

Unmounts a given ISO image.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • true if the ISO was unmounted successfully.



332
333
334
# File 'lib/solusvm/server.rb', line 332

def unmountiso(vid)
  perform_request(action: 'vserver-unmountiso', vserverid: vid)
end

- (Object) vnc(vid)

Retrieves server vnc information.

Parameters:

  • vid

    The virtual server ID in SolusVM

Returns:

  • a Hash.



279
280
281
282
# File 'lib/solusvm/server.rb', line 279

def vnc(vid)
  perform_request(action: 'vserver-vnc', vserverid: vid)
  returned_parameters
end