class Solusvm::Server

Solusvm::Server is the class for working with servers.

Public Instance Methods

add_ip(vid) click to toggle source

Adds an IP address for a specific server.

# File lib/solusvm/server.rb, line 110
def add_ip(vid)
  perform_request(action: 'vserver-addip', vserverid: vid)
  returned_parameters['ipaddress']
end
boot(vid) click to toggle source

Boots a server.

# File lib/solusvm/server.rb, line 38
def boot(vid)
  perform_request(action: 'vserver-boot', vserverid: vid)
end
change_bootorder(vid, bootorder) click to toggle source

Changes server boot order [cd(Hard Disk CDROM)|dc(CDROM Hard Disk)|c(Hard Disk)|d(CDROM)].

# File lib/solusvm/server.rb, line 146
def change_bootorder(vid, bootorder)
  perform_request(action: 'vserver-bootorder', vserverid: vid, bootorder: bootorder.to_s)
end
change_consolepass(vid, new_password) click to toggle source

Changes server console password.

# File lib/solusvm/server.rb, line 131
def change_consolepass(vid, new_password)
  perform_request(action: 'vserver-consolepass', vserverid: vid, consolepassword: new_password)
end
change_hostname(vid, hostname) click to toggle source

Changes server hostname.

# File lib/solusvm/server.rb, line 151
def change_hostname(vid, hostname)
  perform_request(action: 'vserver-hostname', vserverid: vid, hostname: hostname)
end
change_owner(vid, client_id) click to toggle source

Changes server owner.

# File lib/solusvm/server.rb, line 126
def change_owner(vid, client_id)
  perform_request(action: 'vserver-changeowner', vserverid: vid, clientid: client_id)
end
change_plan(vid, plan) click to toggle source

Changes server plan.

# File lib/solusvm/server.rb, line 121
def change_plan(vid, plan)
  perform_request(action: 'vserver-change', vserverid: vid, plan: plan)
end
change_rootpassword(vid, new_password) click to toggle source

Changes server root password.

# File lib/solusvm/server.rb, line 141
def change_rootpassword(vid, new_password)
  perform_request(action: 'vserver-rootpassword', vserverid: vid, rootpassword: new_password)
end
change_vncpass(vid, new_password) click to toggle source

Changes server vnc password.

# File lib/solusvm/server.rb, line 136
def change_vncpass(vid, new_password)
  perform_request(action: 'vserver-vncpass', vserverid: vid, vncpassword: new_password)
end
console(vid, params = {}) click to toggle source

Retrieves server console information.

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

:access - A String that can be 'enable' or 'disable'
:time   - A Integer that can be 1|2|3|4|5|6|7|8

returns a Hash

# File lib/solusvm/server.rb, line 174
def console(vid, params = {})
  perform_request(action: 'vserver-console', vserverid: vid, access: params[:access], time: params[:time])
  returned_parameters
end
create(hostname, password, options = {}) click to toggle source

Creates a server.

Options:

  • :type - openvz|xen|xen hvm|kvm

  • :node - name of node

  • :nodegroup - name of nodegroup

  • :username - client username

  • :plan - plan name

  • :template - template or iso name

  • :ips - amount of ips

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

  • :custommemory - overide plan memory with this amount

  • :customdiskspace - overide plan diskspace with this amount

  • :custombandwidth - overide plan bandwidth with this amount

  • :customcpu - overide plan cpu cores with this amount

  • :customextraip - add this amount of extra ips

  • :issuelicense - 1|2 1 = cPanel monthly 2= cPanel yearly

# File lib/solusvm/server.rb, line 23
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
del_ip(vid, ip_address) click to toggle source

Deletes an IP address for a specific server.

# File lib/solusvm/server.rb, line 116
def del_ip(vid, ip_address)
  perform_request(action: 'vserver-delip', vserverid: vid, ipaddr: ip_address)
end
exists?(vid) click to toggle source

Checks if a specific server exists.

# File lib/solusvm/server.rb, line 98
def exists?(vid)
  perform_request(action: 'vserver-checkexists', vserverid: vid)
  !statusmsg.match(/Virtual server exists/i).nil?
end
info(vid, reboot = false) click to toggle source

Retrieves server information.

# File lib/solusvm/server.rb, line 156
def info(vid, reboot = false)
  perform_request(action: 'vserver-info', vserverid: vid, reboot: reboot)
  returned_parameters
end
info_all(vid) click to toggle source

Retrieves all available server information.

# File lib/solusvm/server.rb, line 180
def info_all(vid)
  perform_request(action: 'vserver-infoall', vserverid: vid)
  returned_parameters
end
mountiso(vid, iso) click to toggle source

Mounts a given iso.

# File lib/solusvm/server.rb, line 191
def mountiso(vid, iso)
  perform_request(action: 'vserver-mountiso', vserverid: vid, iso: iso)
end
network_disable(vid) click to toggle source

Disables Network Mode.

# File lib/solusvm/server.rb, line 78
def network_disable(vid)
  perform_request(action: 'vserver-network-disable', vserverid: vid)
end
network_enable(vid) click to toggle source

Enable Network Mode.

# File lib/solusvm/server.rb, line 73
def network_enable(vid)
  perform_request(action: 'vserver-network-enable', vserverid: vid)
end
pae_disable(vid) click to toggle source

Disables PAE.

# File lib/solusvm/server.rb, line 88
def pae_disable(vid)
  perform_request(action: 'vserver-pae', vserverid: vid, pae: "off")
end
pae_enable(vid) click to toggle source

Enable PAE.

# File lib/solusvm/server.rb, line 83
def pae_enable(vid)
  perform_request(action: 'vserver-pae', vserverid: vid, pae: "on")
end
reboot(vid) click to toggle source

Reboots a server.

# File lib/solusvm/server.rb, line 43
def reboot(vid)
  perform_request(action: 'vserver-reboot', vserverid: vid)
end
rebuild(vid, template) click to toggle source

Rebuilds a server using a given template.

# File lib/solusvm/server.rb, line 186
def rebuild(vid, template)
  perform_request(action: 'vserver-rebuild', vserverid: vid, template: template)
end
resume(vid) click to toggle source

Resumes a server.

# File lib/solusvm/server.rb, line 53
def resume(vid)
  perform_request(action: 'vserver-unsuspend', vserverid: vid)
end
shutdown(vid) click to toggle source

Shuts down a server.

# File lib/solusvm/server.rb, line 58
def shutdown(vid)
  perform_request(action: 'vserver-shutdown', vserverid: vid)
end
status(vid) click to toggle source

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

# File lib/solusvm/server.rb, line 104
def status(vid)
  perform_request(action: 'vserver-status', vserverid: vid)
  statusmsg
end
suspend(vid) click to toggle source

Suspends a server.

# File lib/solusvm/server.rb, line 48
def suspend(vid)
  perform_request(action: 'vserver-suspend', vserverid: vid)
end
terminate(vid, deleteclient = false) click to toggle source

Terminates a server.

# File lib/solusvm/server.rb, line 93
def terminate(vid, deleteclient = false)
  perform_request(action: 'vserver-terminate', vserverid: vid, deleteclient: deleteclient)
end
tun_disable(vid) click to toggle source

Disable TUN/TAP.

# File lib/solusvm/server.rb, line 68
def tun_disable(vid)
  perform_request(action: 'vserver-tun-disable', vserverid: vid)
end
tun_enable(vid) click to toggle source

Enable TUN/TAP.

# File lib/solusvm/server.rb, line 63
def tun_enable(vid)
  perform_request(action: 'vserver-tun-enable', vserverid: vid)
end
unmountiso(vid) click to toggle source

Unmounts a given iso.

# File lib/solusvm/server.rb, line 196
def unmountiso(vid)
  perform_request(action: 'vserver-unmountiso', vserverid: vid)
end
vnc(vid) click to toggle source

Retrieves server vnc information.

# File lib/solusvm/server.rb, line 162
def vnc(vid)
  perform_request(action: 'vserver-vnc', vserverid: vid)
  returned_parameters
end