Class: Nagios::Promoo::Occi::Probes::ComputeProbe

Inherits:
BaseProbe
  • Object
show all
Includes:
Utils::Cache
Defined in:
lib/nagios/promoo/occi/probes/compute_probe.rb

Overview

Probe for checking compute instantiation via OCCI.

Author:

Constant Summary collapse

READY_STATES =
%w[active online].freeze
NONREADY_STATES =
%w[inactive offline].freeze
ERROR_STATES =
%w[error].freeze
CPU_SUM_WEIGHT =
1000
COMPUTE_NAME_PREFIX =
'sam-nagios-promoo'.freeze
DEFAULT_STORAGE_SIZE =

GB

1
APPDB_PROVIDERS_URL =
'https://appdb.egi.eu/rest/1.0/va_providers?listmode=details'.freeze

Constants included from Utils::Cache

Utils::Cache::CACHE_DIR

Instance Attribute Summary

Attributes inherited from BaseProbe

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Cache

#cache_fetch, #cache_valid?, #read_cache, #write_cache

Methods inherited from BaseProbe

#client, #initialize

Constructor Details

This class inherits a constructor from Nagios::Promoo::Occi::Probes::BaseProbe

Class Method Details

.declarationObject



40
41
42
# File 'lib/nagios/promoo/occi/probes/compute_probe.rb', line 40

def declaration
  'compute'
end

.descriptionObject



13
14
15
# File 'lib/nagios/promoo/occi/probes/compute_probe.rb', line 13

def description
  ['compute', 'Run a probe creating a compute instance via OCCI']
end

.optionsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/nagios/promoo/occi/probes/compute_probe.rb', line 17

def options
  [
    [:appid, { type: :string, required: true, desc: 'AppDB ID referencing a virtual appliance' }],
    [
      :vo,
      {
        type: :string,
        required: true,
        desc: 'Virtual Organization name used to select the appropriate virtual appliance'
      }
    ],
    [
      :with_storage,
      {
        type: :boolean, default: false,
        desc: 'Run test attaching a storage instance to compute instance'
      }
    ],
    [:cache_expiration, { type: :numeric, default: 7200, desc: 'AppDB cache expiration (in seconds)' }],
    [:cleanup, { type: :boolean, default: true, desc: 'Perform clean-up before launching a new instance' }]
  ]
end

.runnable?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/nagios/promoo/occi/probes/compute_probe.rb', line 44

def runnable?
  true
end

Instance Method Details

#run(_args = []) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/nagios/promoo/occi/probes/compute_probe.rb', line 59

def run(_args = [])
  @_links = {}

  Timeout.timeout(options[:timeout]) { compute_provision }
  puts "COMPUTE OK - Instance(s) #{@_links[:compute].inspect} created & cleaned up"
rescue Timeout::Error
  puts "COMPUTE CRITICAL - Probe execution timed out [#{options[:timeout]}s]"
  exit 2
end