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 48
48:         def Host.build_xml(pe_id=nil)
49:             if pe_id
50:                 host_xml = "<HOST><ID>#{pe_id}</ID></HOST>"
51:             else
52:                 host_xml = "<HOST></HOST>"
53:             end
54: 
55:             XMLElement.build_xml(host_xml, 'HOST')
56:         end
new (xml, client)

Class constructor

[show source]
    # File OpenNebula/Host.rb, line 61
61:         def initialize(xml, client)
62:             super(xml,client)
63: 
64:             @client = client
65:             @pe_id  = self['ID'].to_i if self['ID']
66:         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 86
86:         def allocate(hostname,im,vmm,tm)
87:             super(HOST_METHODS[:allocate],hostname,im,vmm,tm)
88:         end
cluster ()

Returns the cluster of the Host

[show source]
     # File OpenNebula/Host.rb, line 125
125:         def cluster
126:             self['CLUSTER']
127:         end
delete ()

Deletes the Host

[show source]
    # File OpenNebula/Host.rb, line 91
91:         def delete()
92:             super(HOST_METHODS[:delete])
93:         end
disable ()

Disables the Host

[show source]
     # File OpenNebula/Host.rb, line 101
101:         def disable()
102:             set_enabled(false)
103:         end
enable ()

Enables the Host

[show source]
    # File OpenNebula/Host.rb, line 96
96:         def enable()
97:             set_enabled(true)
98:         end
info ()

Retrieves the information of the given Host.

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

Returns the state of the Host (string value)

[show source]
     # File OpenNebula/Host.rb, line 120
120:         def short_state_str
121:             SHORT_HOST_STATES[state_str]
122:         end
state ()

Returns the state of the Host (numeric value)

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

Returns the state of the Host (string value)

[show source]
     # File OpenNebula/Host.rb, line 115
115:         def state_str
116:             HOST_STATES[state]
117:         end