
Methods
public class
public instance
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
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)
# 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
Class constructor
# 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
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
# File OpenNebula/Host.rb, line 70 70: def allocate(hostname,im,vmm,tm) 71: super(HOST_METHODS[:allocate],hostname,im,vmm,tm) 72: end
Returns the cluster of the Host
# File OpenNebula/Host.rb, line 109 109: def cluster 110: self['CLUSTER'] 111: end
Deletes the Host
# File OpenNebula/Host.rb, line 75 75: def delete() 76: super(HOST_METHODS[:delete]) 77: end
Disables the Host
# File OpenNebula/Host.rb, line 85 85: def disable() 86: set_enabled(false) 87: end
Enables the Host
# File OpenNebula/Host.rb, line 80 80: def enable() 81: set_enabled(true) 82: end
Retrieves the information of the given Host.
# File OpenNebula/Host.rb, line 57 57: def info() 58: super(HOST_METHODS[:info], 'HOST') 59: end
Returns the state of the Host (string value)
# File OpenNebula/Host.rb, line 104 104: def short_state_str 105: SHORT_HOST_STATES[state_str] 106: end
Returns the state of the Host (numeric value)
# File OpenNebula/Host.rb, line 94 94: def state 95: self['STATE'].to_i 96: end
Returns the state of the Host (string value)
# File OpenNebula/Host.rb, line 99 99: def state_str 100: HOST_STATES[state] 101: end