Class: One2Influx::Datastore

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

Overview

Representation of ONE datastore

Instance Attribute Summary

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) ⇒ Datastore

Returns a new instance of Datastore.

Parameters:

  • xml (string)

    representation of datastore

  • client (OpenNebula::Client)

    connection link to ONE API



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/one2influx/one_object/datastore.rb', line 7

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

  # Parsing HOST_ID_X as normal tag_name would cause error
  if @tag_names.has_key? :HOSTS_IDS
    @tag_names.delete :HOSTS_IDS
  end

  super(xml, client)
end

Dynamic Method Handling

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

Instance Method Details

#add_hosts_ids(hosts) ⇒ Object

Add tag HOSTS_IDS a string containing IDs of all hosts associated with this datastore in form for each host associated with this datastore in form ,,ID_1,,ID_2…,,

Parameters:

  • hosts (array)

    array of hosts IDs that are using this datastore



25
26
27
28
29
# File 'lib/one2influx/one_object/datastore.rb', line 25

def add_hosts_ids(hosts)
  unless hosts.empty?
    @tags[:HOSTS_IDS] = ',,' + hosts.join(',,') + ',,'
  end
end