foreman_expire_hosts 6.0.0 → 7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +78 -0
- data/.rubocop.yml +18 -13
- data/.rubocop_todo.yml +11 -31
- data/Gemfile +2 -0
- data/README.md +1 -0
- data/app/controllers/concerns/foreman_expire_hosts/api/v2/hosts_controller_extensions.rb +2 -0
- data/app/controllers/concerns/foreman_expire_hosts/host_controller_extensions.rb +20 -15
- data/app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb +4 -0
- data/app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb +5 -22
- data/app/helpers/expire_hosts_mailer_helper.rb +3 -0
- data/app/helpers/foreman_expire_hosts/hosts_helper.rb +16 -0
- data/app/mailers/expire_hosts_mailer.rb +3 -0
- data/app/models/concerns/foreman_expire_hosts/host_ext.rb +9 -1
- data/app/models/host_status/expiration_status.rb +3 -0
- data/app/models/setting/expire_hosts.rb +2 -0
- data/app/overrides/add_expired_on_field_to_host_form.rb +4 -2
- data/app/overrides/add_expired_on_field_to_host_show.rb +5 -3
- data/app/overrides/deleted_expired_host_comment_in_audits.rb +8 -6
- data/app/services/foreman_expire_hosts/action/base.rb +9 -2
- data/app/services/foreman_expire_hosts/action/delete_expired_hosts.rb +3 -0
- data/app/services/foreman_expire_hosts/action/stop_expired_hosts.rb +6 -2
- data/app/services/foreman_expire_hosts/expiry_edit_authorizer.rb +2 -0
- data/app/services/foreman_expire_hosts/notification/base.rb +12 -3
- data/app/services/foreman_expire_hosts/notification/deleted_hosts.rb +2 -0
- data/app/services/foreman_expire_hosts/notification/expiry_warning.rb +2 -0
- data/app/services/foreman_expire_hosts/notification/failed_deleted_hosts.rb +2 -0
- data/app/services/foreman_expire_hosts/notification/failed_stopped_hosts.rb +2 -0
- data/app/services/foreman_expire_hosts/notification/stopped_hosts.rb +2 -0
- data/app/services/foreman_expire_hosts/safe_destroy.rb +7 -5
- data/app/services/foreman_expire_hosts/ui_notifications/hosts/base.rb +4 -1
- data/app/services/foreman_expire_hosts/ui_notifications/hosts/expiry_warning.rb +2 -0
- data/app/services/foreman_expire_hosts/ui_notifications/hosts/stopped_host.rb +2 -0
- data/app/views/api/v2/hosts/expiration.json.rabl +2 -0
- data/app/views/hosts/_expired_on_field.html.erb +11 -20
- data/app/views/hosts/select_multiple_expiration.html.erb +10 -15
- data/config/routes.rb +2 -0
- data/db/migrate/20150427101516_add_expiry_on_to_hosts.rb +2 -0
- data/db/seeds.d/80_expire_hosts_ui_notification.rb +2 -0
- data/extra/foreman_expire_hosts.cron +8 -0
- data/foreman_expire_hosts.gemspec +10 -3
- data/lib/expire_hosts_notifications.rb +3 -0
- data/lib/foreman_expire_hosts.rb +2 -0
- data/lib/foreman_expire_hosts/engine.rb +22 -10
- data/lib/foreman_expire_hosts/version.rb +3 -1
- data/lib/tasks/expired_hosts.rake +3 -1
- data/test/factories/foreman_expire_hosts_factories.rb +7 -5
- data/test/functional/api/v2/hosts_controller_test.rb +3 -1
- data/test/functional/concerns/hosts_controller_extensions_test.rb +3 -1
- data/test/helpers/hosts_helper_test.rb +5 -0
- data/test/lib/expire_hosts_notifications_test.rb +91 -45
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/concerns/host_extensions_test.rb +21 -19
- data/test/unit/expire_hosts_mailer_test.rb +6 -0
- data/test/unit/expiry_edit_authorizer_test.rb +2 -0
- data/test/unit/host_status/expiration_status_test.rb +3 -1
- data/test/unit/safe_destroy_test.rb +3 -1
- metadata +53 -26
- data/app/assets/javascripts/foreman_expire_hosts/application.js +0 -3
- data/app/assets/javascripts/foreman_expire_hosts/datepicker_for_host_expired_on_field.js +0 -27
- data/app/assets/stylesheets/foreman_expire_hosts/application.scss +0 -4
- data/app/overrides/add_js_to_host_index.rb +0 -6
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class ExpireHostMailerTest < ActionMailer::TestCase
|
@@ -35,6 +37,10 @@ class ExpireHostMailerTest < ActionMailer::TestCase
|
|
35
37
|
assert_includes mail.subject, 'Stopped expired hosts in Foreman'
|
36
38
|
end
|
37
39
|
|
40
|
+
test 'should include a deletion date' do
|
41
|
+
assert_includes mail.body, "These hosts will be destroyed on #{Date.today}."
|
42
|
+
end
|
43
|
+
|
38
44
|
test 'should show mitigation text if authorized' do
|
39
45
|
ForemanExpireHosts::ExpiryEditAuthorizer.any_instance.stubs(:authorized?).returns(true)
|
40
46
|
assert_includes mail.body.to_s, 'Please change their expiry date'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class ExpirationStatusTest < ActiveSupport::TestCase
|
@@ -23,6 +25,6 @@ class ExpirationStatusTest < ActiveSupport::TestCase
|
|
23
25
|
assert @status.relevant?
|
24
26
|
|
25
27
|
@host.expired_on = nil
|
26
|
-
|
28
|
+
assert_not @status.relevant?
|
27
29
|
end
|
28
30
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
module ForemanExpireHosts
|
@@ -29,7 +31,7 @@ module ForemanExpireHosts
|
|
29
31
|
test 'deletes a host' do
|
30
32
|
assert Host::Managed.find_by(id: host.id)
|
31
33
|
assert SafeDestroy.new(host).destroy!
|
32
|
-
|
34
|
+
assert_not Host::Managed.find_by(id: host.id)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_expire_hosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nagarjuna Rachaneni
|
8
8
|
- Timo Goebel
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: deface
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
@@ -26,13 +26,13 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rdoc
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
|
-
type: :
|
35
|
+
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
@@ -40,35 +40,64 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rubocop
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 0.80.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.80.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name: rubocop
|
57
|
+
name: rubocop-minitest
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.7.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.7.0
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop-performance
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.5.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.5.2
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop-rails
|
58
86
|
requirement: !ruby/object:Gem::Requirement
|
59
87
|
requirements:
|
60
|
-
- -
|
88
|
+
- - "~>"
|
61
89
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
90
|
+
version: 2.4.2
|
63
91
|
type: :development
|
64
92
|
prerelease: false
|
65
93
|
version_requirements: !ruby/object:Gem::Requirement
|
66
94
|
requirements:
|
67
|
-
- -
|
95
|
+
- - "~>"
|
68
96
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
70
|
-
description:
|
71
|
-
|
97
|
+
version: 2.4.2
|
98
|
+
description: |
|
99
|
+
A Foreman plugin that allows hosts to expire at a configurable date.
|
100
|
+
Hosts will be shut down and automatically deleted after a grace period.
|
72
101
|
email:
|
73
102
|
- nn.nagarjuna@gmail.com
|
74
103
|
- mail@timogoebel.name
|
@@ -78,27 +107,25 @@ extra_rdoc_files:
|
|
78
107
|
- README.md
|
79
108
|
- LICENSE
|
80
109
|
files:
|
110
|
+
- ".github/workflows/ci.yml"
|
81
111
|
- ".gitignore"
|
82
112
|
- ".rubocop.yml"
|
83
113
|
- ".rubocop_todo.yml"
|
84
114
|
- Gemfile
|
85
115
|
- LICENSE
|
86
116
|
- README.md
|
87
|
-
- app/assets/javascripts/foreman_expire_hosts/application.js
|
88
|
-
- app/assets/javascripts/foreman_expire_hosts/datepicker_for_host_expired_on_field.js
|
89
|
-
- app/assets/stylesheets/foreman_expire_hosts/application.scss
|
90
117
|
- app/controllers/concerns/foreman_expire_hosts/api/v2/hosts_controller_extensions.rb
|
91
118
|
- app/controllers/concerns/foreman_expire_hosts/host_controller_extensions.rb
|
92
119
|
- app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb
|
93
120
|
- app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb
|
94
121
|
- app/helpers/expire_hosts_mailer_helper.rb
|
122
|
+
- app/helpers/foreman_expire_hosts/hosts_helper.rb
|
95
123
|
- app/mailers/expire_hosts_mailer.rb
|
96
124
|
- app/models/concerns/foreman_expire_hosts/host_ext.rb
|
97
125
|
- app/models/host_status/expiration_status.rb
|
98
126
|
- app/models/setting/expire_hosts.rb
|
99
127
|
- app/overrides/add_expired_on_field_to_host_form.rb
|
100
128
|
- app/overrides/add_expired_on_field_to_host_show.rb
|
101
|
-
- app/overrides/add_js_to_host_index.rb
|
102
129
|
- app/overrides/deleted_expired_host_comment_in_audits.rb
|
103
130
|
- app/services/foreman_expire_hosts/action/base.rb
|
104
131
|
- app/services/foreman_expire_hosts/action/delete_expired_hosts.rb
|
@@ -127,6 +154,7 @@ files:
|
|
127
154
|
- config/routes.rb
|
128
155
|
- db/migrate/20150427101516_add_expiry_on_to_hosts.rb
|
129
156
|
- db/seeds.d/80_expire_hosts_ui_notification.rb
|
157
|
+
- extra/foreman_expire_hosts.cron
|
130
158
|
- foreman_expire_hosts.gemspec
|
131
159
|
- lib/expire_hosts_notifications.rb
|
132
160
|
- lib/foreman_expire_hosts.rb
|
@@ -148,7 +176,7 @@ homepage: https://github.com/theforeman/foreman_expire_hosts
|
|
148
176
|
licenses:
|
149
177
|
- GPL-3.0
|
150
178
|
metadata: {}
|
151
|
-
post_install_message:
|
179
|
+
post_install_message:
|
152
180
|
rdoc_options: []
|
153
181
|
require_paths:
|
154
182
|
- lib
|
@@ -163,9 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
191
|
- !ruby/object:Gem::Version
|
164
192
|
version: '0'
|
165
193
|
requirements: []
|
166
|
-
|
167
|
-
|
168
|
-
signing_key:
|
194
|
+
rubygems_version: 3.1.2
|
195
|
+
signing_key:
|
169
196
|
specification_version: 4
|
170
197
|
summary: Foreman plugin for limiting host lifetime
|
171
198
|
test_files:
|
@@ -1,27 +0,0 @@
|
|
1
|
-
var shortcuts = {"1 day": 1, "1 week": 7, "1 month": 30, "1 year": 365, "3 days": 3, "3 weeks": 21, "3 months": 90};
|
2
|
-
function append_shortcuts() {
|
3
|
-
if ($(".datepicker-days #datepicker_shortcuts").length == 0) {
|
4
|
-
var shortcuts_html = "<div id='datepicker_shortcuts'><div>";
|
5
|
-
var shortcut_item = 1;
|
6
|
-
$.each(shortcuts, function (lable, days) {
|
7
|
-
var today = new Date();
|
8
|
-
today.setDate(today.getDate() + days);
|
9
|
-
if (shortcut_item == 5) {
|
10
|
-
shortcuts_html += "</div><div style='padding-top: 3px'>"
|
11
|
-
}
|
12
|
-
shortcuts_html += "<a style='width: 65px;' class='btn btn-default btn-xs' role='button' title='" + $.fn.datepicker.dates.en.monthsShort[today.getMonth()] + " " + today.getDate() + " " + today.getFullYear() + "' onclick='populate_date_from_days(" + days + ")'>" + lable + "</a> ";
|
13
|
-
shortcut_item += 1
|
14
|
-
});
|
15
|
-
shortcuts_html += "</div></div>";
|
16
|
-
$(".datepicker-days table").before(shortcuts_html)
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
function populate_date_from_days(shortcut_days) {
|
21
|
-
var today = new Date();
|
22
|
-
today.setDate(today.getDate() + shortcut_days);
|
23
|
-
$('#host_expired_on').datepicker('setDate', today);
|
24
|
-
$('#host_expired_on').datepicker('remove');
|
25
|
-
//$('#host_expired_on').val(today.getDate()+'/'+(today.getMonth()+1)+'/'+today.getFullYear())
|
26
|
-
//$('#host_expired_on').datepicker('hide')
|
27
|
-
}
|