module OpenNebula
————————————————————————– # Copyright 2002-2020, 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-2020, 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-2020, 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-2020, 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-2020, 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
>> /var/log/one/oned.log
# File lib/opennebula/utils.rb, line 51 def self.handle_driver_exception(action, ex, host, did = nil, id = nil, file = nil) file ||= "" id ||= "" did ||= "" OpenNebula::log_error(action + " of VM #{id} #{did} on host #{host} #{file} "+ "due to \"#{ex.message}\"" + "\n********* STACK TRACE *********\n" + "\t#{ex.backtrace.join("\n\t")}" + "\n*******************************\n") OpenNebula.error_message("There is a problem: #{ex.message}") exit (-1) 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
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 266 def self.process_monitoring(xmldoc, oid, xpath_expressions) hash = {} timestamps = xmldoc.retrieve_elements( "/MONITORING_DATA/MONITORING[ID=#{oid}]/TIMESTAMP") xpath_expressions.each { |xpath| xpath_values = xmldoc.retrieve_elements( "/MONITORING_DATA/MONITORING[ID=#{oid}]/#{xpath}") if ( xpath_values.nil? ) hash[xpath] = [] else hash[xpath] = timestamps.zip(xpath_values) end } return hash end