2012-04-04 08:03:17 -04:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Libvirt
|
|
|
|
class Real
|
|
|
|
def get_node_info
|
|
|
|
node_hash = Hash.new
|
|
|
|
node_info = client.node_get_info
|
|
|
|
[:model, :memory, :cpus, :mhz, :nodes, :sockets, :cores, :threads].each do |param|
|
|
|
|
node_hash[param] = node_info.send(param) rescue nil
|
|
|
|
end
|
|
|
|
[:type, :version, :node_free_memory, :max_vcpus].each do |param|
|
|
|
|
node_hash[param] = client.send(param) rescue nil
|
|
|
|
end
|
|
|
|
node_hash[:uri] = client.uri
|
2012-04-09 09:41:23 -04:00
|
|
|
xml = client.sys_info rescue nil
|
2012-04-04 08:03:17 -04:00
|
|
|
[:uuid, :manufacturer, :product, :serial].each do |attr|
|
2013-03-19 11:55:48 -04:00
|
|
|
node_hash[attr] = node_attr(attr, xml) rescue nil
|
2012-04-09 09:41:23 -04:00
|
|
|
end if xml
|
2012-04-04 08:03:17 -04:00
|
|
|
|
2012-04-08 09:16:28 -04:00
|
|
|
node_hash[:hostname] = client.hostname
|
2012-04-04 08:03:17 -04:00
|
|
|
[node_hash]
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def node_attr attr, xml
|
|
|
|
xml_element(xml, "sysinfo/system/entry[@name='#{attr}']").strip
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
def get_node_info
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|