Module: OpenNebula

Defined in:
OpenNebula/DocumentPoolJSON.rb,
OpenNebula.rb,
OpenNebula/Acl.rb,
OpenNebula/User.rb,
OpenNebula/Pool.rb,
OpenNebula/Host.rb,
OpenNebula/Group.rb,
OpenNebula/Image.rb,
OpenNebula/AclPool.rb,
OpenNebula/Cluster.rb,
OpenNebula/Template.rb,
OpenNebula/XMLUtils.rb,
OpenNebula/Document.rb,
OpenNebula/UserPool.rb,
OpenNebula/HostPool.rb,
OpenNebula/ImagePool.rb,
OpenNebula/GroupPool.rb,
OpenNebula/Datastore.rb,
OpenNebula/ClusterPool.rb,
OpenNebula/TemplatePool.rb,
OpenNebula/DocumentPool.rb,
OpenNebula/DocumentJSON.rb,
OpenNebula/DatastorePool.rb,
OpenNebula/VirtualNetwork.rb,
OpenNebula/VirtualMachine.rb,
OpenNebula/VirtualNetworkPool.rb,
OpenNebula/VirtualMachinePool.rb

Overview

-------------------------------------------------------------------------- # Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #

#

Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at #

#

www.apache.org/licenses/LICENSE-2.0 #

#

Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # --------------------------------------------------------------------------- #

Defined Under Namespace

Classes: Acl, AclPool, Client, Cluster, ClusterPool, Datastore, DatastorePool, Document, DocumentJSON, DocumentPool, DocumentPoolJSON, Error, Group, GroupPool, Host, HostPool, Image, ImagePool, NokogiriStreamParser, Pool, PoolElement, Template, TemplatePool, User, UserPool, VirtualMachine, VirtualMachinePool, VirtualNetwork, VirtualNetworkPool, XMLElement, XMLPool

Constant Summary

VERSION =

OpenNebula version

'3.8.0'

Class Method Summary (collapse)

Class Method Details

+ (Boolean) is_error?(value)

Returns true if the object returned by a method of the OpenNebula library is an Error

Returns:

  • (Boolean)


87
88
89
# File 'OpenNebula.rb', line 87

def self.is_error?(value)
    value.class==OpenNebula::Error
end

+ (Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with the requested xpath expressions, and an Array of [timestamp, value].) process_monitoring(xmldoc, root_elem, timestamp_elem, oid, xpath_expressions)

Processes the monitoring data in XML returned by OpenNebula

Parameters:

  • xmldoc (XMLElement)

    monitoring data returned by OpenNebula

  • root_elem (String)

    Root for each individual PoolElement

  • timestamp_elem (String)

    Name of the XML element with the last monitorization timestamp

  • Id (Integer)

    of the object to process

  • xpath_expressions (Array<String>)

    Elements to retrieve.

  • args

    arguemnts for the xml_method call

Returns:

  • (Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with the requested xpath expressions, and an Array of [timestamp, value].)

    Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with the requested xpath expressions, and an Array of [timestamp, value].



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'OpenNebula/Pool.rb', line 389

def self.process_monitoring(xmldoc, root_elem, timestamp_elem, oid, xpath_expressions)
    hash = {}
    timestamps = xmldoc.retrieve_elements(
        "#{root_elem}[ID=#{oid}]/#{timestamp_elem}")

    xpath_expressions.each { |xpath|
        xpath_values = xmldoc.retrieve_elements("#{root_elem}[ID=#{oid}]/#{xpath}")

        if ( xpath_values.nil? )
            hash[xpath] = []
        else
            hash[xpath] = timestamps.zip(xpath_values)
        end
    }

    return hash
end