Class: SolusVM::Node

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

Overview

SolusVM::Node is the class for working with nodes.

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

#available_ips(nodeid) ⇒ Object

Public: Retrieves a list of available IPs for a specific node.

nodeid - The node ID

Returns an Array.


63
64
65
66
67
68
69
70
# File 'lib/solusvm/node.rb', line 63

def available_ips(nodeid)
  perform_request(action: 'node-iplist', nodeid: nodeid)
  if statusmsg.match /no available ip/i
    []
  else
    parse_returned_params_as_list('ips')
  end
end

#ids(type) ⇒ Object

Public: Lists existing nodes ids of a given type.

type - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]

Returns an Array.


31
32
33
34
35
36
# File 'lib/solusvm/node.rb', line 31

def ids(type)
  validate_server_type(type) do
    perform_request(action: 'node-idlist', type: type)
    parse_returned_params_as_list('nodes')
  end
end

#list(type) ⇒ Object

Public: Lists existing nodes of a given type.

type - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]

Returns an Array.


9
10
11
12
13
14
# File 'lib/solusvm/node.rb', line 9

def list(type)
  validate_server_type(type) do
    perform_request(action: 'listnodes', type: type)
    parse_returned_params_as_list('nodes')
  end
end

#list_groupsObject

Public: Lists existing node groups

Returns an Array.


19
20
21
22
23
24
# File 'lib/solusvm/node.rb', line 19

def list_groups
  perform_request(action: 'listnodegroups')

  # return list of node groups with numeric values excluded
  returned_parameters['nodegroups'].to_s.split(',').map {|group| group.split('|')[1]}
end

#statistics(nodeid) ⇒ Object

Public: Retrieves statistics from a specific node.

nodeid - The node ID

Returns a Hash.


43
44
45
46
# File 'lib/solusvm/node.rb', line 43

def statistics(nodeid)
  perform_request(action: 'node-statistics', nodeid: nodeid)
  returned_parameters
end

#virtualservers(nodeid) ⇒ Object

Public: Lists virtual servers from a specific node.

nodeid - The node ID

Returns an Array if virtual servers were found, otherwise nil.


77
78
79
80
# File 'lib/solusvm/node.rb', line 77

def virtualservers(nodeid)
  perform_request(action: "node-virtualservers", nodeid: nodeid)
  returned_parameters["virtualservers"]
end

#xenresources(nodeid) ⇒ Object

Retrieves available xen resources from a specific node.

nodeid - The node ID

Returns a Hash.


53
54
55
56
# File 'lib/solusvm/node.rb', line 53

def xenresources(nodeid)
  perform_request(action: 'node-xenresources', nodeid: nodeid)
  returned_parameters
end