Sha256: c50c1bf0c2214d0846b94cd95b37d5a5337414b4045c829811e7cd28d0645808

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module Fog
  module Libvirt
    class Compute
      module Shared
        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
          xml = client.sys_info rescue nil
          [:uuid, :manufacturer, :product, :serial].each do |attr|
            node_hash[attr] = node_attr(attr, xml) rescue nil
          end if xml

          node_hash[:hostname] = client.hostname
          [node_hash]
        end

        private

        def node_attr attr, xml
          xml_element(xml, "sysinfo/system/entry[@name='#{attr}']").strip
        end
      end

      class Real
        include Shared
      end

      class Mock
        include Shared
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-libvirt-0.13.2 lib/fog/libvirt/requests/compute/get_node_info.rb
fog-libvirt-0.13.1 lib/fog/libvirt/requests/compute/get_node_info.rb
fog-libvirt-0.13.0 lib/fog/libvirt/requests/compute/get_node_info.rb