module OpenNebula
————————————————————————– # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
#
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. #
————————————————————————– # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
#
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. #
————————————————————————– # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
#
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. #
————————————————————————– # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
#
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. #
————————————————————————– # Copyright 2002-2017, OpenNebula Project, OpenNebula Systems #
#
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. #
Constants
- DEFAULT_POOL_PAGE_SIZE
- NOKOGIRI
- OX
- REXML_FORMATTERS
- VERSION
OpenNebula version
Public Class Methods
receive hashed values (res) with a token returns original values
# File lib/opennebula/utils.rb, line 37 def self.decrypt(res, token) opts = {} res.each do |key, encrypted_value| decipher = OpenSSL::Cipher::AES.new(256,:CBC) decipher.decrypt decipher.key = token[0..31] plain = decipher.update(Base64::decode64(encrypted_value)) + decipher.final opts[key] = plain end return opts end
receive a object key => value format returns hashed values
# File lib/opennebula/utils.rb, line 24 def self.encrypt(opts, token) res = {} opts.each do |key, value| cipher = OpenSSL::Cipher::AES.new(256,:CBC) cipher.encrypt.key = token[0..31] encrypted = cipher.update(value) + cipher.final res[key] = Base64::encode64(encrypted).gsub("\n", "") end return res end
Returns true if the object returned by a method of the OpenNebula library is an Error
# File lib/opennebula/error.rb, line 56 def self.is_error?(value) value.class==OpenNebula::Error end
# File lib/opennebula/client.rb, line 24 def self.pool_page_size @@pool_page_size end
Processes the monitoring data in XML returned by OpenNebula
@param [XMLElement] xmldoc monitoring data returned by OpenNebula @param [String] root_elem Root for each individual PoolElement @param [String] timestamp_elem Name of the XML element with the last
monitorization timestamp
@param [Integer] oid Id of the object to process @param [Array<String>] xpath_expressions Elements to retrieve.
@return [Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with
the requested xpath expressions, and an Array of [timestamp, value].
# 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