Class: One2Influx::Host

Inherits:
OneObject show all
Defined in:
lib/one2influx/one_object/host.rb

Overview

Representation of ONE host

Instance Attribute Summary collapse

Attributes inherited from OneObject

#doc, #metrics, #tags

Instance Method Summary collapse

Methods inherited from OneObject

#method_missing, #serialize_as_points

Constructor Details

#initialize(xml, client) ⇒ Host

Returns a new instance of Host.

Parameters:

  • xml (string)

    representation of host

  • client (OpenNebula::Client)

    connection link to ONE API



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/one2influx/one_object/host.rb', line 9

def initialize(xml, client)
  # Load configuration
  @tag_names = $CFG.storage[:host][:tags]
  @metric_names = $CFG.storage[:host][:metrics]
  @custom_metric_names = $CFG.storage[:host][:cust_metrics]


  @doc = Nokogiri::XML(xml)
  @tags = Hash.new
  load_datastores
  if @tag_names.has_key? :DSS_IDS
    @tag_names.delete :DSS_IDS
    unless @datastores.empty?
      @tags[:DSS_IDS] = ',,' + @datastores.join(',,') + ',,'
    end
  end

  super(xml, client)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class One2Influx::OneObject

Instance Attribute Details

#datastoresObject (readonly)

Returns the value of attribute datastores.



4
5
6
# File 'lib/one2influx/one_object/host.rb', line 4

def datastores
  @datastores
end

Instance Method Details

#vmsarray

Returns IDs of VMs.

Returns:

  • (array)

    IDs of VMs



31
32
33
34
35
# File 'lib/one2influx/one_object/host.rb', line 31

def vms
  @doc.xpath('//VMS/ID').map do |node|
    node.content
  end
end