Class: Nagios::Promoo::Appdb::Probes::BaseProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/nagios/promoo/appdb/probes/base_probe.rb

Overview

Base probe class for all AppDB-related probes.

Author:

Direct Known Subclasses

AppliancesProbe, SizesProbe, SyncProbe

Constant Summary collapse

APPDB_IS_URL =
'http://is.marie.hellasgrid.gr/graphql'.freeze
DEFAULT_HEADERS =
{ 'Content-Type' => 'application/json' }.freeze
GQL_SIZES_BY_ENDPOINT =
%|
{
  siteServiceTemplates(
    filter: { service: { endpointURL: { eq: "$$ENDPOINT$$" } } }, limit: 1000
  ) {
    items { resourceID }
  }
}
|.freeze
GQL_APPLIANCES_BY_ENDPOINT =
%|
{
  siteServiceImages(
    filter: { imageVoVmiInstanceVO: { eq: "$$VO$$" }, service: { endpointURL: { eq: "$$ENDPOINT$$" } } }, limit: 1000
  ) {
    items { applicationEnvironmentRepository applicationEnvironmentAppVersion }
  }
}
|.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ BaseProbe

Returns a new instance of BaseProbe.



38
39
40
41
42
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 38

def initialize(options)
  @options = options
  @endpoint = options.fetch(:endpoint)
  @vo = options.fetch(:vo, nil)
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



36
37
38
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 36

def endpoint
  @endpoint
end

#optionsObject (readonly)

Returns the value of attribute options.



36
37
38
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 36

def options
  @options
end

#voObject (readonly)

Returns the value of attribute vo.



36
37
38
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 36

def vo
  @vo
end

Class Method Details

.runnable?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 10

def runnable?
  false
end

Instance Method Details

#appliances_by_endpointObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 55

def appliances_by_endpoint
  return @_appliances if @_appliances
  raise '`endpoint` and `vo` are mandatory arguments' if endpoint.blank? || vo.blank?

  query = GQL_APPLIANCES_BY_ENDPOINT.gsub('$$ENDPOINT$$', endpoint).gsub('$$VO$$', vo)
  @_appliances = make(query)['data']['siteServiceImages']['items']
  raise "Could not locate appliances from endpoint #{endpoint.inspect} in AppDB" unless @_appliances

  @_appliances
end

#sizes_by_endpointObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/nagios/promoo/appdb/probes/base_probe.rb', line 44

def sizes_by_endpoint
  return @_sizes if @_sizes
  raise '`endpoint` is a mandatory argument' if endpoint.blank?

  query = GQL_SIZES_BY_ENDPOINT.gsub('$$ENDPOINT$$', endpoint)
  @_sizes = make(query)['data']['siteServiceTemplates']['items']
  raise "Could not locate sizes from endpoint #{endpoint.inspect} in AppDB" unless @_sizes

  @_sizes
end