Class: OpenNebula::HostPool

Inherits:
Pool show all
Defined in:
lib/opennebula/host_pool.rb

Constant Summary collapse

HOST_POOL_METHODS =
{
    :info       => "hostpool.info",
    :monitoring => "hostpool.monitoring"
}

Constants inherited from Pool

Pool::INFO_ALL, Pool::INFO_GROUP, Pool::INFO_MINE, Pool::INFO_PRIMARY_GROUP, Pool::PAGINATED_POOLS

Instance Attribute Summary

Attributes inherited from Pool

#element_name, #pool_name

Instance Method Summary collapse

Methods inherited from Pool

#each, #each_page, #each_page_delete, #each_with_xpath, #get_hash, #get_page, #info_paginated, #is_paginated?, #loop_page, #to_str

Methods inherited from XMLPool

#each_element

Methods inherited from XMLElement

#[], #add_element, #attr, build_xml, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?

Constructor Details

#initialize(client) ⇒ HostPool

client a Client object that represents a XML-RPC connection



38
39
40
# File 'lib/opennebula/host_pool.rb', line 38

def initialize(client)
    super('HOST_POOL','HOST',client)
end

Instance Method Details

#factory(element_xml) ⇒ Object

Factory Method for the Host Pool



43
44
45
# File 'lib/opennebula/host_pool.rb', line 43

def factory(element_xml)
    OpenNebula::Host.new(element_xml,@client)
end

#infoObject Also known as: info!

Retrieves all the Hosts in the pool.



52
53
54
# File 'lib/opennebula/host_pool.rb', line 52

def info()
    super(HOST_POOL_METHODS[:info])
end

#info_allObject Also known as: info_all!



56
57
58
# File 'lib/opennebula/host_pool.rb', line 56

def info_all()
    return super(HOST_POOL_METHODS[:info])
end

#info_groupObject Also known as: info_group!



64
65
66
# File 'lib/opennebula/host_pool.rb', line 64

def info_group()
    return super(HOST_POOL_METHODS[:info])
end

#info_mineObject Also known as: info_mine!



60
61
62
# File 'lib/opennebula/host_pool.rb', line 60

def info_mine()
    return super(HOST_POOL_METHODS[:info])
end

#monitoring(xpath_expressions) ⇒ Hash<String, <Hash<String, Array<Array<int>>>>>, OpenNebula::Error

Retrieves the monitoring data for all the Hosts in the pool

Examples:

host_pool.monitoring(
  ['HOST_SHARE/FREE_CPU',
  'HOST_SHARE/RUNNING_VMS',
  'TEMPLATE/CUSTOM_PROBE'] )

{"1"=>
  {"TEMPLATE/CUSTOM_PROBE"=>[],
   "HOST_SHARE/FREE_CPU"=>[["1337609673", "800"]],
   "HOST_SHARE/RUNNING_VMS"=>[["1337609673", "3"]]},
 "0"=>
  {"TEMPLATE/CUSTOM_PROBE"=>[],
   "HOST_SHARE/FREE_CPU"=>[["1337609673", "800"]],
   "HOST_SHARE/RUNNING_VMS"=>[["1337609673", "3"]]}}

Parameters:

  • xpath_expressions (Array<String>)

    Elements to retrieve.

Returns:

  • (Hash<String, <Hash<String, Array<Array<int>>>>>, OpenNebula::Error)

    The first level hash uses the Host ID as keys, and as value a Hash with the requested xpath expressions, and an Array of ‘timestamp, value’.



96
97
98
# File 'lib/opennebula/host_pool.rb', line 96

def monitoring(xpath_expressions)
    return super(HOST_POOL_METHODS[:monitoring], xpath_expressions)
end

#monitoring_xml(num = nil) ⇒ String

Retrieves the monitoring data for all the Hosts in the pool, in XML

Parameters:

  • num (Integer) (defaults to: nil)

    Optional Retrieve monitor records in the last num seconds. 0 just the last record, -1 or nil all records

Returns:

  • (String)

    VM monitoring data, in XML



106
107
108
109
110
# File 'lib/opennebula/host_pool.rb', line 106

def monitoring_xml(num = nil)
    return @client.call(HOST_POOL_METHODS[:monitoring]) if num.nil?

    @client.call(HOST_POOL_METHODS[:monitoring], num.to_i)
end