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



12
13
14
15
16
17
18
19
20
# File 'app/models/concerns/foreman_dlm/host_monitoring_extensions.rb', line 12

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



32
33
34
35
36
37
38
# File 'app/models/concerns/foreman_dlm/host_monitoring_extensions.rb', line 32

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



22
23
24
25
26
27
28
29
30
# File 'app/models/concerns/foreman_dlm/host_monitoring_extensions.rb', line 22

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