foreman_expire_hosts 8.2.0 → 9.0.1

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
2
  SHA256:
3
- metadata.gz: b3e5b913f8041ef79d3fdcb5572d9e0f5a04acb96ac6d18622bf2e4c064e7bf9
4
- data.tar.gz: 29203939087fc0aa319796c0f5b8cca08cd65b92e3a7f6d2708eb4d6d35fa8f8
3
+ metadata.gz: 839f503c394a7967c2a50c93f13197c83b4b9a7a304fbff46721f9416936c8f7
4
+ data.tar.gz: 916041f719b68174a64b3337cfcecbbfd2c0552ae60a5c235cff3701c977331f
5
5
  SHA512:
6
- metadata.gz: e8ae87316f890b0b9ffbb0d6ed9aaa97394871806a08b6e840b565565da321d5ca89cc7887388d2c4557d96552528146231d0791e476cc069962ed9b41d5bd20
7
- data.tar.gz: fceaa7eb6ad7a554c5e3697ebfe69740d28f102313585c818b640a97d5225339c3deac030172722c530ab1e7600ce97900d4e7eea51606a326721c94290a2329
6
+ metadata.gz: cc344d2888bdc7df2471cbdaba3b9236c40e74ae24b2f96cfa38d49188d574beff34ec25d1028b60607083159d99463c2a7916b3dbc212a5f40b962ccf3ff75b
7
+ data.tar.gz: ff4a9af4cba0aaee10361997aa5b714240e83da4d1bb6b17bc2a421867615d1562821c6e6508a0212bdf2abb4673c4f430598375cd0252d74ef97170b0c5031a
data/README.md CHANGED
@@ -20,6 +20,7 @@ This plugin will send two warning notifications before host expiry (see Settings
20
20
  | >= 1.18 | ~> 6.0 |
21
21
  | >= 1.24 | ~> 7.0 |
22
22
  | >= 3.0 | ~> 8.0 |
23
+ | >= 3.13 | ~> 9.0 |
23
24
 
24
25
  # Screenshots
25
26
  ![Expiry date field in host form](https://raw.githubusercontent.com/ingenico-group/screenshots/master/foreman_host_expiry/expiry-date-field-in-host-form.png)
@@ -10,11 +10,12 @@ module ExpireHostsNotifications
10
10
  ForemanExpireHosts::Action::StopExpiredHosts.new.engage
11
11
  end
12
12
 
13
- def deliver_expiry_warning_notification(num = 1) # notify1_days_before_expiry
13
+ # notify1_days_before_expiry
14
+ def deliver_expiry_warning_notification(num = 1)
14
15
  return unless [1, 2].include?(num)
15
16
 
16
17
  days_before_expiry = Setting["notify#{num}_days_before_host_expiry"].to_i
17
- expiry_date = (Date.today + days_before_expiry)
18
+ expiry_date = (Time.zone.today + days_before_expiry)
18
19
  notifiable_hosts = Host.with_expire_date(expiry_date).preload(:owner)
19
20
 
20
21
  ForemanExpireHosts::Notification::ExpiryWarning.new(
@@ -39,6 +39,7 @@ module HostStatus
39
39
  end
40
40
 
41
41
  def to_label(_options = {})
42
+ return N_('Does not expire') unless host.expires?
42
43
  case to_status
43
44
  when OK
44
45
  N_('Expires on %s') % I18n.l(host.expired_on.to_date)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Deface::Override.new(
4
4
  :virtual_path => 'hosts/show',
5
- :name => 'host_expiry_waring_in_show',
5
+ :name => 'host_expiry_warning_in_show',
6
6
  :insert_before => '#host-show',
7
- :partial => 'hosts/expired_message.html.erb'
7
+ :partial => 'hosts/expired_message'
8
8
  )
@@ -6,12 +6,6 @@ module ForemanExpireHosts
6
6
  class Engine < ::Rails::Engine
7
7
  engine_name 'foreman_expire_hosts'
8
8
 
9
- config.autoload_paths += Dir["#{config.root}/lib"]
10
- config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
11
- config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
12
- config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
13
- config.autoload_paths += Dir["#{config.root}/app/services"]
14
-
15
9
  # Add any db migrations
16
10
  initializer 'foreman_plugin_template.load_app_instance_data' do |app|
17
11
  ForemanExpireHosts::Engine.paths['db/migrate'].existent.each do |path|
@@ -19,67 +13,69 @@ module ForemanExpireHosts
19
13
  end
20
14
  end
21
15
 
22
- initializer 'foreman_expire_hosts.register_plugin', :before => :finisher_hook do |_app|
23
- Foreman::Plugin.register :foreman_expire_hosts do
24
- requires_foreman '>= 3.0.0'
25
- register_custom_status HostStatus::ExpirationStatus
16
+ initializer 'foreman_expire_hosts.register_plugin', :before => :finisher_hook do |app|
17
+ app.reloader.to_prepare do
18
+ Foreman::Plugin.register :foreman_expire_hosts do
19
+ requires_foreman '>= 3.13.0'
20
+ register_custom_status HostStatus::ExpirationStatus
26
21
 
27
- # strong parameters
28
- parameter_filter Host::Managed, :expired_on
22
+ # strong parameters
23
+ parameter_filter Host::Managed, :expired_on
29
24
 
30
- security_block :foreman_expire_hosts do
31
- permission :edit_host_expiry,
32
- {},
33
- :resource_type => 'Host'
34
- end
25
+ security_block :foreman_expire_hosts do
26
+ permission :edit_host_expiry,
27
+ {},
28
+ :resource_type => 'Host'
29
+ end
35
30
 
36
- # Extend built in permissions
37
- Foreman::AccessControl.permission(:edit_hosts).actions.concat [
38
- 'hosts/select_multiple_expiration',
39
- 'hosts/update_multiple_expiration'
40
- ]
31
+ # Extend built in permissions
32
+ Foreman::AccessControl.permission(:edit_hosts).actions.concat [
33
+ 'hosts/select_multiple_expiration',
34
+ 'hosts/update_multiple_expiration'
35
+ ]
41
36
 
42
- Setting::BLANK_ATTRS << 'host_expiry_email_recipients'
37
+ Setting::BLANK_ATTRS << 'host_expiry_email_recipients'
43
38
 
44
- settings do
45
- category(:expire_hosts, N_('Expire Hosts')) do
46
- setting('is_host_expiry_date_mandatory',
47
- type: :boolean,
48
- description: N_('Make expiry date field mandatory on host creation/update'),
49
- default: false,
50
- full_name: N_('Require host expiry date'))
51
- setting('can_owner_modify_host_expiry_date',
52
- type: :boolean,
53
- description: N_('Allow host owner to modify host expiry date field. If the field is false then admin only can edit expiry field'),
54
- default: false,
55
- full_name: N_('Host owner can modify host expiry date'))
56
- setting('notify1_days_before_host_expiry',
57
- type: :integer,
58
- description: N_('Send first notification to owner of hosts about his hosts expiring in given days. Must be integer only'),
59
- default: 7,
60
- full_name: N_('First expiry notification'))
61
- setting('notify2_days_before_host_expiry',
62
- type: :integer,
63
- description: N_('Send second notification to owner of hosts about his hosts expiring in given days. Must be integer only'),
64
- default: 1,
65
- full_name: N_('Second expiry notification'))
66
- setting('days_to_delete_after_host_expiration',
67
- type: :integer,
68
- description: N_('Delete expired hosts after given days of hosts expiry date. Must be integer only'),
69
- default: 3,
70
- full_name: N_('Expiry grace period in days'))
71
- setting('host_expiry_email_recipients',
72
- type: :string,
73
- description: N_('All notifications will be delivered to its owner. If any other users/admins need to receive those expiry warning notifications then those emails can be configured comma separated here.'),
74
- default: nil,
75
- full_name: N_('Expiry e-mail recipients'))
39
+ settings do
40
+ category(:expire_hosts, N_('Expire Hosts')) do
41
+ setting('is_host_expiry_date_mandatory',
42
+ type: :boolean,
43
+ description: N_('Make expiry date field mandatory on host creation/update'),
44
+ default: false,
45
+ full_name: N_('Require host expiry date'))
46
+ setting('can_owner_modify_host_expiry_date',
47
+ type: :boolean,
48
+ description: N_('Allow host owner to modify host expiry date field. If the field is false then admin only can edit expiry field'),
49
+ default: false,
50
+ full_name: N_('Host owner can modify host expiry date'))
51
+ setting('notify1_days_before_host_expiry',
52
+ type: :integer,
53
+ description: N_('Send first notification to owner of hosts about his hosts expiring in given days. Must be integer only'),
54
+ default: 7,
55
+ full_name: N_('First expiry notification'))
56
+ setting('notify2_days_before_host_expiry',
57
+ type: :integer,
58
+ description: N_('Send second notification to owner of hosts about his hosts expiring in given days. Must be integer only'),
59
+ default: 1,
60
+ full_name: N_('Second expiry notification'))
61
+ setting('days_to_delete_after_host_expiration',
62
+ type: :integer,
63
+ description: N_('Delete expired hosts after given days of hosts expiry date. Must be integer only'),
64
+ default: 3,
65
+ full_name: N_('Expiry grace period in days'))
66
+ setting('host_expiry_email_recipients',
67
+ type: :string,
68
+ description: N_('All notifications will be delivered to its owner. If any other users/admins need to receive those expiry warning notifications then those emails can be configured comma separated here.'), # rubocop:disable Layout/LineLength
69
+ default: nil,
70
+ full_name: N_('Expiry e-mail recipients'))
71
+ end
76
72
  end
77
- end
78
73
 
79
- extend_rabl_template 'api/v2/hosts/main', 'api/v2/hosts/expiration'
74
+ extend_rabl_template 'api/v2/hosts/main', 'api/v2/hosts/expiration'
80
75
 
81
- describe_host do
82
- multiple_actions_provider :expire_hosts_host_multiple_actions
76
+ describe_host do
77
+ multiple_actions_provider :expire_hosts_host_multiple_actions
78
+ end
83
79
  end
84
80
  end
85
81
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanExpireHosts
4
- VERSION = '8.2.0'
4
+ VERSION = '9.0.1'
5
5
  end
@@ -18,6 +18,9 @@ class ExpirationStatusTest < ActiveSupport::TestCase
18
18
 
19
19
  @host.expired_on = Date.today
20
20
  assert_equal 'Expires today', @status.to_label
21
+
22
+ @host.expired_on = nil
23
+ assert_equal 'Does not expire', @status.to_label
21
24
  end
22
25
 
23
26
  test '#relevant? is only for expiring hosts' do
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_expire_hosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nagarjuna Rachaneni
8
8
  - Timo Goebel
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-05-31 00:00:00.000000000 Z
11
+ date: 2025-06-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: deface
@@ -56,6 +55,7 @@ files:
56
55
  - app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb
57
56
  - app/helpers/expire_hosts_mailer_helper.rb
58
57
  - app/helpers/foreman_expire_hosts/hosts_helper.rb
58
+ - app/lib/expire_hosts_notifications.rb
59
59
  - app/mailers/expire_hosts_mailer.rb
60
60
  - app/models/concerns/foreman_expire_hosts/host_ext.rb
61
61
  - app/models/host_status/expiration_status.rb
@@ -92,7 +92,6 @@ files:
92
92
  - db/migrate/20230112104438_change_expired_on_type.rb
93
93
  - db/seeds.d/80_expire_hosts_ui_notification.rb
94
94
  - extra/foreman_expire_hosts.cron
95
- - lib/expire_hosts_notifications.rb
96
95
  - lib/foreman_expire_hosts.rb
97
96
  - lib/foreman_expire_hosts/engine.rb
98
97
  - lib/foreman_expire_hosts/version.rb
@@ -112,7 +111,6 @@ homepage: https://github.com/theforeman/foreman_expire_hosts
112
111
  licenses:
113
112
  - GPL-3.0
114
113
  metadata: {}
115
- post_install_message:
116
114
  rdoc_options: []
117
115
  require_paths:
118
116
  - lib
@@ -127,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
125
  - !ruby/object:Gem::Version
128
126
  version: '0'
129
127
  requirements: []
130
- rubygems_version: 3.2.3
131
- signing_key:
128
+ rubygems_version: 3.6.7
132
129
  specification_version: 4
133
130
  summary: Foreman plugin for limiting host lifetime
134
131
  test_files: