foreman_monitoring 0.1.2 → 2.1.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.
- checksums.yaml +4 -4
- data/README.md +16 -7
- data/Rakefile +0 -0
- data/app/controllers/api/v2/downtime_controller.rb +63 -0
- data/app/controllers/api/v2/monitoring_results_controller.rb +5 -4
- data/app/controllers/concerns/foreman_monitoring/find_host_by_client_cert.rb +60 -0
- data/app/controllers/concerns/foreman_monitoring/hosts_controller_extensions.rb +21 -20
- data/app/helpers/concerns/foreman_monitoring/hosts_helper_ext.rb +16 -19
- data/app/lib/proxy_api/monitoring.rb +9 -6
- data/app/models/concerns/foreman_monitoring/host_extensions.rb +15 -14
- data/app/models/concerns/foreman_monitoring/hostgroup_extensions.rb +7 -3
- data/app/models/concerns/orchestration/monitoring.rb +22 -15
- data/app/models/host_status/monitoring_status.rb +7 -4
- data/app/models/monitoring_result.rb +13 -6
- data/app/models/setting/monitoring.rb +4 -2
- data/app/overrides/add_host_monitoring_result_tab.rb +8 -6
- data/app/overrides/add_host_multiple_power_set_downtime_checkbox.rb +5 -3
- data/app/overrides/add_host_set_downtime_modal.rb +4 -2
- data/app/services/monitoring.rb +3 -0
- data/app/views/hosts/_downtime_fields.html.erb +2 -2
- data/app/views/monitoring_results/_host_tab_pane.html.erb +2 -2
- data/config/routes.rb +3 -0
- data/db/migrate/20160817135723_create_monitoring_results.rb +5 -1
- data/db/migrate/20161220201510_add_monitoring_proxy_id_to_host_and_hostgroup.rb +3 -1
- data/db/migrate/201910180900_rename_downtime_host_permission.rb +15 -0
- data/db/seeds.d/60-monitoring_proxy_feature.rb +2 -0
- data/lib/foreman_monitoring.rb +2 -0
- data/lib/foreman_monitoring/engine.rb +32 -28
- data/lib/foreman_monitoring/version.rb +3 -1
- data/lib/tasks/foreman_monitoring_tasks.rake +5 -5
- data/locale/gemspec.rb +2 -0
- data/test/controllers/api/v2/downtime_controller_test.rb +73 -0
- data/test/factories/feature.rb +4 -2
- data/test/factories/host.rb +6 -4
- data/test/factories/monitoring_results.rb +9 -7
- data/test/factories/smart_proxy.rb +3 -1
- data/test/functional/hosts_controller_test.rb +65 -52
- data/test/lib/proxy_api/monitoring_test.rb +16 -14
- data/test/test_plugin_helper.rb +5 -3
- data/test/unit/host_status/monitoring_status_test.rb +18 -16
- data/test/unit/host_test.rb +6 -4
- data/test/unit/monitoring_result_test.rb +75 -0
- data/test/unit/monitoring_test.rb +5 -3
- metadata +62 -14
@@ -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
|
7
|
-
|
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
|
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
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
41
|
+
queue.create(:name => _('Removing monitoring object for %s') % self, :priority => 2,
|
36
42
|
:action => [self, :delMonitoring])
|
37
43
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module HostStatus
|
2
4
|
class MonitoringStatus < HostStatus::Status
|
3
5
|
OK = 0
|
@@ -11,9 +13,10 @@ module HostStatus
|
|
11
13
|
|
12
14
|
def to_status(_options = {})
|
13
15
|
state = OK
|
14
|
-
grouped_results.
|
16
|
+
grouped_results.each_key do |resultset|
|
15
17
|
result, downtime, acknowledged = resultset
|
16
18
|
next if downtime
|
19
|
+
|
17
20
|
result = map_result_to_status(result)
|
18
21
|
result = WARNING if acknowledged || result == UNKNOWN
|
19
22
|
state = result if result > state
|
@@ -23,6 +26,7 @@ module HostStatus
|
|
23
26
|
|
24
27
|
def to_global(_options = {})
|
25
28
|
return HostStatus::Global::OK unless should_affect_global_status?
|
29
|
+
|
26
30
|
case status
|
27
31
|
when OK
|
28
32
|
HostStatus::Global::OK
|
@@ -60,9 +64,7 @@ module HostStatus
|
|
60
64
|
host.monitoring_results.any?
|
61
65
|
end
|
62
66
|
|
63
|
-
|
64
|
-
host.monitored?
|
65
|
-
end
|
67
|
+
delegate :monitored?, to: :host, prefix: true
|
66
68
|
|
67
69
|
def should_affect_global_status?
|
68
70
|
Setting[:monitoring_affect_global_status]
|
@@ -76,6 +78,7 @@ module HostStatus
|
|
76
78
|
|
77
79
|
def map_result_to_status(result)
|
78
80
|
return result if Rails::VERSION::MAJOR < 5
|
81
|
+
|
79
82
|
case result.to_sym
|
80
83
|
when :ok
|
81
84
|
OK
|
@@ -1,10 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MonitoringResult < ApplicationRecord
|
4
|
+
enum :result => { :ok => 0, :warning => 1, :critical => 2, :unknown => 3 }
|
3
5
|
|
4
6
|
belongs_to_host
|
5
7
|
|
8
|
+
# rubocop:disable Metrics/AbcSize
|
6
9
|
def self.import(result)
|
7
|
-
host = Host.
|
10
|
+
host = Host.find_by(name: result[:host])
|
8
11
|
|
9
12
|
if host.nil?
|
10
13
|
logger.error "Unable to find host #{result[:host]}"
|
@@ -27,21 +30,25 @@ class MonitoringResult < ActiveRecord::Base
|
|
27
30
|
end
|
28
31
|
|
29
32
|
created = MonitoringResult.where(:host => host, :service => result[:service]).first_or_create
|
30
|
-
|
31
|
-
|
33
|
+
# rubocop:disable Rails/Date
|
34
|
+
if created.timestamp.blank? || updates[:timestamp].blank? || (created.timestamp.to_time - updates[:timestamp].to_time) < 2
|
35
|
+
created.update(updates)
|
32
36
|
|
33
37
|
if created.persisted?
|
34
38
|
logger.info("Imported monitoring result for #{host} in #{(Time.now.utc - start_time).round(2)} seconds")
|
35
|
-
host.
|
39
|
+
host.get_status(::HostStatus::MonitoringStatus).refresh!
|
36
40
|
end
|
37
41
|
else
|
38
42
|
logger.debug "Skipping monitoring result import for #{host} as it is older than what we have."
|
39
43
|
end
|
44
|
+
# rubocop:enable Rails/Date
|
40
45
|
end
|
46
|
+
# rubocop:enable Metrics/AbcSize
|
41
47
|
|
42
48
|
def status
|
43
49
|
return :ok if downtime
|
44
50
|
return :warning if acknowledged
|
51
|
+
|
45
52
|
result.to_sym
|
46
53
|
end
|
47
54
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Setting
|
2
4
|
class Monitoring < ::Setting
|
3
5
|
def self.default_settings
|
@@ -7,10 +9,10 @@ class Setting
|
|
7
9
|
true, N_('Monitoring status should affect global status')),
|
8
10
|
set('monitoring_create_action',
|
9
11
|
_('What action should be taken when a host is created'),
|
10
|
-
'create', N_('Host Create Action'), nil,
|
12
|
+
'create', N_('Host Create Action'), nil, :collection => proc { ::Monitoring::CREATE_ACTIONS }),
|
11
13
|
set('monitoring_delete_action',
|
12
14
|
_('What action should be taken when a host is deleted'),
|
13
|
-
'delete', N_('Host Delete Action'), nil,
|
15
|
+
'delete', N_('Host Delete Action'), nil, :collection => proc { ::Monitoring::DELETE_ACTIONS })
|
14
16
|
]
|
15
17
|
end
|
16
18
|
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(:virtual_path => 'hosts/show',
|
4
|
+
:name => 'add_monitoring_result_tab',
|
3
5
|
:insert_bottom => 'ul.nav-tabs',
|
4
|
-
:partial
|
6
|
+
:partial => 'monitoring_results/host_tab')
|
5
7
|
|
6
|
-
Deface::Override.new(:virtual_path
|
7
|
-
:name
|
8
|
+
Deface::Override.new(:virtual_path => 'hosts/show',
|
9
|
+
:name => 'add_monitoring_result_tab_pane',
|
8
10
|
:insert_bottom => 'div.tab-content',
|
9
|
-
:partial
|
11
|
+
:partial => 'monitoring_results/host_tab_pane')
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(:virtual_path => 'hosts/select_multiple_power_state',
|
4
|
+
:name => 'add_host_multiple_power_set_downtime_checkbox',
|
3
5
|
:insert_before => "erb[silent]:contains('end')",
|
4
|
-
:partial
|
6
|
+
:partial => 'hosts/host_downtime_checkbox')
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(:virtual_path => 'hosts/show',
|
4
|
+
:name => 'add_monitoring_set_downtime_modal',
|
3
5
|
:insert_after => 'div#review_before_build',
|
4
6
|
:partial => 'hosts/set_host_downtime')
|
data/app/services/monitoring.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Monitoring
|
2
4
|
CREATE_ACTIONS = {
|
3
5
|
'none' => _('None'),
|
@@ -49,6 +51,7 @@ class Monitoring
|
|
49
51
|
def query_host(host)
|
50
52
|
result = proxy_api.query_host(host.name)
|
51
53
|
return {} unless result
|
54
|
+
|
52
55
|
{
|
53
56
|
:attrs => result
|
54
57
|
}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<%= text_f f, :comment, :size => "col-md-5", :label => _('Comment'), :help_inline => _('Short description that explains why the downtime was set.'), :required => true %>
|
2
|
-
<%=
|
3
|
-
<%=
|
2
|
+
<%= monitoring_datetime_f f, :starttime, :size => "col-md-5", :label => _('Starttime'), :help_inline => _('Time when the downtime should start.'), :min => DateTime.now, :value => Time.current, :required => true %>
|
3
|
+
<%= monitoring_datetime_f f, :endtime, :size => "col-md-5", :label => _('Endtime'), :help_inline => _('Time when the downtime should end.'), :value => Time.current.advance(:hours => 2), :required => true %>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%- if authorized_for(:permission => 'view_monitoring_results', :auth_object => @host) && @host.monitored? -%>
|
2
2
|
<div class="tab-pane" id="monitoring">
|
3
3
|
<% if @host.monitoring_results.any? %>
|
4
|
-
<table class="
|
5
|
-
<thead
|
4
|
+
<table class="<%= table_css_classes %>">
|
5
|
+
<thead>
|
6
6
|
<tr>
|
7
7
|
<th colspan="2">Monitoring</th>
|
8
8
|
</tr>
|
data/config/routes.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Rails.application.routes.draw do
|
2
4
|
namespace :api, :defaults => { :format => 'json' } do
|
3
5
|
scope '(:apiv)', :module => :v2,
|
@@ -5,6 +7,7 @@ Rails.application.routes.draw do
|
|
5
7
|
:apiv => /v1|v2/,
|
6
8
|
:constraints => ApiConstraints.new(:version => 2) do
|
7
9
|
resources :monitoring_results, :only => [:create]
|
10
|
+
resources :downtime, :only => [:create]
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateMonitoringResults < ActiveRecord::Migration[4.2]
|
2
4
|
def change
|
5
|
+
# rubocop:disable Rails/CreateTableWithTimestamps
|
3
6
|
create_table :monitoring_results do |t|
|
4
7
|
t.references :host, :null => false
|
5
8
|
t.string :service, :null => false
|
@@ -8,5 +11,6 @@ class CreateMonitoringResults < ActiveRecord::Migration
|
|
8
11
|
t.boolean :acknowledged, :default => false, :null => false
|
9
12
|
t.datetime :timestamp
|
10
13
|
end
|
14
|
+
# rubocop:enable Rails/CreateTableWithTimestamps
|
11
15
|
end
|
12
16
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddMonitoringProxyIdToHostAndHostgroup < ActiveRecord::Migration[4.2]
|
2
4
|
def self.up
|
3
5
|
add_column :hosts, :monitoring_proxy_id, :integer
|
4
6
|
add_column :hostgroups, :monitoring_proxy_id, :integer
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class RenameDowntimeHostPermission < ActiveRecord::Migration[5.2]
|
4
|
+
def up
|
5
|
+
# rubocop:disable Rails/SkipsModelValidations
|
6
|
+
Permission.where(name: 'manage_host_downtimes').update_all(name: 'manage_downtime_hosts') if table_exists?(:permissions)
|
7
|
+
# rubocop:enable Rails/SkipsModelValidations
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
# rubocop:disable Rails/SkipsModelValidations
|
12
|
+
Permission.where(name: 'manage_downtime_hosts').update_all(name: 'manage_host_downtimes') if table_exists?(:permissions)
|
13
|
+
# rubocop:enable Rails/SkipsModelValidations
|
14
|
+
end
|
15
|
+
end
|
data/lib/foreman_monitoring.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'deface'
|
2
4
|
|
3
5
|
module ForemanMonitoring
|
@@ -17,42 +19,44 @@ module ForemanMonitoring
|
|
17
19
|
end
|
18
20
|
|
19
21
|
initializer 'foreman_monitoring.load_default_settings',
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
22
|
+
:before => :load_config_initializers do |_app|
|
23
|
+
setting_table_exists = begin
|
24
|
+
Setting.table_exists?
|
25
|
+
rescue StandardError
|
26
|
+
false
|
27
|
+
end
|
28
|
+
require_dependency File.expand_path('../../app/models/setting/monitoring.rb', __dir__) if setting_table_exists
|
28
29
|
end
|
29
30
|
|
30
31
|
initializer 'foreman_monitoring.register_plugin', :before => :finisher_hook do |_app|
|
31
32
|
Foreman::Plugin.register :foreman_monitoring do
|
32
|
-
requires_foreman '>=
|
33
|
+
requires_foreman '>= 2.2'
|
33
34
|
|
34
35
|
apipie_documented_controllers ["#{ForemanMonitoring::Engine.root}/app/controllers/api/v2/*.rb"]
|
35
36
|
|
36
37
|
security_block :foreman_monitoring do
|
37
38
|
permission :view_monitoring_results,
|
38
|
-
|
39
|
-
|
40
|
-
permission :
|
41
|
-
|
42
|
-
|
39
|
+
{},
|
40
|
+
:resource_type => 'Host'
|
41
|
+
permission :manage_downtime_hosts,
|
42
|
+
{ :hosts => [:downtime, :select_multiple_downtime, :update_multiple_downtime], :'api/v2/downtime' => [:create] },
|
43
|
+
:resource_type => 'Host'
|
43
44
|
permission :upload_monitoring_results,
|
44
|
-
|
45
|
-
permission :edit_hosts,
|
46
|
-
{ :hosts => [:select_multiple_monitoring_proxy, :update_multiple_monitoring_proxy] },
|
47
|
-
:resource_type => 'Host'
|
45
|
+
:'api/v2/monitoring_results' => [:create]
|
48
46
|
end
|
49
47
|
|
50
|
-
|
51
|
-
|
48
|
+
# Extend built in permissions
|
49
|
+
Foreman::AccessControl.permission(:edit_hosts).actions.concat [
|
50
|
+
'hosts/select_multiple_monitoring_proxy',
|
51
|
+
'hosts/update_multiple_monitoring_proxy'
|
52
|
+
]
|
53
|
+
|
54
|
+
role 'Monitoring viewer', [:view_monitoring_results], 'Role granting permissions to view monitor results'
|
55
|
+
role 'Monitoring manager', [:view_monitoring_results, :manage_downtime_hosts], 'Role granting permissions to view monitor results and manage downtimes'
|
52
56
|
|
53
57
|
register_custom_status HostStatus::MonitoringStatus
|
54
58
|
|
55
|
-
add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:monitoring_results) }
|
59
|
+
add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_results) }
|
56
60
|
|
57
61
|
monitoring_proxy_options = {
|
58
62
|
:feature => 'Monitoring',
|
@@ -65,23 +69,23 @@ module ForemanMonitoring
|
|
65
69
|
smart_proxy_for Host::Managed, :monitoring_proxy, monitoring_proxy_options
|
66
70
|
smart_proxy_for Hostgroup, :monitoring_proxy, monitoring_proxy_options
|
67
71
|
|
68
|
-
add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:monitoring_proxy) }
|
72
|
+
add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_proxy) }
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
72
76
|
config.to_prepare do
|
73
77
|
begin
|
74
|
-
::Host::Managed.
|
75
|
-
::Hostgroup.
|
76
|
-
::HostsHelper.
|
77
|
-
::HostsController.
|
78
|
-
rescue => e
|
78
|
+
::Host::Managed.prepend(ForemanMonitoring::HostExtensions)
|
79
|
+
::Hostgroup.include(ForemanMonitoring::HostgroupExtensions)
|
80
|
+
::HostsHelper.prepend(ForemanMonitoring::HostsHelperExt)
|
81
|
+
::HostsController.prepend(ForemanMonitoring::HostsControllerExtensions)
|
82
|
+
rescue StandardError => e
|
79
83
|
Rails.logger.warn "ForemanMonitoring: skipping engine hook (#{e})"
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
83
87
|
initializer 'foreman_monitoring.register_gettext', after: :load_config_initializers do |_app|
|
84
|
-
locale_dir = File.join(File.expand_path('
|
88
|
+
locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
|
85
89
|
locale_domain = 'foreman_monitoring'
|
86
90
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
87
91
|
end
|