Module: OpenNebula

Defined in:
lib/opennebula/document_pool_json.rb,
lib/opennebula.rb,
lib/opennebula/acl.rb,
lib/opennebula/host.rb,
lib/opennebula/pool.rb,
lib/opennebula/user.rb,
lib/opennebula/zone.rb,
lib/opennebula/error.rb,
lib/opennebula/group.rb,
lib/opennebula/image.rb,
lib/opennebula/client.rb,
lib/opennebula/system.rb,
lib/opennebula/cluster.rb,
lib/opennebula/acl_pool.rb,
lib/opennebula/document.rb,
lib/opennebula/ssh_auth.rb,
lib/opennebula/template.rb,
lib/opennebula/xml_pool.rb,
lib/opennebula/datastore.rb,
lib/opennebula/host_pool.rb,
lib/opennebula/ldap_auth.rb,
lib/opennebula/user_pool.rb,
lib/opennebula/x509_auth.rb,
lib/opennebula/xml_utils.rb,
lib/opennebula/zone_pool.rb,
lib/opennebula/group_pool.rb,
lib/opennebula/image_pool.rb,
lib/opennebula/xml_element.rb,
lib/opennebula/cluster_pool.rb,
lib/opennebula/pool_element.rb,
lib/opennebula/document_json.rb,
lib/opennebula/document_pool.rb,
lib/opennebula/template_pool.rb,
lib/opennebula/datastore_pool.rb,
lib/opennebula/virtual_machine.rb,
lib/opennebula/virtual_network.rb,
lib/opennebula/server_x509_auth.rb,
lib/opennebula/server_cipher_auth.rb,
lib/opennebula/virtual_machine_pool.rb,
lib/opennebula/virtual_network_pool.rb

Overview

————————————————————————– # Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs #

#

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

Modules: ParsePoolBase Classes: Acl, AclPool, Client, Cluster, ClusterPool, Datastore, DatastorePool, Document, DocumentJSON, DocumentPool, DocumentPoolJSON, Error, Group, GroupPool, Host, HostPool, Image, ImagePool, LdapAuth, NokogiriStreamParser, OxStreamParser, ParsePoolSax, ParsePoolSaxBase, Pool, PoolElement, ServerCipherAuth, ServerX509Auth, SshAuth, System, Template, TemplatePool, User, UserPool, VirtualMachine, VirtualMachinePool, VirtualNetwork, VirtualNetworkPool, X509Auth, XMLElement, XMLPool, Zone, ZonePool

Constant Summary collapse

VERSION =

OpenNebula version

'4.10.2'
DEFAULT_POOL_PAGE_SIZE =
2000
@@pool_page_size =
DEFAULT_POOL_PAGE_SIZE

Class Method Summary collapse

Class Method Details

.is_error?(value) ⇒ Boolean

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

Returns:

  • (Boolean)


49
50
51
# File 'lib/opennebula/error.rb', line 49

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

.pool_page_sizeObject



24
25
26
# File 'lib/opennebula/client.rb', line 24

def self.pool_page_size
    @@pool_page_size
end

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

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

  • oid (Integer)

    Id of the object to process

  • xpath_expressions (Array<String>)

    Elements to retrieve.

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].



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/opennebula/pool_element.rb', line 250

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