Class: OpenNebula::Host
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Host
- Defined in:
- lib/OpenNebula/Host.rb
Constant Summary collapse
- HOST_METHODS =
{ :info => "host.info", :allocate => "host.allocate", :delete => "host.delete", :enable => "host.enable", :update => "host.update" }
- HOST_STATES =
%w{INIT MONITORING MONITORED ERROR DISABLED}
- SHORT_HOST_STATES =
{ "INIT" => "on", "MONITORING" => "on", "MONITORED" => "on", "ERROR" => "err", "DISABLED" => "off" }
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a Host description with just its identifier this method should be used to create plain Host objects.
Instance Method Summary collapse
-
#allocate(hostname, im, vmm, vnm, cluster_id = ClusterPool::NONE_CLUSTER_ID) ⇒ Integer, OpenNebula::Error
Allocates a new Host in OpenNebula.
-
#delete ⇒ Object
Deletes the Host.
-
#disable ⇒ Object
Disables the Host.
-
#enable ⇒ Object
Enables the Host.
-
#info ⇒ Object
Retrieves the information of the given Host.
-
#initialize(xml, client) ⇒ Host
constructor
Class constructor.
-
#short_state_str ⇒ Object
Returns the state of the Host (string value).
-
#state ⇒ Object
Returns the state of the Host (numeric value).
-
#state_str ⇒ Object
Returns the state of the Host (string value).
-
#update(new_template) ⇒ Object
Replaces the template contents.
Methods inherited from PoolElement
#id, #name, new_with_id, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml
Constructor Details
#initialize(xml, client) ⇒ Host
Class constructor
63 64 65 66 67 68 |
# File 'lib/OpenNebula/Host.rb', line 63 def initialize(xml, client) super(xml,client) @client = client @pe_id = self['ID'].to_i if self['ID'] end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/OpenNebula/Host.rb', line 52 def Host.build_xml(pe_id=nil) if pe_id host_xml = "<HOST><ID>#{pe_id}</ID></HOST>" else host_xml = "<HOST></HOST>" end XMLElement.build_xml(host_xml, 'HOST') end |
Instance Method Details
#allocate(hostname, im, vmm, vnm, cluster_id = ClusterPool::NONE_CLUSTER_ID) ⇒ Integer, OpenNebula::Error
Allocates a new Host in OpenNebula
89 90 91 |
# File 'lib/OpenNebula/Host.rb', line 89 def allocate(hostname,im,vmm,vnm,cluster_id=ClusterPool::NONE_CLUSTER_ID) super(HOST_METHODS[:allocate],hostname,im,vmm,vnm,cluster_id) end |
#delete ⇒ Object
Deletes the Host
94 95 96 |
# File 'lib/OpenNebula/Host.rb', line 94 def delete() super(HOST_METHODS[:delete]) end |
#disable ⇒ Object
Disables the Host
104 105 106 |
# File 'lib/OpenNebula/Host.rb', line 104 def disable() set_enabled(false) end |
#enable ⇒ Object
Enables the Host
99 100 101 |
# File 'lib/OpenNebula/Host.rb', line 99 def enable() set_enabled(true) end |
#info ⇒ Object
Retrieves the information of the given Host.
75 76 77 |
# File 'lib/OpenNebula/Host.rb', line 75 def info() super(HOST_METHODS[:info], 'HOST') end |
#short_state_str ⇒ Object
Returns the state of the Host (string value)
130 131 132 |
# File 'lib/OpenNebula/Host.rb', line 130 def short_state_str SHORT_HOST_STATES[state_str] end |
#state ⇒ Object
Returns the state of the Host (numeric value)
120 121 122 |
# File 'lib/OpenNebula/Host.rb', line 120 def state self['STATE'].to_i end |
#state_str ⇒ Object
Returns the state of the Host (string value)
125 126 127 |
# File 'lib/OpenNebula/Host.rb', line 125 def state_str HOST_STATES[state] end |
#update(new_template) ⇒ Object
Replaces the template contents
new_template
New template contents
111 112 113 |
# File 'lib/OpenNebula/Host.rb', line 111 def update(new_template) super(HOST_METHODS[:update], new_template) end |