Class: One2Influx::VirtualMachine

Inherits:
OneObject
  • Object
show all
Defined in:
lib/one2influx/one_object/virtual_machine.rb

Overview

Representation of ONE virtual machine

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, parent_host) ⇒ VirtualMachine

Returns a new instance of VirtualMachine.

Parameters:

  • xml (string)

    representation of VM

  • client (OpenNebula::Client)

    connection link to ONE API

  • parent_host (One2Influx::Host)

    owner of this VM



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

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

  # Assign tags inherited from parent host
  @tags = Hash.new
  $CFG.storage[:vm][:inh_tags].each do |name, value|
    @tags[name] = parent_host.tags[value.to_sym]
  end
  super(xml, client)
end

Dynamic Method Handling

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