Class: Rubineti::Node

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

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Node

Returns a new instance of Node.



3
4
5
# File 'lib/rubineti/node.rb', line 3

def initialize connection
  @connection = connection
end

Instance Method Details

#all(params = {}) ⇒ Object

Returns a list of all nodes.

If the optional bulk parameter (?bulk=1) is provided, the output contains detailed information about instances as a list.



70
71
72
# File 'lib/rubineti/node.rb', line 70

def all params = {}
  @connection.get "/2/nodes", params
end

#evacuate(name, params = {}) ⇒ Object

Evacuates all secondary instances off a node.

To evacuate a node, either one of the iallocator or remote_node parameters must be passed:

- evacuate?iallocator=[iallocator]
- evacuate?remote_node=[nodeX.example.com]

See: docs.ganeti.org/ganeti/2.2/html/rapi.html#nodes-node-name-evacuate

If the optional dry-run parameter (?dry-run=1) is provided, the job will not be actually executed, only the pre-execution checks will be done.



19
20
21
22
# File 'lib/rubineti/node.rb', line 19

def evacuate name, params = {}
  warn "WARNING: Node#evacuate not implemented."
  # post "/2/nodes/#{name}/evacuate", params
end

#list(name) ⇒ Object

Returns information about a node.



27
28
29
# File 'lib/rubineti/node.rb', line 27

def list name
  @connection.get "/2/nodes/#{name}"
end

#migrate(name, params = {}) ⇒ Object

Migrates all primary instances from a node.

If no mode is explicitly specified, each instances’ hypervisor default migration mode will be used. Query parameters:

- live (bool): If set, use live migration if available.
- mode (string): Sets migration mode, live for live migration
  and non-live for non-live migration. Supported by Ganeti 2.2 and above.


40
41
42
43
# File 'lib/rubineti/node.rb', line 40

def migrate name, params = {}
  warn "WARNING: Node#migrate not implemented."
  # post "/2/nodes/#{name}/migrate", params
end

#role_create(name) ⇒ Object

Change the node role. Returns a job id.

It supports the bool force argument.



51
52
53
54
55
# File 'lib/rubineti/node.rb', line 51

def role_create name
  warn "WARNING: Node#role_create not implemented."
  # TODO: API Docs do not describe it's usage well.
  # put "/2/nodes/#{name}/role"
end

#role_list(name) ⇒ Object

Returns the current node role.



60
61
62
# File 'lib/rubineti/node.rb', line 60

def role_list name
  @connection.get "/2/nodes/#{name}/role"
end

#storage_list(name, params = {}) ⇒ Object

Requests a list of storage units on a node. Returns a job id.

Requires the parameters storage_type (one of file, lvm-pv or lvm-vg) and output_fields.



80
81
82
83
# File 'lib/rubineti/node.rb', line 80

def storage_list name, params = {}
  warn "WARNING: Node#storage_list not implemented."
  # get "/2/nodes/#{name}/storage", params
end

#storage_modify(name, params = {}) ⇒ Object

Modifies storage units on the node. Returns a job id.

Requires the parameters storage_type (one of file, lvm-pv or lvm-vg) and name (name of the storage unit). Parameters can be passed additionally. Currently only allocatable (bool) is supported.



92
93
94
95
# File 'lib/rubineti/node.rb', line 92

def storage_modify name, params = {}
  warn "WARNING: Node#storage_modify not implemented."
  # put "/2/nodes/#{name}/storage/modify", params
end

#storage_repair(name, params = {}) ⇒ Object

Repairs a storage unit on the node. Returns a job id.

Requires the parameters storage_type (currently only lvm-vg can be repaired) and name (name of the storage unit).



104
105
106
107
# File 'lib/rubineti/node.rb', line 104

def storage_repair name, params = {}
  warn "WARNING: Node#storage_repair not implemented."
  # put "/2/nodes/#{name}/repair", params
end

#tags_create(name, params = {}) ⇒ Object

Add a set of tags. Returns a job id.

If the optional dry-run parameter (?dry-run=1) is provided, the job will not be actually executed, only the pre-execution checks will be done.



117
118
119
120
# File 'lib/rubineti/node.rb', line 117

def tags_create name, params = {}
  warn "WARNING: Node#tags_create not implemented."
  # put "/2/nodes/#{name}/tags", params
end

#tags_delete(name, params = {}) ⇒ Object

Deletes tags. Returns a job id.

If the optional dry-run parameter (?dry-run=1) is provided, the job will not be actually executed, only the pre-execution checks will be done.



130
131
132
133
# File 'lib/rubineti/node.rb', line 130

def tags_delete name, params = {}
  warn "WARNING: Node#tags_delete not implemented."
  # delete "/2/nodes/#{name}/tags", params
end

#tags_list(name) ⇒ Object

Return a list of tags.



138
139
140
141
# File 'lib/rubineti/node.rb', line 138

def tags_list name
  warn "WARNING: Node#tags_list not implemented."
  # get "/2/nodes/#{name}/tags"
end