Class OpenNebula::Host

  1. OpenNebula/Host.rb
Pool VirtualNetworkPool ClusterPool ImagePool VirtualMachinePool HostPool UserPool XMLElement PoolElement XMLPool User VirtualNetwork Cluster Image VirtualMachine Host Enumerable Client ImageRepository Error OpenNebula dot/f_0.png

Constants

HOST_METHODS = { :info => "host.info", :allocate => "host.allocate", :delete => "host.delete", :enable => "host.enable" }   Constants and Class Methods
HOST_STATES = %w{INIT MONITORING MONITORED ERROR DISABLED}
SHORT_HOST_STATES = { "INIT" => "on", "MONITORING" => "on", "MONITORED" => "on", "ERROR" => "err", "DISABLED" => "off" }

Public class methods

build_xml (pe_id=nil)

Creates a Host description with just its identifier this method should be used to create plain Host objects. id the id of the host

Example:

host = Host.new(Host.build_xml(3),rpc_client)
[show source]
    # File OpenNebula/Host.rb, line 32
32:         def Host.build_xml(pe_id=nil)
33:             if pe_id
34:                 host_xml = "<HOST><ID>#{pe_id}</ID></HOST>"
35:             else
36:                 host_xml = "<HOST></HOST>"
37:             end
38: 
39:             XMLElement.build_xml(host_xml, 'HOST')
40:         end
new (xml, client)

Class constructor

[show source]
    # File OpenNebula/Host.rb, line 45
45:         def initialize(xml, client)
46:             super(xml,client)
47: 
48:             @client = client
49:             @pe_id  = self['ID'].to_i if self['ID']
50:         end

Public instance methods

allocate (hostname,im,vmm,tm)

Allocates a new Host in OpenNebula

hostname A string containing the name of the new Host.

im A string containing the name of the im_driver

vmm A string containing the name of the vmm_driver

tm A string containing the name of the tm_driver

[show source]
    # File OpenNebula/Host.rb, line 70
70:         def allocate(hostname,im,vmm,tm)
71:             super(HOST_METHODS[:allocate],hostname,im,vmm,tm)
72:         end
cluster ()

Returns the cluster of the Host

[show source]
     # File OpenNebula/Host.rb, line 109
109:         def cluster
110:             self['CLUSTER']
111:         end
delete ()

Deletes the Host

[show source]
    # File OpenNebula/Host.rb, line 75
75:         def delete()
76:             super(HOST_METHODS[:delete])
77:         end
disable ()

Disables the Host

[show source]
    # File OpenNebula/Host.rb, line 85
85:         def disable()
86:             set_enabled(false)
87:         end
enable ()

Enables the Host

[show source]
    # File OpenNebula/Host.rb, line 80
80:         def enable()
81:             set_enabled(true)
82:         end
info ()

Retrieves the information of the given Host.

[show source]
    # File OpenNebula/Host.rb, line 57
57:         def info()
58:             super(HOST_METHODS[:info], 'HOST')
59:         end
short_state_str ()

Returns the state of the Host (string value)

[show source]
     # File OpenNebula/Host.rb, line 104
104:         def short_state_str
105:             SHORT_HOST_STATES[state_str]
106:         end
state ()

Returns the state of the Host (numeric value)

[show source]
    # File OpenNebula/Host.rb, line 94
94:         def state
95:             self['STATE'].to_i
96:         end
state_str ()

Returns the state of the Host (string value)

[show source]
     # File OpenNebula/Host.rb, line 99
 99:         def state_str
100:             HOST_STATES[state]
101:         end