foreman_expire_hosts 8.1.0 → 8.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/foreman_expire_hosts/hosts_helper.rb +19 -0
- data/app/models/concerns/foreman_expire_hosts/host_ext.rb +3 -3
- data/lib/foreman_expire_hosts/engine.rb +0 -1
- data/lib/foreman_expire_hosts/version.rb +1 -1
- data/test/helpers/hosts_helper_test.rb +5 -1
- metadata +3 -4
- data/app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3e5b913f8041ef79d3fdcb5572d9e0f5a04acb96ac6d18622bf2e4c064e7bf9
|
4
|
+
data.tar.gz: 29203939087fc0aa319796c0f5b8cca08cd65b92e3a7f6d2708eb4d6d35fa8f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8ae87316f890b0b9ffbb0d6ed9aaa97394871806a08b6e840b565565da321d5ca89cc7887388d2c4557d96552528146231d0791e476cc069962ed9b41d5bd20
|
7
|
+
data.tar.gz: fceaa7eb6ad7a554c5e3697ebfe69740d28f102313585c818b640a97d5225339c3deac030172722c530ab1e7600ce97900d4e7eea51606a326721c94290a2329
|
@@ -12,5 +12,24 @@ module ForemanExpireHosts
|
|
12
12
|
end
|
13
13
|
actions
|
14
14
|
end
|
15
|
+
|
16
|
+
def host_expiry_warning_message(host)
|
17
|
+
return nil unless host.expires?
|
18
|
+
|
19
|
+
if host.expired_past_grace_period?
|
20
|
+
message = _('This host has expired %s ago and needs to be deleted manually.') % time_ago_in_words(host.expired_on)
|
21
|
+
elsif host.expired?
|
22
|
+
message = _('This host has expired %{time_ago} ago and will be deleted on %{delete_date}.') % { :delete_date => l(host.expiration_grace_period_end_date), :time_ago => time_ago_in_words(host.expired_on) }
|
23
|
+
elsif host.expires_today?
|
24
|
+
message = _('This host will expire today.')
|
25
|
+
elsif host.pending_expiration?
|
26
|
+
message = _('This host will expire in %{distance_of_time} (on %{expire_date}).') % { :expire_date => l(host.expired_on), :distance_of_time => future_time_in_words(host.expired_on) }
|
27
|
+
end
|
28
|
+
message
|
29
|
+
end
|
30
|
+
|
31
|
+
def future_time_in_words(to_time, options = {})
|
32
|
+
distance_of_time_in_words(to_time, Time.current, options)
|
33
|
+
end
|
15
34
|
end
|
16
35
|
end
|
@@ -55,20 +55,20 @@ module ForemanExpireHosts
|
|
55
55
|
def expiration_grace_period_end_date
|
56
56
|
return nil unless expires?
|
57
57
|
|
58
|
-
expired_on.to_date + Setting[:days_to_delete_after_host_expiration].to_i
|
58
|
+
expired_on.to_date + Setting[:days_to_delete_after_host_expiration].to_i.days
|
59
59
|
end
|
60
60
|
|
61
61
|
def expired_past_grace_period?
|
62
62
|
return false unless expires?
|
63
63
|
|
64
|
-
expiration_grace_period_end_date <= Date.today
|
64
|
+
expiration_grace_period_end_date.to_date <= Date.today
|
65
65
|
end
|
66
66
|
|
67
67
|
def pending_expiration?
|
68
68
|
return false unless expires?
|
69
69
|
return false if expired?
|
70
70
|
|
71
|
-
expired_on - Setting['notify1_days_before_host_expiry'].to_i <= Date.today
|
71
|
+
expired_on.to_date - Setting['notify1_days_before_host_expiry'].to_i.days <= Date.today
|
72
72
|
end
|
73
73
|
|
74
74
|
def can_modify_expiry_date?
|
@@ -87,7 +87,6 @@ module ForemanExpireHosts
|
|
87
87
|
config.to_prepare do
|
88
88
|
begin
|
89
89
|
::Host::Managed.include ForemanExpireHosts::HostExt
|
90
|
-
::HostsHelper.include ForemanExpireHosts::HostsHelperExtensions
|
91
90
|
::HostsController.prepend ForemanExpireHosts::HostControllerExtensions
|
92
91
|
::AuditsHelper.include ForemanExpireHosts::AuditsHelperExtensions
|
93
92
|
::Api::V2::HostsController.include ForemanExpireHosts::Api::V2::HostsControllerExtensions
|
@@ -5,7 +5,11 @@ require 'test_plugin_helper'
|
|
5
5
|
class HostsHelperTest < ActionView::TestCase
|
6
6
|
include HostsHelper
|
7
7
|
include HostDescriptionHelper
|
8
|
-
|
8
|
+
# Foreman 3.7 dropped this via
|
9
|
+
# https://github.com/theforeman/foreman/commit/6cdb8c7a9ebd790537510213e43537a4a87189d6
|
10
|
+
# Foreman 3.9 bought it back via
|
11
|
+
# https://github.com/theforeman/foreman/commit/37a99c70ebd9e4d6f03af546dfe36e7678e2bcf3
|
12
|
+
include PuppetRelatedHelper if defined?(PuppetRelatedHelper)
|
9
13
|
include ForemanExpireHosts::HostsHelper
|
10
14
|
include ApplicationHelper
|
11
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_expire_hosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nagarjuna Rachaneni
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deface
|
@@ -54,7 +54,6 @@ files:
|
|
54
54
|
- app/controllers/concerns/foreman_expire_hosts/api/v2/hosts_controller_extensions.rb
|
55
55
|
- app/controllers/concerns/foreman_expire_hosts/host_controller_extensions.rb
|
56
56
|
- app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb
|
57
|
-
- app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb
|
58
57
|
- app/helpers/expire_hosts_mailer_helper.rb
|
59
58
|
- app/helpers/foreman_expire_hosts/hosts_helper.rb
|
60
59
|
- app/mailers/expire_hosts_mailer.rb
|
@@ -128,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
127
|
- !ruby/object:Gem::Version
|
129
128
|
version: '0'
|
130
129
|
requirements: []
|
131
|
-
rubygems_version: 3.3
|
130
|
+
rubygems_version: 3.2.3
|
132
131
|
signing_key:
|
133
132
|
specification_version: 4
|
134
133
|
summary: Foreman plugin for limiting host lifetime
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ForemanExpireHosts
|
4
|
-
module HostsHelperExtensions
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
def host_expiry_warning_message(host)
|
8
|
-
return nil unless host.expires?
|
9
|
-
|
10
|
-
if host.expired_past_grace_period?
|
11
|
-
message = _('This host has expired %s ago and needs to be deleted manually.') % time_ago_in_words(host.expired_on)
|
12
|
-
elsif host.expired?
|
13
|
-
message = _('This host has expired %{time_ago} ago and will be deleted on %{delete_date}.') % { :delete_date => l(host.expiration_grace_period_end_date), :time_ago => time_ago_in_words(host.expired_on) }
|
14
|
-
elsif host.expires_today?
|
15
|
-
message = _('This host will expire today.')
|
16
|
-
elsif host.pending_expiration?
|
17
|
-
message = _('This host will expire in %{distance_of_time} (on %{expire_date}).') % { :expire_date => l(host.expired_on), :distance_of_time => future_time_in_words(host.expired_on) }
|
18
|
-
end
|
19
|
-
message
|
20
|
-
end
|
21
|
-
|
22
|
-
def future_time_in_words(to_time, options = {})
|
23
|
-
distance_of_time_in_words(to_time, Time.current, options)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|