foreman_monitoring 0.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +14 -7
  3. data/Rakefile +0 -0
  4. data/app/controllers/api/v2/downtime_controller.rb +63 -0
  5. data/app/controllers/api/v2/monitoring_results_controller.rb +5 -4
  6. data/app/controllers/concerns/foreman_monitoring/find_host_by_client_cert.rb +59 -0
  7. data/app/controllers/concerns/foreman_monitoring/hosts_controller_extensions.rb +7 -5
  8. data/app/helpers/concerns/foreman_monitoring/hosts_helper_ext.rb +11 -13
  9. data/app/lib/proxy_api/monitoring.rb +9 -6
  10. data/app/models/concerns/foreman_monitoring/host_extensions.rb +6 -3
  11. data/app/models/concerns/foreman_monitoring/hostgroup_extensions.rb +7 -3
  12. data/app/models/concerns/orchestration/monitoring.rb +22 -15
  13. data/app/models/host_status/monitoring_status.rb +7 -4
  14. data/app/models/monitoring_result.rb +13 -6
  15. data/app/models/setting/monitoring.rb +4 -2
  16. data/app/overrides/add_host_monitoring_result_tab.rb +8 -6
  17. data/app/overrides/add_host_multiple_power_set_downtime_checkbox.rb +5 -3
  18. data/app/overrides/add_host_set_downtime_modal.rb +4 -2
  19. data/app/services/monitoring.rb +3 -0
  20. data/app/views/hosts/_downtime_fields.html.erb +2 -2
  21. data/app/views/monitoring_results/_host_tab_pane.html.erb +2 -2
  22. data/config/routes.rb +3 -0
  23. data/db/migrate/20160817135723_create_monitoring_results.rb +5 -1
  24. data/db/migrate/20161220201510_add_monitoring_proxy_id_to_host_and_hostgroup.rb +3 -1
  25. data/db/migrate/201910180900_rename_downtime_host_permission.rb +15 -0
  26. data/db/seeds.d/60-monitoring_proxy_feature.rb +2 -0
  27. data/lib/foreman_monitoring.rb +2 -0
  28. data/lib/foreman_monitoring/engine.rb +32 -28
  29. data/lib/foreman_monitoring/version.rb +3 -1
  30. data/lib/tasks/foreman_monitoring_tasks.rake +5 -5
  31. data/locale/gemspec.rb +2 -0
  32. data/test/controllers/api/v2/downtime_controller_test.rb +73 -0
  33. data/test/factories/feature.rb +4 -2
  34. data/test/factories/host.rb +6 -4
  35. data/test/factories/monitoring_results.rb +9 -7
  36. data/test/factories/smart_proxy.rb +3 -1
  37. data/test/functional/hosts_controller_test.rb +65 -52
  38. data/test/lib/proxy_api/monitoring_test.rb +16 -14
  39. data/test/test_plugin_helper.rb +5 -3
  40. data/test/unit/host_status/monitoring_status_test.rb +18 -16
  41. data/test/unit/host_test.rb +6 -4
  42. data/test/unit/monitoring_result_test.rb +75 -0
  43. data/test/unit/monitoring_test.rb +5 -3
  44. metadata +68 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6ec30b6e40aad99c7da94b66100590381d300289
4
- data.tar.gz: ef1bb20065f0c5b11544f64babe2ab0c8faa3b6d
2
+ SHA256:
3
+ metadata.gz: 5e703d5ad965ed3aecba3fee0dc31a7a2c80a84eab893392484555fda8ba8ab1
4
+ data.tar.gz: 6dce2771bea3df536cb244aadfbad6483387d71157c4b70d5cbe0256b27f508c
5
5
  SHA512:
6
- metadata.gz: 92fc91db5150b641f8a169fce2468695a4a64e84ec02235259385864deb0c1b7309e49853fb297a88f9e37d143371f88d6aa446c37abebc8d8a2172433a725d1
7
- data.tar.gz: 9306c61272155529c75cd7c90b9a115a5d931b11455f0313fa057de42ac565a3a301023cbd95fc8fa744d913e570ea8a8ad3c689f042c45aa5a6d4dc00d944e2
6
+ metadata.gz: e3c24e7c223b0103333d21717636f338176cb2756028d60943c8e6276ffaa366de039dec2b5afd527b5f50464737194b6cc6d5e357f9696d6b56aff167b7fc6e
7
+ data.tar.gz: ca91aa5af43494a254fbe03bd13cb4e4e30dccfdab8e47befb8252f97b2cce1bd8ab850739993d1675d194f3253a8b5825b248f6d95cc75b6b7c4915252356eb
data/README.md CHANGED
@@ -17,7 +17,7 @@ The gem name is `foreman_monitoring`.
17
17
 
18
18
  RPM users can install the `tfm-rubygem-foreman_monitoring` package.
19
19
 
20
- Deb users can install the `ruby-foreman_monitoring` package.
20
+ Deb users can install the `ruby-foreman-monitoring` package.
21
21
 
22
22
  If using the gem as installation source database enhancement and service restart must
23
23
  be done manually.
@@ -28,6 +28,13 @@ foreman-rake db:seed
28
28
  touch ~foreman/tmp/restart.txt
29
29
  ```
30
30
 
31
+ ## Compatibility
32
+
33
+ | Foreman Version | Plugin Version |
34
+ | --------------- | --------------:|
35
+ | >= 1.15 | ~> 0.1 |
36
+ | >= 1.17 | ~> 1.0 |
37
+
31
38
  # Usage
32
39
 
33
40
  For managing a host in the monitoring solution a Smart Proxy providing
@@ -35,15 +42,15 @@ the `monitoring` feature has to be assigned. This can be done during
35
42
  provisioning or as a bulk action from the host overview.
36
43
 
37
44
  You can configure the default action which will be done during host
38
- provisioning and deprovisioning. Provisioning allows to create a monitoring
39
- object or take no action while deprovisioing allows to delete the monitoring
40
- object, set a downtime or take no action. For rebuild it will by default
45
+ provisioning and de-provisioning. Provisioning allows to create a monitoring
46
+ object or take no action while de-provisoning allows deleting the monitoring
47
+ object, set a downtime or take no action. For rebuild, it will by default
41
48
  set a downtime.
42
49
 
43
50
  The plugin will show you the monitoring status as a sub-status and a detail
44
51
  panel. You can configure if the sub-status should affect the global status.
45
52
 
46
- Furthermore it allows to individually set a downtime at the host detail view
53
+ Furthermore, it allows to individually set a downtime at the host detail view
47
54
  or as a bulk action from the host overview.
48
55
 
49
56
  # Troubleshooting
@@ -51,8 +58,8 @@ or as a bulk action from the host overview.
51
58
  Logging entries relevant to the plug-in will be located in the Foreman's log
52
59
  which is by default `/var/log/foreman/production.log`.
53
60
 
54
- Also check the troubleshooting section of the Smart Proxy plug-in if problems
55
- occure in the underlying communication.
61
+ Also, check the troubleshooting section of the Smart Proxy plug-in if problems
62
+ occur in the underlying communication.
56
63
 
57
64
  ## Contributing
58
65
 
data/Rakefile CHANGED
File without changes
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Api
4
+ module V2
5
+ class DowntimeController < V2::BaseController
6
+ include Api::Version2
7
+ include ::ForemanMonitoring::FindHostByClientCert
8
+
9
+ authorize_host_by_client_cert %i[create]
10
+ before_action :find_host, :only => [:create]
11
+
12
+ api :POST, '/downtime', N_('Schedule host downtime')
13
+ param :duration, :number, :desc => N_('Downtime duration (seconds)'), :required => false
14
+ param :reason, String, :desc => N_('Downtime reason'), :required => false
15
+
16
+ def create
17
+ begin
18
+ options = {
19
+ :comment => downtime_params[:reason] || _('Host requested downtime')
20
+ }
21
+ if downtime_params.key? :duration
22
+ options[:start_time] = Time.now.to_i
23
+ options[:end_time] = Time.now.to_i + downtime_params[:duration].to_i
24
+ end
25
+ @host.downtime_host(options)
26
+ rescue StandardError => e
27
+ Foreman::Logging.exception('Failed to request downtime', e)
28
+ render :json => { 'message' => e.message }, :status => :unprocessable_entity
29
+ return
30
+ end
31
+
32
+ render :json => { 'message' => 'OK' }
33
+ end
34
+
35
+ private
36
+
37
+ def downtime_params
38
+ params.permit(:duration, :reason)
39
+ end
40
+
41
+ def find_host
42
+ @host = detected_host
43
+
44
+ return true if @host
45
+
46
+ logger.info 'Denying access because no host could be detected.'
47
+ if User.current
48
+ render_error 'access_denied',
49
+ :status => :forbidden,
50
+ :locals => {
51
+ :details => 'You need to authenticate with a valid client cert. The DN has to match a known host.'
52
+ }
53
+ else
54
+ render_error 'unauthorized',
55
+ :status => :unauthorized,
56
+ :locals => {
57
+ :user_login => get_client_cert_hostname
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Api
2
4
  module V2
3
5
  class MonitoringResultsController < V2::BaseController
@@ -17,10 +19,9 @@ module Api
17
19
 
18
20
  def create
19
21
  begin
20
- MonitoringResult.import(monitoring_result_params.with_indifferent_access)
21
- rescue => e
22
- logger.error "Failed to import monitoring result: #{e.message}"
23
- logger.debug e.backtrace.join("\n")
22
+ MonitoringResult.import(monitoring_result_params.to_h.with_indifferent_access)
23
+ rescue StandardError => e
24
+ Foreman::Logging.exception('Failed to import monitoring result', e)
24
25
  render :json => { 'message' => e.message }, :status => :unprocessable_entity
25
26
  return
26
27
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanMonitoring
4
+ module FindHostByClientCert
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ def authorize_host_by_client_cert(actions, _options = {})
9
+ skip_before_action :require_login, :only => actions, :raise => false
10
+ skip_before_action :authorize, :only => actions
11
+ skip_before_action :verify_authenticity_token, :only => actions
12
+ skip_before_action :set_taxonomy, :only => actions, :raise => false
13
+ skip_before_action :session_expiry, :update_activity_time, :only => actions
14
+ before_action(:only => actions) { require_client_cert_or_login }
15
+ attr_reader :detected_host
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ # Permits Hosts authorized by their client cert
22
+ # or a user with permission
23
+ def require_client_cert_or_login
24
+ @detected_host = find_host_by_client_cert
25
+
26
+ if detected_host
27
+ set_admin_user
28
+ return true
29
+ end
30
+
31
+ require_login
32
+ unless User.current
33
+ render_error 'unauthorized', :status => :unauthorized unless performed? && api_request?
34
+ return false
35
+ end
36
+ authorize
37
+ end
38
+
39
+ def find_host_by_client_cert
40
+ hostname = get_client_cert_hostname
41
+
42
+ return unless hostname
43
+
44
+ host ||= Host::Base.find_by(certname: hostname) ||
45
+ Host::Base.find_by(name: hostname)
46
+ logger.info { "Found Host #{host} by client cert #{hostname}" } if host
47
+ host
48
+ end
49
+
50
+ def get_client_cert_hostname
51
+ client_certificate = Foreman::ClientCertificate.new(request: request)
52
+ return unless client_certificate.verified?
53
+
54
+ hostname = client_certificate.subject
55
+ logger.debug "Extracted hostname '#{hostname}' from client certificate." if hostname
56
+ hostname
57
+ end
58
+ end
59
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanMonitoring
2
4
  module HostsControllerExtensions
3
5
  def self.prepended(base)
@@ -38,14 +40,14 @@ module ForemanMonitoring
38
40
  failed_hosts[host.name] = error_message
39
41
  logger.error "Failed to set a host downtime for #{host}: #{error_message}"
40
42
  end
41
- rescue => error
42
- failed_hosts[host.name] = error
43
- Foreman::Logging.exception(_('Failed to set a host downtime for %s.') % host, error)
43
+ rescue StandardError => e
44
+ failed_hosts[host.name] = e
45
+ Foreman::Logging.exception(_('Failed to set a host downtime for %s.') % host, e)
44
46
  end
45
47
  end
46
48
 
47
49
  if failed_hosts.empty?
48
- notice _('A downtime was set for the selected hosts.')
50
+ success _('A downtime was set for the selected hosts.')
49
51
  else
50
52
  error n_('A downtime clould not be set for host: %s.',
51
53
  'A downtime could not be set for hosts: %s.',
@@ -128,7 +130,7 @@ module ForemanMonitoring
128
130
  def action_permission
129
131
  case params[:action]
130
132
  when 'downtime', 'select_multiple_downtime', 'update_multiple_downtime'
131
- :downtime
133
+ :manage_downtime
132
134
  when 'select_multiple_monitoring_proxy', 'update_multiple_monitoring_proxy'
133
135
  :edit
134
136
  else
@@ -1,13 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanMonitoring
2
4
  module HostsHelperExt
3
5
  def multiple_actions
4
6
  actions = super
5
- if authorized_for(:controller => :hosts, :action => :select_multiple_downtime)
6
- actions << [_('Set downtime'), select_multiple_downtime_hosts_path]
7
- end
8
- if authorized_for(:controller => :hosts, :action => :select_multiple_monitoring_proxy)
9
- actions << [_('Change Monitoring Proxy'), select_multiple_monitoring_proxy_hosts_path]
10
- end
7
+ actions << [_('Set downtime'), select_multiple_downtime_hosts_path] if authorized_for(:controller => :hosts, :action => :select_multiple_downtime)
8
+ actions << [_('Change Monitoring Proxy'), select_multiple_monitoring_proxy_hosts_path] if authorized_for(:controller => :hosts, :action => :select_multiple_monitoring_proxy)
11
9
  actions
12
10
  end
13
11
 
@@ -16,14 +14,14 @@ module ForemanMonitoring
16
14
  button_group(
17
15
  display_link_if_authorized(_('Downtime'),
18
16
  hash_for_host_path(:id => host).merge(:auth_object => host,
19
- :permission => :manage_host_downtimes,
17
+ :permission => :manage_downtime_hosts,
20
18
  :anchor => 'set_host_downtime'),
21
19
  :class => 'btn btn-default',
22
20
  :disabled => !host.monitored?,
23
- :title => _('Set a downtime for this host'),
24
- :id => 'host-downtime',
25
- :data => { :toggle => 'modal',
26
- :target => '#set_host_downtime' })
21
+ :title => _('Set a downtime for this host'),
22
+ :id => 'host-downtime',
23
+ :data => { :toggle => 'modal',
24
+ :target => '#set_host_downtime' })
27
25
  )
28
26
  )
29
27
  super
@@ -57,10 +55,10 @@ module ForemanMonitoring
57
55
  end
58
56
  end
59
57
 
60
- def datetime_f(f, attr, options = {})
58
+ def monitoring_datetime_f(f, attr, options = {})
61
59
  field(f, attr, options) do
62
60
  addClass options, 'form-control'
63
- f.datetime_local_field attr, options
61
+ f.datetime_field attr, options
64
62
  end
65
63
  end
66
64
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ProxyAPI
2
4
  class Monitoring < ProxyAPI::Resource
3
5
  def initialize(args)
@@ -7,34 +9,35 @@ module ProxyAPI
7
9
 
8
10
  def create_host_downtime(host, args = {})
9
11
  parse(post(args, "downtime/host/#{host}"))
10
- rescue => e
12
+ rescue StandardError => e
11
13
  raise ProxyException.new(url, e, N_('Unable to set downtime for %s') % host)
12
14
  end
13
15
 
14
16
  def remove_host_downtime(host, args = {})
15
17
  parse(delete("downtime/host/#{host}?#{args.to_query}"))
16
- rescue => e
18
+ rescue StandardError => e
17
19
  raise ProxyException.new(url, e, N_('Unable to remove downtime for %s') % host)
18
20
  end
19
21
 
20
22
  def create_host(host, attributes = {})
21
23
  parse(put({ :attributes => attributes }, "host/#{host}"))
22
- rescue => e
24
+ rescue StandardError => e
23
25
  raise ProxyException.new(url, e, N_('Unable to create monitoring host object for %s') % host)
24
26
  end
25
27
 
26
28
  def update_host(host, attributes = {})
27
29
  parse(post({ :attributes => attributes }, "host/#{host}"))
28
- rescue => e
30
+ rescue StandardError => e
29
31
  raise ProxyException.new(url, e, N_('Unable to update monitoring host object for %s') % host)
30
32
  end
31
33
 
32
34
  def delete_host(host)
33
35
  raise Foreman::Exception, 'Missing hostname.' if host.blank?
36
+
34
37
  parse(delete("host/#{host}"))
35
38
  rescue RestClient::ResourceNotFound
36
39
  true
37
- rescue => e
40
+ rescue StandardError => e
38
41
  raise ProxyException.new(url, e, N_('Unable to delete monitoring host object for %s') % host)
39
42
  end
40
43
 
@@ -42,7 +45,7 @@ module ProxyAPI
42
45
  parse(get("host/#{host}"))
43
46
  rescue RestClient::ResourceNotFound
44
47
  nil
45
- rescue => e
48
+ rescue StandardError => e
46
49
  raise ProxyException.new(url, e, N_('Unable to query monitoring host object for %{host}: %{message}') % { :host => host, :message => e.try(:response) || e.try(:message) })
47
50
  end
48
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanMonitoring
2
4
  module HostExtensions
3
5
  def self.prepended(base)
@@ -6,7 +8,7 @@ module ForemanMonitoring
6
8
 
7
9
  after_build :downtime_host_build
8
10
 
9
- has_many :monitoring_results, :dependent => :destroy, :foreign_key => 'host_id'
11
+ has_many :monitoring_results, :dependent => :destroy, :foreign_key => 'host_id', :inverse_of => :host
10
12
  end
11
13
  end
12
14
 
@@ -28,6 +30,7 @@ module ForemanMonitoring
28
30
 
29
31
  def downtime_host(options)
30
32
  return unless monitored?
33
+
31
34
  begin
32
35
  monitoring.set_downtime_host(self, options)
33
36
  rescue ProxyAPI::ProxyException => e
@@ -59,12 +62,12 @@ module ForemanMonitoring
59
62
  :architecture => architecture.try(:name),
60
63
  :os => operatingsystem.try(:to_label),
61
64
  :osfamily => operatingsystem.try(:family),
62
- :virtual => provider != 'BareMetal',
65
+ :virtual => virtual.presence || provider != 'BareMetal',
63
66
  :provider => provider,
64
67
  :compute_resource => compute_resource.try(:to_label),
65
68
  :hostgroup => hostgroup.try(:to_label),
66
69
  :organization => organization.try(:name),
67
- :location => organization.try(:name),
70
+ :location => location.try(:name),
68
71
  :comment => comment,
69
72
  :environment => environment.try(:to_s),
70
73
  :owner_name => owner.try(:name)
@@ -1,14 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanMonitoring
2
4
  module HostgroupExtensions
3
5
  extend ActiveSupport::Concern
4
6
 
5
7
  def monitoring_proxy
6
- return super unless ancestry.present?
7
- SmartProxy.find_by_id(inherited_monitoring_proxy_id)
8
+ return super if ancestry.blank?
9
+
10
+ SmartProxy.find_by(id: inherited_monitoring_proxy_id)
8
11
  end
9
12
 
10
13
  def inherited_monitoring_proxy_id
11
- return monitoring_proxy_id unless ancestry.present?
14
+ return monitoring_proxy_id if ancestry.blank?
15
+
12
16
  self[:monitoring_proxy_id] || self.class.sort_by_ancestry(ancestors.where('monitoring_proxy_id is not NULL')).last.try(:monitoring_proxy_id)
13
17
  end
14
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Orchestration::Monitoring
2
4
  extend ActiveSupport::Concern
3
5
 
@@ -10,55 +12,59 @@ module Orchestration::Monitoring
10
12
 
11
13
  def queue_monitoring
12
14
  return unless monitored? && errors.empty?
15
+
13
16
  clear_monitoring_object
14
17
  !monitoring_object.key?(:attrs) ? queue_monitoring_create : queue_monitoring_update
15
18
  end
16
19
 
17
20
  def queue_monitoring_create
18
21
  return true unless ::Monitoring.create_action?(:create)
19
- queue.create(:name => _('Create monitoring object for %s') % self, :priority => 20,
22
+
23
+ queue.create(:name => _('Create monitoring object for %s') % self, :priority => 20,
20
24
  :action => [self, :setMonitoring])
21
25
  end
22
26
 
23
27
  def queue_monitoring_update
24
28
  return unless monitoring_update_required?(monitoring_object[:attrs], monitoring_attributes)
29
+
25
30
  Rails.logger.debug('Detected a change to the monitoring object is required.')
26
- if ::Monitoring.create_action?(:create)
27
- queue.create(:name => _('Monitoring update for %s') % old, :priority => 2,
28
- :action => [self, :setMonitoringUpdate])
29
- end
31
+ return unless ::Monitoring.create_action?(:create)
32
+
33
+ queue.create(:name => _('Monitoring update for %s') % old, :priority => 2,
34
+ :action => [self, :setMonitoringUpdate])
30
35
  end
31
36
 
32
37
  def queue_monitoring_destroy
33
38
  return unless monitored? && errors.empty?
39
+
34
40
  if ::Monitoring.delete_action?(:delete)
35
- queue.create(:name => _('Removing monitoring object for %s') % self, :priority => 2,
41
+ queue.create(:name => _('Removing monitoring object for %s') % self, :priority => 2,
36
42
  :action => [self, :delMonitoring])
37
43
  end
38
- if ::Monitoring.delete_action?(:downtime)
39
- queue.create(:name => _('Set monitoring downtime for %s') % self, :priority => 2,
40
- :action => [self, :setMonitoringDowntime])
41
- end
44
+ return unless ::Monitoring.delete_action?(:downtime)
45
+
46
+ queue.create(:name => _('Set monitoring downtime for %s') % self, :priority => 2,
47
+ :action => [self, :setMonitoringDowntime])
42
48
  end
43
49
 
44
50
  def setMonitoring
45
51
  Rails.logger.info "Adding Monitoring object for #{name}"
46
52
  monitoring.create_host(self)
47
- rescue => e
53
+ rescue StandardError => e
48
54
  failure format(_("Failed to create a monitoring object %{name}: %{message}\n "), :name => name, :message => e.message), e
49
55
  end
50
56
 
51
57
  def delMonitoring
52
58
  Rails.logger.info "Deleting Monitoring object for #{name}"
53
59
  monitoring.delete_host(self)
54
- rescue => e
60
+ rescue StandardError => e
55
61
  failure format(_("Failed to delete a monitoring object %{name}: %{message}\n "), :name => name, :message => e.message), e
56
62
  end
57
63
 
58
64
  def setMonitoringUpdate
59
65
  Rails.logger.info "Updating Monitoring object for #{name}"
60
66
  monitoring.update_host(self)
61
- rescue => e
67
+ rescue StandardError => e
62
68
  failure format(_("Failed to update a monitoring object %{name}: %{message}\n "), :name => name, :message => e.message), e
63
69
  end
64
70
 
@@ -67,14 +73,14 @@ module Orchestration::Monitoring
67
73
  def setMonitoringDowntime
68
74
  Rails.logger.info "Setting Monitoring downtime for #{name}"
69
75
  monitoring.set_downtime_host(self, monitoring_downtime_defaults)
70
- rescue => e
76
+ rescue StandardError => e
71
77
  failure format(_("Failed to set a monitoring downtime for %{name}: %{message}\n "), :name => name, :message => e.message), e
72
78
  end
73
79
 
74
80
  def delMonitoringDowntime
75
81
  Rails.logger.info "Deleting Monitoring downtime for #{name}"
76
82
  monitoring.del_downtime_host(self, monitoring_downtime_defaults)
77
- rescue => e
83
+ rescue StandardError => e
78
84
  failure format(_("Failed to set a monitoring downtime for %{name}: %{message}\n "), :name => name, :message => e.message), e
79
85
  end
80
86
 
@@ -97,6 +103,7 @@ module Orchestration::Monitoring
97
103
 
98
104
  def monitoring_update_required?(actual_attrs, desired_attrs)
99
105
  return true if actual_attrs.deep_symbolize_keys.keys != desired_attrs.deep_symbolize_keys.keys
106
+
100
107
  actual_attrs.deep_symbolize_keys.merge(desired_attrs.deep_symbolize_keys) do |k, actual_v, desired_v|
101
108
  if actual_v.is_a?(Hash) && desired_v.is_a?(Hash)
102
109
  return true if monitoring_update_required?(actual_v, desired_v)