Class: Nagios::Promoo::Occi::Probes::KindsProbe
- Defined in:
- lib/nagios/promoo/occi/probes/kinds_probe.rb
Overview
Probe for checking OCCI kinds declared by sites.
Constant Summary collapse
- CORE_KINDS =
%w[ http://schemas.ogf.org/occi/core#entity http://schemas.ogf.org/occi/core#resource http://schemas.ogf.org/occi/core#link ].freeze
- INFRA_KINDS =
%w[ http://schemas.ogf.org/occi/infrastructure#compute http://schemas.ogf.org/occi/infrastructure#storage http://schemas.ogf.org/occi/infrastructure#network http://schemas.ogf.org/occi/infrastructure#storagelink http://schemas.ogf.org/occi/infrastructure#networkinterface ].freeze
Instance Attribute Summary
Attributes inherited from BaseProbe
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseProbe
Constructor Details
This class inherits a constructor from Nagios::Promoo::Occi::Probes::BaseProbe
Class Method Details
.declaration ⇒ Object
43 44 45 |
# File 'lib/nagios/promoo/occi/probes/kinds_probe.rb', line 43 def declaration 'kinds' end |
.description ⇒ Object
13 14 15 |
# File 'lib/nagios/promoo/occi/probes/kinds_probe.rb', line 13 def description ['kinds', 'Run a probe checking for mandatory OCCI kind definitions'] end |
.options ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nagios/promoo/occi/probes/kinds_probe.rb', line 17 def [ [ :kinds, { type: :string, enum: %w[core infra all], default: 'all', desc: 'Collection of mandatory kinds to check' } ], [ :optional, { type: :array, default: [], desc: 'Identifiers of optional kinds (optional by force)' } ], [ :check_location, { type: :boolean, default: false, desc: 'Verify declared REST locations for INFRA resources' } ] ] end |
.runnable? ⇒ Boolean
47 48 49 |
# File 'lib/nagios/promoo/occi/probes/kinds_probe.rb', line 47 def runnable? true end |
Instance Method Details
#run(_args = []) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/nagios/promoo/occi/probes/kinds_probe.rb', line 66 def run(_args = []) kinds = [] kinds += CORE_KINDS if %w[core all].include?([:kinds]) kinds += INFRA_KINDS if %w[infra all].include?([:kinds]) kinds -= [:optional] if [:optional] Timeout.timeout([:timeout]) do kinds.each do |kind| raise "#{kind.inspect} is missing" unless client.model.get_by_id(kind, true) next unless [:check_location] && INFRA_KINDS.include?(kind) # Make sure declared locations are actually available as REST # endpoints. Failure will raise an exception, no need to do # anything here. To keep requirements reasonable, only INFRA # kinds are considered relevant for this part of the check. begin client.list(kind) rescue => err raise "Failed to verify declared REST location for #{kind.inspect} (#{err.})" end end end puts 'KINDS OK - All specified OCCI kinds were found' rescue => ex puts "KINDS CRITICAL - #{ex.}" puts ex.backtrace if [:debug] exit 2 end |