Class: Rubineti::Instance

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

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Instance

Returns a new instance of Instance.



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

def initialize connection
  @connection = connection
end

Instance Method Details

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

Activate disks on an instance. Returns a job id.

Takes the bool parameter ignore_size. (useful for forcing activation when recorded size is wrong).



14
15
16
17
# File 'lib/rubineti/instance.rb', line 14

def activate_disks name, params = {}
  warn "WARNING: Instance#activate_disks not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/activate-disks", params
end

#all(params = {}) ⇒ Object

Returns a list of all available instances.

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



199
200
201
# File 'lib/rubineti/instance.rb', line 199

def all params = {}
  @connection.get "/#{Ganeti::Version}/instances", params
end

#create(params = {}) ⇒ Object

Creates an instance. Returns a job id.

Body parameters:

- http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances

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.



30
31
32
# File 'lib/rubineti/instance.rb', line 30

def create params = {}
  @connection.post "/#{Ganeti::Version}/instances", params
end

#deactivate_disks(name) ⇒ Object

Deactivate disks on an instance. Returns a job id.



38
39
40
41
# File 'lib/rubineti/instance.rb', line 38

def deactivate_disks name
  warn "WARNING: Instance#deactivate_disks not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/deactivate-disks"
end

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

Deletes an instance. 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.



51
52
53
# File 'lib/rubineti/instance.rb', line 51

def delete name, params = {}
  @connection.delete "/#{Ganeti::Version}/instances/#{name}", params
end

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

Exports an instance. Returns a job id.

Body parameters:

- http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-export


62
63
64
65
# File 'lib/rubineti/instance.rb', line 62

def export name, params = {}
  warn "WARNING: Instance#export not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/export", params
end

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

Requests detailed information about the instance.

An optional parameter, static (bool), can be set to return only static information from the configuration without querying the instance’s nodes. The result will be a job id.



74
75
76
# File 'lib/rubineti/instance.rb', line 74

def info name, params = {}
  @connection.get "/#{Ganeti::Version}/instances/#{name}/info", params
end

#list(name) ⇒ Object

Returns information about an instance, similar to the bulk output from #instances_list.



82
83
84
# File 'lib/rubineti/instance.rb', line 82

def list name
  @connection.get "/#{Ganeti::Version}/instances/#{name}"
end

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

Migrates an instance. Returns a job id.

Body parameters:

- http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-migrate


93
94
95
96
# File 'lib/rubineti/instance.rb', line 93

def migrate name, params = {}
  warn "WARNING: Instance#migrate not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/migrate", params
end

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

Modifies an instance. Returns a job id.

Body parameters:

- http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-modify


105
106
107
108
# File 'lib/rubineti/instance.rb', line 105

def modify name, params = {}
  warn "WARNING: Instance#modify not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/modify", params
end

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

Prepares an export of an instance. Returns a job id.

Takes one parameter, mode, for the export mode.



116
117
118
119
# File 'lib/rubineti/instance.rb', line 116

def prepare_export name, params = {}
  warn "WARNING: Instance#prepare_export not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/prepare-disks", params
end

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

Reboots the instance. Returns a job id.

The URI takes optional type=soft|hard|full and ignore_secondaries=0|1 parameters.

- soft is just a normal reboot, without terminating the hypervisor.
- hard means full shutdown (including terminating the hypervisor process)
  and startup again.
- full is like hard but also recreates the configuration from ground up
  as if you would have done a gnt-instance shutdown and gnt-instance start on it.
- ignore_secondaries parameter (?ignore_secondaries=1), will start the
  instance even if secondary disks are failing.

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.



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

def reboot name, params = {}
  @connection.post "/#{Ganeti::Version}/instances/#{name}/reboot", params
end

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

Reinstalls the instance’s operating system. Returns a job id.

Takes the parameters os (OS template name) and nostartup (bool).



148
149
150
# File 'lib/rubineti/instance.rb', line 148

def reinstall name, params = {}
  @connection.post "/#{Ganeti::Version}/instances/#{name}/reinstall", params
end

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

Renames an instance. Returns a job id.

Body parameters:

- http://docs.ganeti.org/ganeti/#{Ganeti::Version}.2/html/rapi.html#instances-instance-name-rename


159
160
161
162
# File 'lib/rubineti/instance.rb', line 159

def rename name, params = {}
  warn "WARNING: Instance#rename not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/rename", params
end

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

Replaces disks on an instance. Returns a job id.

Takes the mandatory parameters mode:

- (one of replace_on_primary, replace_on_secondary, replace_new_secondary or replace_auto),
- disks (comma separated list of disk indexes)
- remote_node and iallocator

Either remote_node or iallocator needs to be defined when using mode=replace_new_secondary. replace_auto tries to determine the broken disk(s) on its own and replacing it.



176
177
178
179
# File 'lib/rubineti/instance.rb', line 176

def replace_disks name, params = {}
  warn "WARNING: Instance#replace_disks not implemented."
  # post "/#{Ganeti::Version}/instances/#{name}/replace-disks", params
end

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

Shutdown an instance. 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.



189
190
191
# File 'lib/rubineti/instance.rb', line 189

def shutdown name, params = {}
  @connection.put "/#{Ganeti::Version}/instances/#{name}/shutdown", params
end

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

Startup an instance. 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.



211
212
213
# File 'lib/rubineti/instance.rb', line 211

def startup name, params = {}
  @connection.put "/#{Ganeti::Version}/instances/#{name}/startup", params
end

#tag_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.



223
224
225
226
# File 'lib/rubineti/instance.rb', line 223

def tag_create name, params = {}
  warn "WARNING: Instance#tag_create not implemented."
  # put "/#{Ganeti::Version}/instances/#{name}/tags", params
end

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

Delete a tag. 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.



236
237
238
239
# File 'lib/rubineti/instance.rb', line 236

def tag_delete name, params = {}
  warn "WARNING: Instance#tag_delete not implemented."
  # delete "/#{Ganeti::Version}/instances/#{name}/tags", params
end

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

Return a list of tags.



244
245
246
247
# File 'lib/rubineti/instance.rb', line 244

def tag_list name, params = {}
  warn "WARNING: Instance#tag_list not implemented."
  # get "/#{Ganeti::Version}/instances/#{name}/tags", params
end