Class: OpenNebulaEconeProbe
- Inherits:
-
OpennebulaProbe
- Object
- OpennebulaProbe
- OpenNebulaEconeProbe
- Defined in:
- lib/probe/opennebula_econe_probe.rb
Overview
OpenNebulaEconeProbe - Econe client query service implementation.
Constant Summary
Constants inherited from OpennebulaProbe
OpennebulaProbe::CRIT_MSG, OpennebulaProbe::OK_MSG, OpennebulaProbe::UNKWN_MSG, OpennebulaProbe::WARN_MSG
Instance Attribute Summary
Attributes inherited from OpennebulaProbe
Instance Method Summary collapse
- #check_crit ⇒ Object
- #check_resources(resources) ⇒ Object
- #check_warn ⇒ Object
-
#initialize(opts) ⇒ OpenNebulaEconeProbe
constructor
A new instance of OpenNebulaEconeProbe.
Methods inherited from OpennebulaProbe
Constructor Details
#initialize(opts) ⇒ OpenNebulaEconeProbe
Returns a new instance of OpenNebulaEconeProbe.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/probe/opennebula_econe_probe.rb', line 23 def initialize(opts) super(opts) @connection = AWS::EC2::Base.new( access_key_id: @opts.username, secret_access_key: Digest::SHA1.hexdigest(@opts.password), server: @opts.hostname, port: @opts.port, path: @opts.path, use_ssl: @opts.protocol == :https ) end |
Instance Method Details
#check_crit ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/probe/opennebula_econe_probe.rb', line 36 def check_crit @logger.info "Checking for basic connectivity at #{@endpoint}" begin @connection.describe_images @connection.describe_instances rescue StandardError => e @logger.error "Failed to check connectivity: #{e.}" @logger.debug "#{e.backtrace.join("\n")}" return true end false end |
#check_resources(resources) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/probe/opennebula_econe_probe.rb', line 50 def check_resources(resources) if resources.map { |x| x[:resource] }.reduce(true) { |product, resource| product && resource.nil? } @logger.info 'There are no resources to check, for details on how to specify resources see --help' return false end resources.each do |resource_hash| resource = resource_hash[:resource] next unless resource @logger.info "Looking for #{resource_hash[:resource_string]}s: #{resource.inspect}" if resource_hash[:resource_type] == :image result = @connection.describe_images set = 'imagesSet' id = 'imageId' elsif resource_hash[:resource_type] == :compute result = @connection.describe_instances result = result['reservationSet']['item'][0] if result['reservationSet'] && result['reservationSet']['item'] set = 'instancesSet' id = 'amiLaunchIndex' else fail 'Wrong resource definition' end @logger.debug result fail "No #{resource_hash[:resource_string].capitalize} found" unless result && result[set] resource.each do |resource_to_look_for| found = false result[set]['item'].each { |resource_found| found = true if resource_to_look_for == resource_found[id] } fail "#{resource_hash[:resource_string].capitalize} #{resource_to_look_for} not found" unless found end end false end |
#check_warn ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/probe/opennebula_econe_probe.rb', line 91 def check_warn @logger.info "Checking for resource availability at #{@endpoint}" # iterate over given resources @logger.info "Not looking for networks, since it is not supported by OpenNebula's ECONE server'" if @opts.network resources = [] resources << { resource_type: :image, resource: @opts.storage, resource_string: 'image' } resources << { resource_type: :compute, resource: @opts.compute, resource_string: 'compute instance' } check_resources(resources) rescue StandardError => e @logger.error "Failed to check resource availability: #{e.}" @logger.debug "#{e.backtrace.join("\n")}" return true end |