foreman_monitoring 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e703d5ad965ed3aecba3fee0dc31a7a2c80a84eab893392484555fda8ba8ab1
4
- data.tar.gz: 6dce2771bea3df536cb244aadfbad6483387d71157c4b70d5cbe0256b27f508c
3
+ metadata.gz: bba72edc0a48bb00f5818a0662ef643ea892cef4f457b474fd35332471bf1751
4
+ data.tar.gz: b62364ba84ac51878993cd2d6d7be654cfb10aa2c2a565b2ec71f6dc38f933a1
5
5
  SHA512:
6
- metadata.gz: e3c24e7c223b0103333d21717636f338176cb2756028d60943c8e6276ffaa366de039dec2b5afd527b5f50464737194b6cc6d5e357f9696d6b56aff167b7fc6e
7
- data.tar.gz: ca91aa5af43494a254fbe03bd13cb4e4e30dccfdab8e47befb8252f97b2cce1bd8ab850739993d1675d194f3253a8b5825b248f6d95cc75b6b7c4915252356eb
6
+ metadata.gz: d1d0834a1dc76d2009dc1bd1bbd35c0fbcfc166e1b1206c87a3ba1fd7d8543c693d22550cd899129b41d9dcbf76d0a379ab7c0ef6a7d83e2ffa1960c0b8ec3a2
7
+ data.tar.gz: 8715c42a9d55a3f491a860373c74dcda03351be2752a14e2dc798781f1ab807b55ff332822ead436637b1d479702920cbe9c19b6b30bff4844418acbe3d8611f
data/README.md CHANGED
@@ -34,6 +34,9 @@ touch ~foreman/tmp/restart.txt
34
34
  | --------------- | --------------:|
35
35
  | >= 1.15 | ~> 0.1 |
36
36
  | >= 1.17 | ~> 1.0 |
37
+ | >= 2.0 | ~> 2.0 |
38
+ | >= 2.2 | ~> 2.1 |
39
+ | >= 3.0 | ~> 3.0 |
37
40
 
38
41
  # Usage
39
42
 
@@ -7,6 +7,7 @@ module ForemanMonitoring
7
7
  module ClassMethods
8
8
  def authorize_host_by_client_cert(actions, _options = {})
9
9
  skip_before_action :require_login, :only => actions, :raise => false
10
+ skip_before_action :check_user_enabled, :only => actions, :raise => false
10
11
  skip_before_action :authorize, :only => actions
11
12
  skip_before_action :verify_authenticity_token, :only => actions
12
13
  skip_before_action :set_taxonomy, :only => actions, :raise => false
@@ -56,7 +56,7 @@ module ForemanMonitoring
56
56
  end
57
57
 
58
58
  def monitoring_attributes
59
- {
59
+ attributes = {
60
60
  :ip => ip,
61
61
  :ip6 => ip6,
62
62
  :architecture => architecture.try(:name),
@@ -69,9 +69,12 @@ module ForemanMonitoring
69
69
  :organization => organization.try(:name),
70
70
  :location => location.try(:name),
71
71
  :comment => comment,
72
- :environment => environment.try(:to_s),
73
72
  :owner_name => owner.try(:name)
74
73
  }
74
+
75
+ attributes[:environment] = environment.try(:to_s) if defined?(ForemanPuppet)
76
+
77
+ attributes
75
78
  end
76
79
 
77
80
  private
@@ -3,13 +3,13 @@
3
3
  class RenameDowntimeHostPermission < ActiveRecord::Migration[5.2]
4
4
  def up
5
5
  # rubocop:disable Rails/SkipsModelValidations
6
- Permission.where(name: 'manage_host_downtimes').update_all(name: 'manage_downtime_hosts')
6
+ Permission.where(name: 'manage_host_downtimes').update_all(name: 'manage_downtime_hosts') if table_exists?(:permissions)
7
7
  # rubocop:enable Rails/SkipsModelValidations
8
8
  end
9
9
 
10
10
  def down
11
11
  # rubocop:disable Rails/SkipsModelValidations
12
- Permission.where(name: 'manage_downtime_hosts').update_all(name: 'manage_host_downtimes')
12
+ Permission.where(name: 'manage_downtime_hosts').update_all(name: 'manage_host_downtimes') if table_exists?(:permissions)
13
13
  # rubocop:enable Rails/SkipsModelValidations
14
14
  end
15
15
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FixMonitoringSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
4
+ def up
5
+ # rubocop:disable Rails/SkipsModelValidations
6
+ Setting.where(category: 'Setting::Monitoring').update_all(category: 'Setting')
7
+ # rubocop:enable Rails/SkipsModelValidations
8
+ end
9
+ end
@@ -18,19 +18,31 @@ module ForemanMonitoring
18
18
  end
19
19
  end
20
20
 
21
- initializer 'foreman_monitoring.load_default_settings',
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
29
- end
30
-
31
21
  initializer 'foreman_monitoring.register_plugin', :before => :finisher_hook do |_app|
32
22
  Foreman::Plugin.register :foreman_monitoring do
33
- requires_foreman '>= 2.0'
23
+ requires_foreman '>= 3.0'
24
+
25
+ settings do
26
+ category(:monitoring, N_('Monitoring')) do
27
+ setting('monitoring_affect_global_status',
28
+ type: :boolean,
29
+ description: N_("Monitoring status will affect a host's global status when enabled"),
30
+ default: true,
31
+ full_name: N_('Monitoring status should affect global status'))
32
+ setting('monitoring_create_action',
33
+ type: :string,
34
+ description: N_('What action should be taken when a host is created'),
35
+ default: 'create',
36
+ full_name: N_('Host Create Action'),
37
+ collection: proc { ::Monitoring::CREATE_ACTIONS })
38
+ setting('monitoring_delete_action',
39
+ type: :string,
40
+ description: N_('What action should be taken when a host is deleted'),
41
+ default: 'delete',
42
+ full_name: N_('Host Delete Action'),
43
+ collection: proc { ::Monitoring::DELETE_ACTIONS })
44
+ end
45
+ end
34
46
 
35
47
  apipie_documented_controllers ["#{ForemanMonitoring::Engine.root}/app/controllers/api/v2/*.rb"]
36
48
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanMonitoring
4
- VERSION = '2.0.0'
4
+ VERSION = '3.0.0'
5
5
  end
@@ -8,7 +8,7 @@ class Api::V2::DowntimeControllerTest < ActionController::TestCase
8
8
  context 'with user authentication' do
9
9
  context '#create' do
10
10
  test 'should deny access' do
11
- put :create
11
+ post :create
12
12
  assert_response :forbidden
13
13
  end
14
14
  end
@@ -29,7 +29,7 @@ class Api::V2::DowntimeControllerTest < ActionController::TestCase
29
29
 
30
30
  context '#create' do
31
31
  test 'should create downtime' do
32
- put :create
32
+ post :create
33
33
  assert_response :success
34
34
  end
35
35
  end
@@ -37,13 +37,13 @@ class Api::V2::DowntimeControllerTest < ActionController::TestCase
37
37
  context '#create with duration' do
38
38
  test 'should create downtime with given duration' do
39
39
  Host::Managed.any_instance.expects(:downtime_host).with { |params| params[:end_time] - params[:start_time] == 3600 }
40
- put :create, params: { duration: 3600 }
40
+ post :create, params: { duration: 3600 }
41
41
  assert_response :success
42
42
  end
43
43
 
44
44
  test 'should create downtime with given duration as string' do
45
45
  Host::Managed.any_instance.expects(:downtime_host).with { |params| params[:end_time] - params[:start_time] == 3600 }
46
- put :create, params: { duration: '3600' }
46
+ post :create, params: { duration: '3600' }
47
47
  assert_response :success
48
48
  end
49
49
  end
@@ -51,7 +51,7 @@ class Api::V2::DowntimeControllerTest < ActionController::TestCase
51
51
  context '#create with reason' do
52
52
  test 'should create downtime with given reason' do
53
53
  Host::Managed.any_instance.expects(:downtime_host).with { |params| params[:comment] == 'In testing' }
54
- put :create, params: { reason: 'In testing' }
54
+ post :create, params: { reason: 'In testing' }
55
55
  assert_response :success
56
56
  end
57
57
  end
@@ -11,10 +11,6 @@ FactoryBot.reload
11
11
  # Foreman's setup doesn't handle cleaning up for Minitest::Spec
12
12
  DatabaseCleaner.strategy = :transaction
13
13
 
14
- def setup_settings
15
- Setting::Monitoring.load_defaults
16
- end
17
-
18
14
  def disable_monitoring_orchestration
19
15
  ProxyAPI::Monitoring.any_instance.stubs(:query_host).returns({})
20
16
  end
@@ -4,7 +4,6 @@ require 'test_plugin_helper'
4
4
 
5
5
  class MonitoringStatusTest < ActiveSupport::TestCase
6
6
  setup do
7
- setup_settings
8
7
  disable_monitoring_orchestration
9
8
  end
10
9
 
@@ -5,7 +5,6 @@ require 'test_plugin_helper'
5
5
  class HostTest < ActiveSupport::TestCase
6
6
  setup do
7
7
  User.current = FactoryBot.build(:user, :admin)
8
- setup_settings
9
8
  disable_orchestration
10
9
  disable_monitoring_orchestration
11
10
  end
@@ -5,7 +5,6 @@ require 'test_plugin_helper'
5
5
  class MonitoringResultTest < ActiveSupport::TestCase
6
6
  setup do
7
7
  User.current = FactoryBot.build(:user, :admin)
8
- setup_settings
9
8
  disable_orchestration
10
9
  disable_monitoring_orchestration
11
10
  end
@@ -5,7 +5,6 @@ require 'test_plugin_helper'
5
5
  class MonitoringTest < ActiveSupport::TestCase
6
6
  setup do
7
7
  User.current = FactoryBot.build(:user, :admin)
8
- setup_settings
9
8
  disable_monitoring_orchestration
10
9
  end
11
10
 
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: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-11 00:00:00.000000000 Z
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -115,7 +115,6 @@ files:
115
115
  - app/models/concerns/orchestration/monitoring.rb
116
116
  - app/models/host_status/monitoring_status.rb
117
117
  - app/models/monitoring_result.rb
118
- - app/models/setting/monitoring.rb
119
118
  - app/overrides/add_host_monitoring_result_tab.rb
120
119
  - app/overrides/add_host_multiple_power_set_downtime_checkbox.rb
121
120
  - app/overrides/add_host_set_downtime_modal.rb
@@ -131,6 +130,7 @@ files:
131
130
  - db/migrate/20160817135723_create_monitoring_results.rb
132
131
  - db/migrate/20161220201510_add_monitoring_proxy_id_to_host_and_hostgroup.rb
133
132
  - db/migrate/201910180900_rename_downtime_host_permission.rb
133
+ - db/migrate/20221026065954_fix_monitoring_settings_category_to_dsl.rb
134
134
  - db/seeds.d/60-monitoring_proxy_feature.rb
135
135
  - lib/foreman_monitoring.rb
136
136
  - lib/foreman_monitoring/engine.rb
@@ -171,20 +171,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.1.2
174
+ rubygems_version: 3.2.33
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Foreman plugin for monitoring system integration.
178
178
  test_files:
179
- - test/unit/host_test.rb
180
- - test/unit/monitoring_result_test.rb
181
- - test/unit/host_status/monitoring_status_test.rb
182
- - test/unit/monitoring_test.rb
183
- - test/factories/smart_proxy.rb
184
- - test/factories/monitoring_results.rb
179
+ - test/controllers/api/v2/downtime_controller_test.rb
185
180
  - test/factories/feature.rb
186
181
  - test/factories/host.rb
182
+ - test/factories/monitoring_results.rb
183
+ - test/factories/smart_proxy.rb
184
+ - test/functional/hosts_controller_test.rb
187
185
  - test/lib/proxy_api/monitoring_test.rb
188
186
  - test/test_plugin_helper.rb
189
- - test/controllers/api/v2/downtime_controller_test.rb
190
- - test/functional/hosts_controller_test.rb
187
+ - test/unit/host_status/monitoring_status_test.rb
188
+ - test/unit/host_test.rb
189
+ - test/unit/monitoring_result_test.rb
190
+ - test/unit/monitoring_test.rb
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Setting
4
- class Monitoring < ::Setting
5
- def self.default_settings
6
- [
7
- set('monitoring_affect_global_status',
8
- _("Monitoring status will affect a host's global status when enabled"),
9
- true, N_('Monitoring status should affect global status')),
10
- set('monitoring_create_action',
11
- _('What action should be taken when a host is created'),
12
- 'create', N_('Host Create Action'), nil, :collection => proc { ::Monitoring::CREATE_ACTIONS }),
13
- set('monitoring_delete_action',
14
- _('What action should be taken when a host is deleted'),
15
- 'delete', N_('Host Delete Action'), nil, :collection => proc { ::Monitoring::DELETE_ACTIONS })
16
- ]
17
- end
18
-
19
- def self.load_defaults
20
- # Check the table exists
21
- return unless super
22
-
23
- self.transaction do
24
- default_settings.each { |s| self.create! s.update(:category => 'Setting::Monitoring') }
25
- end
26
-
27
- true
28
- end
29
-
30
- def self.humanized_category
31
- N_('Monitoring')
32
- end
33
- end
34
- end