foreman_monitoring 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6ec30b6e40aad99c7da94b66100590381d300289
4
- data.tar.gz: ef1bb20065f0c5b11544f64babe2ab0c8faa3b6d
2
+ SHA256:
3
+ metadata.gz: f742aa658a66234e28555d6dbba4beca116e6ba3d49db3c02898bd7cc295a5d9
4
+ data.tar.gz: f11b41bb8dc37e78431df10c3fc255f7680039293e7e0c9ff0268a4c975d49ef
5
5
  SHA512:
6
- metadata.gz: 92fc91db5150b641f8a169fce2468695a4a64e84ec02235259385864deb0c1b7309e49853fb297a88f9e37d143371f88d6aa446c37abebc8d8a2172433a725d1
7
- data.tar.gz: 9306c61272155529c75cd7c90b9a115a5d931b11455f0313fa057de42ac565a3a301023cbd95fc8fa744d913e570ea8a8ad3c689f042c45aa5a6d4dc00d944e2
6
+ metadata.gz: f7dbdfc58ea1b7669eefff4b603ccc4f813b87a3aadbb4cd4a48ad86de3899403b440709d1b2a1f9145dc5b4b4487875ad0a33de031142d70e47d139278043d1
7
+ data.tar.gz: 39f27d2331c23bd24392d1abcaa47dc4ec9757463a27503518d501581ba2b276acc2528fa58b2e76f632f58ac00cb91801060d09a821a9853e0754ced75342dc
@@ -1,17 +1,18 @@
1
1
  module ForemanMonitoring
2
2
  module HostsControllerExtensions
3
- def self.prepended(base)
4
- base.class_eval do
5
- before_action :find_resource_with_monitoring, :only => [:downtime]
6
- before_action :find_multiple_with_monitoring, :only => %i[select_multiple_downtime update_multiple_downtime
7
- select_multiple_monitoring_proxy update_multiple_monitoring_proxy]
8
- before_action :validate_host_downtime_params, :only => [:downtime]
9
- before_action :validate_hosts_downtime_params, :only => [:update_multiple_downtime]
10
- before_action :validate_multiple_monitoring_proxy, :only => :update_multiple_monitoring_proxy
11
-
12
- alias_method :find_resource_with_monitoring, :find_resource
13
- alias_method :find_multiple_with_monitoring, :find_multiple
14
- end
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :find_resource_with_monitoring, :only => [:downtime]
7
+ before_action :find_multiple_with_monitoring, :only => %i[select_multiple_downtime update_multiple_downtime
8
+ select_multiple_monitoring_proxy update_multiple_monitoring_proxy]
9
+ before_action :validate_host_downtime_params, :only => [:downtime]
10
+ before_action :validate_hosts_downtime_params, :only => [:update_multiple_downtime]
11
+ before_action :validate_multiple_monitoring_proxy, :only => :update_multiple_monitoring_proxy
12
+
13
+ alias_method :find_resource_with_monitoring, :find_resource
14
+ alias_method :find_multiple_with_monitoring, :find_multiple
15
+ alias_method_chain :update_multiple_power_state, :monitoring
15
16
  end
16
17
 
17
18
  def downtime
@@ -64,7 +65,7 @@ module ForemanMonitoring
64
65
  update_multiple_proxy(_('Monitoring'), :monitoring_proxy=)
65
66
  end
66
67
 
67
- def update_multiple_power_state
68
+ def update_multiple_power_state_with_monitoring
68
69
  options = {
69
70
  :comment => 'Power state changed in Foreman',
70
71
  :author => "Foreman User #{User.current}",
@@ -85,7 +86,7 @@ module ForemanMonitoring
85
86
  end
86
87
  end
87
88
  end
88
- super
89
+ update_multiple_power_state_without_monitoring
89
90
  end
90
91
 
91
92
  private
@@ -1,17 +1,18 @@
1
1
  module ForemanMonitoring
2
2
  module HostsHelperExt
3
- def multiple_actions
4
- 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
11
- actions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ alias_method_chain :host_title_actions, :monitoring
7
+ alias_method_chain :multiple_actions, :monitoring
8
+ end
9
+
10
+ def multiple_actions_with_monitoring
11
+ return multiple_actions_without_monitoring unless authorized_for(:controller => :hosts, :action => :select_multiple_downtime)
12
+ multiple_actions_without_monitoring + [[_('Set downtime'), select_multiple_downtime_hosts_path], [_('Change Monitoring Proxy'), select_multiple_monitoring_proxy_hosts_path]]
12
13
  end
13
14
 
14
- def host_title_actions(host)
15
+ def host_title_actions_with_monitoring(host)
15
16
  title_actions(
16
17
  button_group(
17
18
  display_link_if_authorized(_('Downtime'),
@@ -26,7 +27,7 @@ module ForemanMonitoring
26
27
  :target => '#set_host_downtime' })
27
28
  )
28
29
  )
29
- super
30
+ host_title_actions_without_monitoring(host)
30
31
  end
31
32
 
32
33
  def host_monitoring_result_icon_class(result)
@@ -1,13 +1,15 @@
1
1
  module ForemanMonitoring
2
2
  module HostExtensions
3
- def self.prepended(base)
4
- base.class_eval do
5
- include Orchestration::Monitoring
3
+ extend ActiveSupport::Concern
4
+ included do
5
+ include Orchestration::Monitoring
6
6
 
7
- after_build :downtime_host_build
7
+ after_build :downtime_host_build
8
8
 
9
- has_many :monitoring_results, :dependent => :destroy, :foreign_key => 'host_id'
10
- end
9
+ alias_method_chain :smart_proxy_ids, :monitoring_proxy
10
+ alias_method_chain :hostgroup_inherited_attributes, :monitoring
11
+
12
+ has_many :monitoring_results, :dependent => :destroy, :foreign_key => 'host_id'
11
13
  end
12
14
 
13
15
  def monitoring_status(options = {})
@@ -40,12 +42,12 @@ module ForemanMonitoring
40
42
  monitoring_proxy.present?
41
43
  end
42
44
 
43
- def hostgroup_inherited_attributes
44
- super + ['monitoring_proxy_id']
45
+ def hostgroup_inherited_attributes_with_monitoring
46
+ hostgroup_inherited_attributes_without_monitoring + ['monitoring_proxy_id']
45
47
  end
46
48
 
47
- def smart_proxy_ids
48
- ids = super
49
+ def smart_proxy_ids_with_monitoring_proxy
50
+ ids = smart_proxy_ids_without_monitoring_proxy
49
51
  [monitoring_proxy, hostgroup.try(:monitoring_proxy)].compact.each do |proxy|
50
52
  ids << proxy.id
51
53
  end
@@ -71,10 +71,10 @@ module ForemanMonitoring
71
71
 
72
72
  config.to_prepare do
73
73
  begin
74
- ::Host::Managed.send(:prepend, ForemanMonitoring::HostExtensions)
75
- ::Hostgroup.send(:include, ForemanMonitoring::HostgroupExtensions)
76
- ::HostsHelper.send(:prepend, ForemanMonitoring::HostsHelperExt)
77
- ::HostsController.send(:prepend, ForemanMonitoring::HostsControllerExtensions)
74
+ ::Host::Managed.send :include, ForemanMonitoring::HostExtensions
75
+ ::Hostgroup.send :include, ForemanMonitoring::HostgroupExtensions
76
+ ::HostsHelper.send(:include, ForemanMonitoring::HostsHelperExt)
77
+ ::HostsController.send :include, ForemanMonitoring::HostsControllerExtensions
78
78
  rescue => e
79
79
  Rails.logger.warn "ForemanMonitoring: skipping engine hook (#{e})"
80
80
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanMonitoring
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_monitoring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2018-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.6.12
128
+ rubygems_version: 2.7.3
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Foreman plugin for monitoring system integration.