class ForemanMaintain::Utils::Service::RemoteDB

Attributes

component[R]
db_feature[R]

Public Class Methods

new(name, priority, options = {}) click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 6
def initialize(name, priority, options = {})
  super
  @db_feature = options.fetch(:db_feature)
  @component = options.fetch(:component, nil)
end

Public Instance Methods

disable() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 25
def disable
  [0, db_status("It can't be disabled.").last]
end
enable() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 29
def enable
  [0, db_status("It can't be enabled.").last]
end
exist?() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 55
def exist?
  true
end
inspect() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 16
def inspect
  component = @component ? ':' + @component : ''
  "#{self.class.name.split('::').last}(#{@name}#{component} [#{@priority}])"
end
matches?(service) click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 45
def matches?(service)
  if service.instance_of?(self.class)
    service.name == @name && service.component == @component
  elsif service.is_a? String
    service == @name
  else
    false
  end
end
running?() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 41
def running?
  status.first == 0
end
start() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 33
def start
  db_status
end
status() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 21
def status
  db_status
end
stop() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 37
def stop
  [0, db_status.last]
end
to_s() click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 12
def to_s
  @name + (@component ? " (#{@component})" : '')
end

Private Instance Methods

db_status(msg = nil) click to toggle source
# File lib/foreman_maintain/utils/service/remote_db.rb, line 61
def db_status(msg = nil)
  msg = " #{msg}" if msg
  if @db_feature.ping
    [0, "#{self} is remote and is UP.#{msg}"]
  else
    [1, "#{self} is remote and is DOWN.#{msg}" \
      "\n  Unable to connect to the remote database." \
      "\n  See the log (#{ForemanMaintain.config.log_filename}) for more details.#{msg}"]
  end
end