class Nagios::Promoo::Appdb::Probes::BaseProbe

Base probe class for all AppDB-related probes.

@author Boris Parak <parak@cesnet.cz>

Constants

APPDB_IS_URL
DEFAULT_HEADERS
GQL_APPLIANCES_BY_ENDPOINT
GQL_SIZES_BY_ENDPOINT

Attributes

endpoint[R]
options[R]
vo[R]

Public Class Methods

new(options) click to toggle source
# 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
runnable?() click to toggle source
# File lib/nagios/promoo/appdb/probes/base_probe.rb, line 10
def runnable?
  false
end

Public Instance Methods

appliances_by_endpoint() click to toggle source
# 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_endpoint() click to toggle source
# 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

Private Instance Methods

make(query) click to toggle source
# File lib/nagios/promoo/appdb/probes/base_probe.rb, line 68
def make(query)
  response = HTTParty.post(APPDB_IS_URL, body: { query: query }.to_json, headers: DEFAULT_HEADERS)
  raise "#{query.inspect} failed to get data from AppDB [HTTP #{response.code}]" unless response.success?

  response.parsed_response
end