Module: ForemanDlm::HostMonitoringExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/foreman_dlm/host_monitoring_extensions.rb

Instance Method Summary collapse

Instance Method Details

#add_lock_monitoring_downtimeObject



10
11
12
13
14
15
16
17
# File 'app/models/concerns/foreman_dlm/host_monitoring_extensions.rb', line 10

def add_lock_monitoring_downtime
  return unless monitored?
  logger.info "Setting Monitoring downtime for #{self}"
  monitoring.set_downtime_host(self, lock_monitoring_downtime_options)
  true
rescue ProxyAPI::ProxyException => e
  Foreman::Logging.exception("Unable to set monitoring downtime for #{e}", e)
end

#lock_monitoring_downtime_optionsObject



28
29
30
31
32
33
34
# File 'app/models/concerns/foreman_dlm/host_monitoring_extensions.rb', line 28

def lock_monitoring_downtime_options
  {
    comment: _('Host acquired lock.'),
    start_time: Time.current.to_i,
    end_time: Time.current.advance(:minutes => 180).to_i
  }
end

#remove_lock_monitoring_downtimeObject



19
20
21
22
23
24
25
26
# File 'app/models/concerns/foreman_dlm/host_monitoring_extensions.rb', line 19

def remove_lock_monitoring_downtime
  return unless monitored?
  logger.info "Deleting Monitoring downtime for #{self}"
  monitoring.del_downtime_host(self, lock_monitoring_downtime_options)
  true
rescue ProxyAPI::ProxyException => e
  Foreman::Logging.exception("Unable to remove monitoring downtime for #{e}", e)
end