foreman_monitoring 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/controllers/api/v2/downtime_controller.rb +3 -1
- data/app/lib/proxy_api/monitoring.rb +1 -1
- data/app/models/monitoring_result.rb +0 -2
- data/config/routes.rb +1 -1
- data/db/migrate/201910180900_rename_downtime_host_permission.rb +0 -4
- data/db/migrate/20221026065954_fix_monitoring_settings_category_to_dsl.rb +1 -3
- data/lib/foreman_monitoring/engine.rb +6 -8
- data/lib/foreman_monitoring/version.rb +1 -1
- data/test/controllers/api/v2/downtime_controller_test.rb +20 -0
- data/test/unit/host_test.rb +3 -3
- metadata +7 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c19621c4296a6cc5d051522ee0176ef3a4726f24bc73eda2c1182c812939c5
|
4
|
+
data.tar.gz: 1691af6f9079acd23c0f826b6052605d99eff64346c127a5b50a2fbac4e38344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57746ee94c93571b9e8fa14050f2ff1358d265fa710908175fa26b9baa799c5597d31ef2b8a71c3d31b9a57c6c6e4e46fc7377700d1a4f686e1db2a18835f54c
|
7
|
+
data.tar.gz: 14c121e8aaf4c486e1fdd74ce09747578658cc8f8d7c5c9e471d897ea55fe27d8e5c5a3068c87373988af09d6b96bfee113fb90428680abed618eca0c825ebbd
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@ module Api
|
|
10
10
|
before_action :find_host, :only => [:create]
|
11
11
|
|
12
12
|
api :POST, '/downtime', N_('Schedule host downtime')
|
13
|
+
param :all_services, [true, false], :desc => N_('Set downtime for all services'), :required => false
|
13
14
|
param :duration, :number, :desc => N_('Downtime duration (seconds)'), :required => false
|
14
15
|
param :reason, String, :desc => N_('Downtime reason'), :required => false
|
15
16
|
|
@@ -18,6 +19,7 @@ module Api
|
|
18
19
|
options = {
|
19
20
|
:comment => downtime_params[:reason] || _('Host requested downtime')
|
20
21
|
}
|
22
|
+
options[:all_services] = downtime_params[:all_services] if downtime_params.key? :all_services
|
21
23
|
if downtime_params.key? :duration
|
22
24
|
options[:start_time] = Time.now.to_i
|
23
25
|
options[:end_time] = Time.now.to_i + downtime_params[:duration].to_i
|
@@ -35,7 +37,7 @@ module Api
|
|
35
37
|
private
|
36
38
|
|
37
39
|
def downtime_params
|
38
|
-
params.permit(:duration, :reason)
|
40
|
+
params.permit(:all_services, :duration, :reason)
|
39
41
|
end
|
40
42
|
|
41
43
|
def find_host
|
@@ -30,7 +30,6 @@ class MonitoringResult < ApplicationRecord
|
|
30
30
|
end
|
31
31
|
|
32
32
|
created = MonitoringResult.where(:host => host, :service => result[:service]).first_or_create
|
33
|
-
# rubocop:disable Rails/Date
|
34
33
|
if created.timestamp.blank? || updates[:timestamp].blank? || (created.timestamp.to_time - updates[:timestamp].to_time) < 2
|
35
34
|
created.update(updates)
|
36
35
|
|
@@ -41,7 +40,6 @@ class MonitoringResult < ApplicationRecord
|
|
41
40
|
else
|
42
41
|
logger.debug "Skipping monitoring result import for #{host} as it is older than what we have."
|
43
42
|
end
|
44
|
-
# rubocop:enable Rails/Date
|
45
43
|
end
|
46
44
|
# rubocop:enable Metrics/AbcSize
|
47
45
|
|
data/config/routes.rb
CHANGED
@@ -2,14 +2,10 @@
|
|
2
2
|
|
3
3
|
class RenameDowntimeHostPermission < ActiveRecord::Migration[5.2]
|
4
4
|
def up
|
5
|
-
# rubocop:disable Rails/SkipsModelValidations
|
6
5
|
Permission.where(name: 'manage_host_downtimes').update_all(name: 'manage_downtime_hosts') if table_exists?(:permissions)
|
7
|
-
# rubocop:enable Rails/SkipsModelValidations
|
8
6
|
end
|
9
7
|
|
10
8
|
def down
|
11
|
-
# rubocop:disable Rails/SkipsModelValidations
|
12
9
|
Permission.where(name: 'manage_downtime_hosts').update_all(name: 'manage_host_downtimes') if table_exists?(:permissions)
|
13
|
-
# rubocop:enable Rails/SkipsModelValidations
|
14
10
|
end
|
15
11
|
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
class FixMonitoringSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
|
4
4
|
def up
|
5
|
-
|
6
|
-
Setting.where(category: 'Setting::Monitoring').update_all(category: 'Setting')
|
7
|
-
# rubocop:enable Rails/SkipsModelValidations
|
5
|
+
Setting.where(category: 'Setting::Monitoring').update_all(category: 'Setting') if column_exists?(:settings, :category)
|
8
6
|
end
|
9
7
|
end
|
@@ -86,14 +86,12 @@ module ForemanMonitoring
|
|
86
86
|
end
|
87
87
|
|
88
88
|
config.to_prepare do
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
Rails.logger.warn "ForemanMonitoring: skipping engine hook (#{e})"
|
96
|
-
end
|
89
|
+
::Host::Managed.prepend(ForemanMonitoring::HostExtensions)
|
90
|
+
::Hostgroup.include(ForemanMonitoring::HostgroupExtensions)
|
91
|
+
::HostsHelper.prepend(ForemanMonitoring::HostsHelperExt)
|
92
|
+
::HostsController.prepend(ForemanMonitoring::HostsControllerExtensions)
|
93
|
+
rescue StandardError => e
|
94
|
+
Rails.logger.warn "ForemanMonitoring: skipping engine hook (#{e})"
|
97
95
|
end
|
98
96
|
|
99
97
|
initializer 'foreman_monitoring.register_gettext', after: :load_config_initializers do |_app|
|
@@ -34,6 +34,26 @@ class Api::V2::DowntimeControllerTest < ActionController::TestCase
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
context '#create with all_services' do
|
38
|
+
test 'should create downtime without all_services value if none given' do
|
39
|
+
Host::Managed.any_instance.expects(:downtime_host).with { |params| !params.key? :all_services }
|
40
|
+
post :create
|
41
|
+
assert_response :success
|
42
|
+
end
|
43
|
+
|
44
|
+
test 'should create downtime with given all_services value' do
|
45
|
+
Host::Managed.any_instance.expects(:downtime_host).with { |params| params[:all_services] }
|
46
|
+
post :create, params: { all_services: true }
|
47
|
+
assert_response :success
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'should create downtime with given all_services value even if false' do
|
51
|
+
Host::Managed.any_instance.expects(:downtime_host).with { |params| params[:all_services] == false }
|
52
|
+
post :create, params: { all_services: false }
|
53
|
+
assert_response :success
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
37
57
|
context '#create with duration' do
|
38
58
|
test 'should create downtime with given duration' do
|
39
59
|
Host::Managed.any_instance.expects(:downtime_host).with { |params| params[:end_time] - params[:start_time] == 3600 }
|
data/test/unit/host_test.rb
CHANGED
@@ -61,7 +61,7 @@ class HostTest < ActiveSupport::TestCase
|
|
61
61
|
ProxyAPI::Monitoring.any_instance.stubs(:query_host).returns(fake_host_query_result)
|
62
62
|
assert_valid host
|
63
63
|
tasks = host.queue.all.map(&:name)
|
64
|
-
|
64
|
+
assert_empty tasks
|
65
65
|
end
|
66
66
|
|
67
67
|
test 'should queue monitoring destroy' do
|
@@ -83,7 +83,7 @@ class HostTest < ActiveSupport::TestCase
|
|
83
83
|
test 'should not queue monitoring create actions' do
|
84
84
|
assert_valid host
|
85
85
|
tasks = host.queue.all.map(&:name)
|
86
|
-
|
86
|
+
assert_empty tasks
|
87
87
|
end
|
88
88
|
|
89
89
|
test 'should queue monitoring downtime on host destroy' do
|
@@ -134,7 +134,7 @@ class HostTest < ActiveSupport::TestCase
|
|
134
134
|
host.send(:queue_monitoring)
|
135
135
|
host.send(:queue_monitoring_destroy)
|
136
136
|
tasks = host.queue.all.map(&:name)
|
137
|
-
|
137
|
+
assert_empty tasks
|
138
138
|
end
|
139
139
|
end
|
140
140
|
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: 3.
|
4
|
+
version: 3.1.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:
|
11
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -24,62 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rubocop
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.80.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.80.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop-minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop-performance
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop-rails
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
27
|
- !ruby/object:Gem::Dependency
|
84
28
|
name: deface
|
85
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,14 +108,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
108
|
requirements:
|
165
109
|
- - ">="
|
166
110
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
111
|
+
version: '2.7'
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '4'
|
168
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
116
|
requirements:
|
170
117
|
- - ">="
|
171
118
|
- !ruby/object:Gem::Version
|
172
119
|
version: '0'
|
173
120
|
requirements: []
|
174
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.5.9
|
175
122
|
signing_key:
|
176
123
|
specification_version: 4
|
177
124
|
summary: Foreman plugin for monitoring system integration.
|