foreman_expire_hosts 7.0.0 → 7.0.1

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: 1f4ea5566b63be22aff9f760b76e60ca34a5ae6c4b09c5cbf1350095b092599d
4
- data.tar.gz: 599502fc7cd748e98c3c5e4caeec46868c1484a7e0c883fddf281ab19e11e76e
3
+ metadata.gz: 44247c83269ff2759c38b6c8ea6821f2b65bdf2558c4703eb4a89f6ccaa7ab83
4
+ data.tar.gz: 110282faa293e518d45dca6661137039ea0e8eaa9a5cd038ee7b19536b8715fe
5
5
  SHA512:
6
- metadata.gz: 81cfb253f0a07dbc56641c6fb194f3cd61b4d0d366d855a71202ca9ae9d686f5ef5d56aeabed31b8905990c30c59527035218541fd3f860855843e2adc0cfddf
7
- data.tar.gz: 4b9c1c317f1abc646c04260bc92822833ac743cb018e79b62eaa48fd3ef94a43fd752a04a553c253b7424bd67308e75251002f84b0fe2e7f49706ea714e96e74
6
+ metadata.gz: e55938b35afdd0ad71696a0a6ed21b8f489934223edd98aac29820d6fce255a372a1372907b3ff489e70205b367e6569eaa7fbf40c6c3251294bd55d746eddc6
7
+ data.tar.gz: 61dcac4a506ba4bf9379ce3270286636f0913c46c96c2bb8691b2b98db05494d1fdb1890daade056fa497198d22266482499c49ebdfc2c1f4bf375feace4f8ca
@@ -34,9 +34,6 @@ Naming/FileName:
34
34
  Style/WordArray:
35
35
  Enabled: false
36
36
 
37
- Style/BracesAroundHashParameters:
38
- Enabled: false
39
-
40
37
  Style/RescueModifier:
41
38
  Enabled: false
42
39
 
@@ -75,3 +72,6 @@ Rails/SkipsModelValidations:
75
72
 
76
73
  Metrics:
77
74
  Enabled: false
75
+
76
+ Layout/LineLength:
77
+ Enabled: false
@@ -5,3 +5,12 @@
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
+
9
+ Style/HashEachMethods:
10
+ Enabled: false
11
+
12
+ Style/HashTransformKeys:
13
+ Enabled: false
14
+
15
+ Style/HashTransformValues:
16
+ Enabled: false
@@ -23,12 +23,6 @@ module ForemanExpireHosts
23
23
  distance_of_time_in_words(to_time, Time.current, options)
24
24
  end
25
25
 
26
- def input_group_addon(content, options = {})
27
- content_tag :span, class: 'input-group-addon' do
28
- content_tag :span, content, options
29
- end
30
- end
31
-
32
26
  def datepicker_f(form, attr, options = {}, html_options = {})
33
27
  field(form, attr, options) do
34
28
  addClass options, 'form-control'
@@ -23,8 +23,10 @@ module ForemanExpireHosts
23
23
  next if result.nil?
24
24
 
25
25
  if result
26
+ logger.info "Action #{self.class.name} for host #{host.name} was successful."
26
27
  self.successful_hosts << host
27
28
  else
29
+ logger.info "Action #{self.class.name} for host #{host.name} failed."
28
30
  self.failed_hosts << host
29
31
  end
30
32
  end
@@ -56,7 +58,7 @@ module ForemanExpireHosts
56
58
  }
57
59
  end
58
60
 
59
- delegate :logger, :to => :Rails
61
+ delegate :logger, :to => :ForemanExpireHosts
60
62
  end
61
63
  end
62
64
  end
@@ -10,6 +10,7 @@ module ForemanExpireHosts
10
10
  end
11
11
 
12
12
  def action(host)
13
+ logger.info "Destroying expired host #{host}."
13
14
  SafeDestroy.new(host).destroy!
14
15
  end
15
16
 
@@ -13,7 +13,7 @@ module ForemanExpireHosts
13
13
  return false unless host.supports_power?
14
14
  return unless host.power.ready?
15
15
 
16
- logger.info "Powering down expired host in grace period #{host}"
16
+ logger.info "Powering down expired host in grace period #{host}."
17
17
  host.power.stop
18
18
  rescue StandardError
19
19
  false
@@ -28,6 +28,8 @@ module ForemanExpireHosts
28
28
  def deliver_mail_notification(recipient, hosts)
29
29
  return true if hosts.empty?
30
30
 
31
+ logger.info "Deliving mail notification '#{humanized_name}' for hosts #{hosts.to_sentence} to #{recipient}."
32
+
31
33
  build_mail_notification(recipient, hosts).deliver_now
32
34
  rescue SocketError, Net::SMTPError => e
33
35
  message = _('Failed to deliver %{notification_name} for Hosts %{hosts}') % {
@@ -39,11 +41,12 @@ module ForemanExpireHosts
39
41
 
40
42
  def deliver_ui_notifications
41
43
  all_hosts.each do |host|
44
+ logger.info "Deliving UI notification '#{humanized_name}' for host '#{host}'."
42
45
  build_ui_notification(host).deliver!
43
46
  end
44
47
  end
45
48
 
46
- delegate :logger, :to => :Rails
49
+ delegate :logger, :to => :ForemanExpireHosts
47
50
 
48
51
  def humanized_name
49
52
  _('Notification')
@@ -7,7 +7,7 @@
7
7
  :start_year => Date.today.year,
8
8
  :help_block => ('<span class="pficon-warning-triangle-o"></span> '.html_safe + _('You are not allowed to change the expiry date of this host.') unless @host.can_modify_expiry_date?),
9
9
  :disabled => !@host.can_modify_expiry_date?,
10
- :help_inline => popover('Auto Expiry', _('Host will be deleted automatically on the given expiry date.') + '<br>'.html_safe +
11
- _('Leave blank to keep the host until deleted manually.'))
10
+ :help_inline => popover('Auto Expiry', _('Expired hosts will be deleted automatically after the grace period has passed.') + '<br>'.html_safe +
11
+ _('If you do not want this host to expire and do not want it to be deleted automatically, do not specify an expiry date.'))
12
12
  }
13
13
  %>
@@ -0,0 +1,8 @@
1
+ SHELL=/bin/sh
2
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
3
+
4
+ RAILS_ENV=production
5
+ FOREMAN_HOME=/usr/share/foreman
6
+
7
+ # Send out notifications about expired hosts
8
+ 45 7 * * * foreman /usr/sbin/foreman-rake expired_hosts:deliver_notifications >>/var/log/foreman/expired_hosts.log 2>&1
@@ -10,7 +10,10 @@ Gem::Specification.new do |s|
10
10
  s.authors = ['Nagarjuna Rachaneni', 'Timo Goebel']
11
11
  s.email = ['nn.nagarjuna@gmail.com', 'mail@timogoebel.name']
12
12
  s.summary = 'Foreman plugin for limiting host lifetime'
13
- s.description = 'This Plugin will add new column expired_on to hosts to limit the lifetime of a host.'
13
+ s.description = <<-DESC
14
+ A Foreman plugin that allows hosts to expire at a configurable date.
15
+ Hosts will be shut down and automatically deleted after a grace period.
16
+ DESC
14
17
  s.homepage = 'https://github.com/theforeman/foreman_expire_hosts'
15
18
  s.licenses = ['GPL-3.0']
16
19
 
@@ -23,7 +26,7 @@ Gem::Specification.new do |s|
23
26
  s.add_dependency 'deface'
24
27
 
25
28
  s.add_development_dependency 'rdoc'
26
- s.add_development_dependency 'rubocop', '0.75.0'
27
- s.add_development_dependency 'rubocop-performance'
28
- s.add_development_dependency 'rubocop-rails', '~> 2.3.2'
29
+ s.add_development_dependency 'rubocop', '~> 0.80.0'
30
+ s.add_development_dependency 'rubocop-performance', '~> 1.5.2'
31
+ s.add_development_dependency 'rubocop-rails', '~> 2.4.2'
29
32
  end
@@ -53,10 +53,10 @@ module ForemanExpireHosts
53
53
 
54
54
  config.to_prepare do
55
55
  begin
56
- Host::Managed.include ForemanExpireHosts::HostExt
57
- HostsHelper.include ForemanExpireHosts::HostsHelperExtensions
58
- HostsController.prepend ForemanExpireHosts::HostControllerExtensions
59
- AuditsHelper.include ForemanExpireHosts::AuditsHelperExtensions
56
+ ::Host::Managed.include ForemanExpireHosts::HostExt
57
+ ::HostsHelper.include ForemanExpireHosts::HostsHelperExtensions
58
+ ::HostsController.prepend ForemanExpireHosts::HostControllerExtensions
59
+ ::AuditsHelper.include ForemanExpireHosts::AuditsHelperExtensions
60
60
  ::Api::V2::HostsController.include ForemanExpireHosts::Api::V2::HostsControllerExtensions
61
61
  rescue StandardError => e
62
62
  Rails.logger.warn "ForemanExpireHosts: skipping engine hook (#{e})"
@@ -69,4 +69,8 @@ module ForemanExpireHosts
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ def self.logger
74
+ Foreman::Logging.logger('foreman_expire_hosts')
75
+ end
72
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanExpireHosts
4
- VERSION = '7.0.0'
4
+ VERSION = '7.0.1'
5
5
  end
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: 7.0.0
4
+ version: 7.0.1
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: 2019-12-10 00:00:00.000000000 Z
12
+ date: 2020-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -43,46 +43,47 @@ dependencies:
43
43
  name: rubocop
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '='
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.75.0
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: 0.75.0
55
+ version: 0.80.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rubocop-performance
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: 1.5.2
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: 1.5.2
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rubocop-rails
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: 2.3.2
76
+ version: 2.4.2
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: 2.3.2
84
- description: This Plugin will add new column expired_on to hosts to limit the lifetime
85
- of a host.
83
+ version: 2.4.2
84
+ description: |
85
+ A Foreman plugin that allows hosts to expire at a configurable date.
86
+ Hosts will be shut down and automatically deleted after a grace period.
86
87
  email:
87
88
  - nn.nagarjuna@gmail.com
88
89
  - mail@timogoebel.name
@@ -138,6 +139,7 @@ files:
138
139
  - config/routes.rb
139
140
  - db/migrate/20150427101516_add_expiry_on_to_hosts.rb
140
141
  - db/seeds.d/80_expire_hosts_ui_notification.rb
142
+ - extra/foreman_expire_hosts.cron
141
143
  - foreman_expire_hosts.gemspec
142
144
  - lib/expire_hosts_notifications.rb
143
145
  - lib/foreman_expire_hosts.rb