foreman_expire_hosts 3.0.0 → 4.0.0

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -2
  3. data/.rubocop_todo.yml +10 -47
  4. data/README.md +1 -0
  5. data/app/controllers/concerns/foreman_expire_hosts/host_controller_extensions.rb +11 -13
  6. data/app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb +2 -2
  7. data/app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb +8 -11
  8. data/app/mailers/expire_hosts_mailer.rb +72 -20
  9. data/app/models/concerns/foreman_expire_hosts/host_ext.rb +3 -3
  10. data/app/models/host_status/expiration_status.rb +1 -1
  11. data/app/models/setting/expire_hosts.rb +2 -2
  12. data/app/services/foreman_expire_hosts/action/base.rb +57 -0
  13. data/app/services/foreman_expire_hosts/action/delete_expired_hosts.rb +23 -0
  14. data/app/services/foreman_expire_hosts/action/stop_expired_hosts.rb +37 -0
  15. data/app/services/foreman_expire_hosts/expiry_edit_authorizer.rb +21 -0
  16. data/app/services/foreman_expire_hosts/notification/base.rb +71 -0
  17. data/app/services/foreman_expire_hosts/notification/deleted_hosts.rb +15 -0
  18. data/app/services/foreman_expire_hosts/notification/expiry_warning.rb +26 -0
  19. data/app/services/foreman_expire_hosts/notification/failed_deleted_hosts.rb +15 -0
  20. data/app/services/foreman_expire_hosts/notification/failed_stopped_hosts.rb +15 -0
  21. data/app/services/foreman_expire_hosts/notification/stopped_hosts.rb +26 -0
  22. data/app/services/foreman_expire_hosts/safe_destroy.rb +23 -0
  23. data/app/services/foreman_expire_hosts/ui_notifications/hosts/base.rb +68 -0
  24. data/app/services/foreman_expire_hosts/ui_notifications/hosts/expiry_warning.rb +28 -0
  25. data/app/services/foreman_expire_hosts/ui_notifications/hosts/stopped_host.rb +11 -0
  26. data/app/views/expire_hosts_mailer/expiry_warning_notification.html.erb +4 -1
  27. data/app/views/expire_hosts_mailer/stopped_hosts_notification.html.erb +4 -1
  28. data/db/seeds.d/80_expire_hosts_ui_notification.rb +30 -0
  29. data/foreman_expire_hosts.gemspec +2 -2
  30. data/lib/expire_hosts_notifications.rb +7 -104
  31. data/lib/foreman_expire_hosts/engine.rb +14 -8
  32. data/lib/foreman_expire_hosts/version.rb +1 -1
  33. data/lib/tasks/expired_hosts.rake +7 -5
  34. data/test/factories/foreman_expire_hosts_factories.rb +1 -1
  35. data/test/functional/concerns/hosts_controller_extensions_test.rb +8 -6
  36. data/test/lib/expire_hosts_notifications_test.rb +128 -32
  37. data/test/test_plugin_helper.rb +8 -3
  38. data/test/unit/concerns/host_extensions_test.rb +17 -17
  39. data/test/unit/expire_hosts_mailer_test.rb +47 -27
  40. data/test/unit/expiry_edit_authorizer_test.rb +55 -0
  41. data/test/unit/host_status/expiration_status_test.rb +1 -1
  42. data/test/unit/safe_destroy_test.rb +26 -0
  43. metadata +30 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a46f4ef05040228424339f7bb3e64d1f0fd4856
4
- data.tar.gz: 224e1a6a8458ea48fe76246f91d524c644a1e395
3
+ metadata.gz: 93ce6b56c3992acaf75ce33279400688b6feb3c6
4
+ data.tar.gz: c5ebb3c23813c35e438c1e636aaa0f89c265035a
5
5
  SHA512:
6
- metadata.gz: 06f65256c9e252b8e5177208a97051e8563dd4c0e4a0a0163290d8b7d5f1d36948fe4f599bdaf9caef3a129c130b1ea13e20831ca6e1a3b56adb2f8fad5b158f
7
- data.tar.gz: 99313de528e91e2bf57d568616590d88fe0571534cb885c69767472c902507e4b4bdcb4c1130aeda31c019cf84d62dca37212f131e0274c87ec8395a0abee2ee
6
+ metadata.gz: 3c96161b39033fa298be9570693b7f216e8745cd7f615f54055119dcd63c7e2f0c8123e1a40f334bad43f4819233bd8e4c3636daef9c00168ca69bb4986d0044
7
+ data.tar.gz: 17c238e649d88559d2e7708ae0a35b31604d7a201df5721b4ff231c6fe1d4bfc8cac21170a6e2b63b27685eb633b3958a9931f6c9b4489f81bf8ac0aaa697680
data/.rubocop.yml CHANGED
@@ -22,7 +22,7 @@ Rails/ActionFilter:
22
22
  Metrics/MethodLength:
23
23
  Max: 40
24
24
 
25
- Style/AccessorMethodName:
25
+ Naming/AccessorMethodName:
26
26
  Enabled: false
27
27
 
28
28
  Style/RedundantSelf:
@@ -31,7 +31,7 @@ Style/RedundantSelf:
31
31
  Metrics/ClassLength:
32
32
  Max: 500
33
33
 
34
- Style/FileName:
34
+ Naming/FileName:
35
35
  Exclude:
36
36
  - 'db/seeds.d/*'
37
37
 
@@ -52,3 +52,29 @@ Style/EachWithObject:
52
52
 
53
53
  Metrics/ParameterLists:
54
54
  Enabled: false
55
+
56
+ Rails/HttpPositionalArguments:
57
+ Enabled: false
58
+
59
+ Style/SymbolArray:
60
+ Enabled: false
61
+
62
+ Style/FormatString:
63
+ Enabled: false
64
+
65
+ Style/FormatStringToken:
66
+ Enabled: false
67
+
68
+ Style/HashSyntax:
69
+ Enabled: false
70
+
71
+ Rails/HasManyOrHasOneDependent:
72
+ Enabled: false
73
+
74
+ Style/CommentedKeyword:
75
+ Enabled: false
76
+
77
+
78
+ # May be enabled for Foreman >= 1.16
79
+ Rails/ApplicationRecord:
80
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,26 +1,11 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-10-20 20:55:41 +0200 using RuboCop version 0.42.0.
3
+ # on 2017-08-01 16:36:14 +0200 using RuboCop version 0.49.1.
4
4
  # The point is for the user to remove these configuration records
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
8
 
9
- # Offense count: 4
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
12
- Lint/UnusedBlockArgument:
13
- Exclude:
14
- - 'lib/expire_hosts_notifications.rb'
15
- - 'lib/foreman_expire_hosts/engine.rb'
16
-
17
- # Offense count: 1
18
- # Cop supports --auto-correct.
19
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
20
- Lint/UnusedMethodArgument:
21
- Exclude:
22
- - 'app/models/host_status/expiration_status.rb'
23
-
24
9
  # Offense count: 1
25
10
  Lint/UselessAssignment:
26
11
  Exclude:
@@ -30,12 +15,19 @@ Lint/UselessAssignment:
30
15
  Metrics/AbcSize:
31
16
  Max: 51
32
17
 
18
+ # Offense count: 4
19
+ # Configuration parameters: CountComments, ExcludedMethods.
20
+ Metrics/BlockLength:
21
+ Max: 35
22
+ Exclude:
23
+ - 'test/**/*.rb'
24
+
33
25
  # Offense count: 3
34
26
  Metrics/CyclomaticComplexity:
35
27
  Max: 11
36
28
 
37
- # Offense count: 86
38
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
29
+ # Offense count: 89
30
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
39
31
  # URISchemes: http, https
40
32
  Metrics/LineLength:
41
33
  Max: 362
@@ -53,32 +45,3 @@ Metrics/PerceivedComplexity:
53
45
  Rails/OutputSafety:
54
46
  Exclude:
55
47
  - 'app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb'
56
-
57
- # Offense count: 4
58
- # Cop supports --auto-correct.
59
- # Configuration parameters: EnforcedStyle, SupportedStyles.
60
- # SupportedStyles: empty_lines, no_empty_lines
61
- Style/EmptyLinesAroundClassBody:
62
- Exclude:
63
- - 'app/mailers/expire_hosts_mailer.rb'
64
- - 'app/models/setting/expire_hosts.rb'
65
- - 'lib/expire_hosts_notifications.rb'
66
-
67
- # Offense count: 105
68
- # Cop supports --auto-correct.
69
- # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
70
- # SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
71
- Style/HashSyntax:
72
- Enabled: false
73
-
74
- # Offense count: 12
75
- # Cop supports --auto-correct.
76
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
77
- # SupportedStyles: space, no_space, compact
78
- Style/SpaceInsideHashLiteralBraces:
79
- Exclude:
80
- - 'app/controllers/concerns/foreman_expire_hosts/host_controller_extensions.rb'
81
- - 'app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb'
82
- - 'lib/expire_hosts_notifications.rb'
83
- - 'lib/foreman_expire_hosts/engine.rb'
84
- - 'test/functional/concerns/hosts_controller_extensions_test.rb'
data/README.md CHANGED
@@ -15,6 +15,7 @@ This plugin will send two warning notifications before host expiry (see Settings
15
15
  | >= 1.11 | ~> 2.0 |
16
16
  | >= 1.13 | ~> 2.1 |
17
17
  | >= 1.15 | ~> 3.0 |
18
+ | >= 1.16 | ~> 4.0 |
18
19
 
19
20
  # Screenshots
20
21
  ![Expiry date field in host form](https://raw.githubusercontent.com/ingenico-group/screenshots/master/foreman_host_expiry/expiry-date-field-in-host-form.png)
@@ -1,16 +1,14 @@
1
1
  module ForemanExpireHosts
2
2
  module HostControllerExtensions
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- before_filter :validate_multiple_expiration, :only => :update_multiple_expiration
7
- before_filter :find_multiple_with_expire_hosts, :only => [:select_multiple_expiration, :update_multiple_expiration]
8
- alias_method_chain :action_permission, :expire_hosts
9
- alias_method :find_multiple_with_expire_hosts, :find_multiple
3
+ def self.prepended(base)
4
+ base.class_eval do
5
+ before_filter :validate_multiple_expiration, :only => :update_multiple_expiration
6
+ before_filter :find_multiple_with_expire_hosts, :only => [:select_multiple_expiration, :update_multiple_expiration]
7
+ alias_method :find_multiple_with_expire_hosts, :find_multiple
8
+ end
10
9
  end
11
10
 
12
- def select_multiple_expiration
13
- end
11
+ def select_multiple_expiration; end
14
12
 
15
13
  def update_multiple_expiration
16
14
  expiration_date = params[:host][:expired_on]
@@ -22,10 +20,10 @@ module ForemanExpireHosts
22
20
  begin
23
21
  host.expired_on = expiration_date
24
22
  host.save!
25
- rescue => error
23
+ rescue StandardError => error
26
24
  failed_hosts[host.name] = error
27
25
  message = if expiration_date.present?
28
- _('Failed to set expiration date for %{host} to %{expiration_date}.') % {:host => host, :expiration_date => l(expiration_date)}
26
+ _('Failed to set expiration date for %{host} to %{expiration_date}.') % { :host => host, :expiration_date => l(expiration_date) }
29
27
  else
30
28
  _('Failed to clear expiration date for %s.') % host
31
29
  end
@@ -62,12 +60,12 @@ module ForemanExpireHosts
62
60
  end
63
61
  end
64
62
 
65
- def action_permission_with_expire_hosts
63
+ def action_permission
66
64
  case params[:action]
67
65
  when 'select_multiple_expiration', 'update_multiple_expiration'
68
66
  :edit
69
67
  else
70
- action_permission_without_expire_hosts
68
+ super
71
69
  end
72
70
  end
73
71
  end
@@ -3,12 +3,12 @@ module ForemanExpireHosts
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  def destroyed_expired_host_audit_comment_in_list(audit)
6
- return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && !audit.comment.blank?
6
+ return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && audit.comment.present?
7
7
  "<div style='color: #737373;font-size: 14px'>Comment: #{audit.comment}</div>".html_safe
8
8
  end
9
9
 
10
10
  def destroyed_expired_host_audit_comment_in_show(audit)
11
- return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && !audit.comment.blank?
11
+ return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && audit.comment.present?
12
12
  "<tr><td>Comment</td><td>#{audit.comment}</td></tr>".html_safe
13
13
  end
14
14
  end
@@ -1,14 +1,11 @@
1
1
  module ForemanExpireHosts
2
2
  module HostsHelperExtensions
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- alias_method_chain :multiple_actions, :expire_hosts
7
- end
8
-
9
- def multiple_actions_with_expire_hosts
10
- return multiple_actions_without_expire_hosts unless authorized_for(:controller => :hosts, :action => :edit)
11
- multiple_actions_without_expire_hosts + [[_('Change Expiration'), select_multiple_expiration_hosts_path]]
3
+ def multiple_actions
4
+ actions = super
5
+ if authorized_for(:controller => :hosts, :action => :edit)
6
+ actions << [_('Change Expiration'), select_multiple_expiration_hosts_path]
7
+ end
8
+ actions
12
9
  end
13
10
 
14
11
  def host_expiry_warning_message(host)
@@ -16,11 +13,11 @@ module ForemanExpireHosts
16
13
  if host.expired_past_grace_period?
17
14
  message = _('This host has expired %s ago and needs to be deleted manually.') % time_ago_in_words(host.expired_on)
18
15
  elsif host.expired?
19
- 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)}
16
+ 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) }
20
17
  elsif host.expires_today?
21
18
  message = _('This host will expire today.')
22
19
  elsif host.pending_expiration?
23
- 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)}
20
+ 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) }
24
21
  end
25
22
  message
26
23
  end
@@ -1,37 +1,89 @@
1
1
  class ExpireHostsMailer < ApplicationMailer
2
-
3
2
  default :content_type => 'text/html', :from => Setting[:email_reply_address] || 'noreply@your-foreman.com'
4
3
 
5
- def deleted_hosts_notification(emails, hosts)
6
- @hosts = hosts
7
- mail(:to => emails, :subject => _('Deleted expired hosts in Foreman'), :importance => 'High')
4
+ def deleted_hosts_notification(recipient, hosts)
5
+ build_mail(
6
+ recipient: recipient,
7
+ subject: N_('Deleted expired hosts in Foreman'),
8
+ hosts: hosts
9
+ )
8
10
  end
9
11
 
10
- def failed_to_delete_hosts_notification(emails, hosts)
11
- @hosts = hosts
12
- mail(:to => emails, :subject => _('Failed to delete expired hosts in Foreman'), :importance => 'High')
12
+ def failed_to_delete_hosts_notification(recipient, hosts)
13
+ build_mail(
14
+ recipient: recipient,
15
+ subject: N_('Failed to delete expired hosts in Foreman'),
16
+ hosts: hosts
17
+ )
13
18
  end
14
19
 
15
- def stopped_hosts_notification(emails, delete_date, hosts)
16
- @hosts = hosts
20
+ def stopped_hosts_notification(recipient, delete_date, hosts)
17
21
  @delete_date = delete_date
18
- mail(:to => emails, :subject => _('Stopped expired hosts in Foreman'), :importance => 'High') do |format|
19
- format.html { render :layout => 'application_mailer' }
20
- end
22
+ build_mail(
23
+ recipient: recipient,
24
+ subject: N_('Stopped expired hosts in Foreman'),
25
+ hosts: hosts
26
+ )
21
27
  end
22
28
 
23
- def failed_to_stop_hosts_notification(emails, hosts)
29
+ def failed_to_stop_hosts_notification(recipient, hosts)
30
+ build_mail(
31
+ recipient: recipient,
32
+ subject: N_('Failed to stop expired hosts in Foreman'),
33
+ hosts: hosts
34
+ )
35
+ end
36
+
37
+ def expiry_warning_notification(recipient, expiry_date, hosts)
38
+ @expiry_date = expiry_date
39
+ build_mail(
40
+ recipient: recipient,
41
+ subject: N_('Expiring hosts in foreman'),
42
+ hosts: hosts
43
+ )
44
+ end
45
+
46
+ private
47
+
48
+ def build_mail(opts = {})
49
+ recipient = opts[:recipient]
50
+ subject = opts[:subject]
51
+ hosts = opts[:hosts]
52
+ user = user_for_recipient(recipient)
24
53
  @hosts = hosts
25
- mail(:to => emails, :subject => _('Failed to stop expired hosts in Foreman'), :importance => 'High') do |format|
26
- format.html { render :layout => 'application_mailer' }
54
+ @authorized_for_expiry_date_change = ForemanExpireHosts::ExpiryEditAuthorizer.new(
55
+ :user => user,
56
+ :hosts => hosts
57
+ ).authorized?
58
+ set_locale_for(user) do
59
+ mail(
60
+ :to => recipient_mail(recipient),
61
+ :subject => _(subject),
62
+ :importance => 'High'
63
+ ) do |format|
64
+ format.html { render :layout => 'application_mailer' }
65
+ end
27
66
  end
28
67
  end
29
68
 
30
- def expiry_warning_notification(emails, expiry_date, hosts)
31
- @hosts = hosts
32
- @expiry_date = expiry_date
33
- mail(:to => emails, :subject => _('Expiring hosts in foreman'), :importance => 'High') do |format|
34
- format.html { render :layout => 'application_mailer' }
69
+ def user_for_recipient(recipient)
70
+ case recipient
71
+ when Array
72
+ User.anonymous_admin
73
+ when User
74
+ recipient
75
+ else
76
+ raise Foreman::Exception.new(N_('Cannot map recipient %s to user'), recipient.inspect)
35
77
  end
36
78
  end
79
+
80
+ def recipient_mail(recipient)
81
+ return recipient if recipient.is_a?(Array)
82
+ return recipient.mail if recipient.mail.present?
83
+ admin_email
84
+ end
85
+
86
+ def admin_email
87
+ Setting[:administrator]
88
+ end
37
89
  end
@@ -17,7 +17,7 @@ module ForemanExpireHosts
17
17
  scope :expiring_today, -> { expiring.with_expire_date(Date.today) }
18
18
  scope :expired_past_grace_period, -> { expiring.where('expired_on <= ?', Date.today - Setting[:days_to_delete_after_host_expiration].to_i) }
19
19
 
20
- scoped_search :on => :expired_on, :complete_value => :true, :rename => :expires, :only_explicit => true
20
+ scoped_search :on => :expired_on, :complete_value => true, :rename => :expires, :only_explicit => true
21
21
  end
22
22
 
23
23
  def validate_expired_on
@@ -26,7 +26,7 @@ module ForemanExpireHosts
26
26
  unless expired_on.to_s.to_date > Date.today
27
27
  errors.add(:expired_on, _('must be in the future'))
28
28
  end
29
- rescue => e
29
+ rescue StandardError => e
30
30
  errors.add(:expired_on, _('is invalid'))
31
31
  end
32
32
  end
@@ -76,7 +76,7 @@ module ForemanExpireHosts
76
76
  return true if self.owner_type.nil? || self.owner.nil?
77
77
  Setting[:can_owner_modify_host_expiry_date] &&
78
78
  ((self.owner_type == 'User' && self.owner == User.current) ||
79
- (self.owner_type == 'Usergroup' && self.owner.users.include?(User.current)))
79
+ (self.owner_type == 'Usergroup' && self.owner.all_users.include?(User.current)))
80
80
  end
81
81
 
82
82
  private
@@ -50,7 +50,7 @@ module HostStatus
50
50
  end
51
51
  end
52
52
 
53
- def relevant?(options = {})
53
+ def relevant?(_options = {})
54
54
  host.expires?
55
55
  end
56
56
  end
@@ -1,4 +1,5 @@
1
1
  class Setting::ExpireHosts < Setting
2
+ Setting::BLANK_ATTRS.push('host_expiry_email_recipients')
2
3
 
3
4
  def self.load_defaults
4
5
  # Check the table exists
@@ -11,11 +12,10 @@ class Setting::ExpireHosts < Setting
11
12
  self.set('notify1_days_before_host_expiry', N_('Send first notification to owner of hosts about his hosts expiring in given days. Must be integer only'), 7, N_('First expiry notification')),
12
13
  self.set('notify2_days_before_host_expiry', N_('Send second notification to owner of hosts about his hosts expiring in given days. Must be integer only'), 1, N_('Second expiry notification')),
13
14
  self.set('days_to_delete_after_host_expiration', N_('Delete expired hosts after given days of hosts expiry date. Must be integer only'), 3, N_('Expiry grace period in days')),
14
- self.set('host_expiry_email_recipients', N_('All notifications will be delivered to its owner. If any other users/admins need to receive those expiry wanting notifications then those emails can be configured here. This must be string and multiple emails can give with coma(,) separated'), 'foreman-admin@your_foreman.com', N_('Expiry e-mail recipients'))
15
+ self.set('host_expiry_email_recipients', 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.'), nil, N_('Expiry e-mail recipients'))
15
16
  ].each { |s| self.create! s.update(:category => 'Setting::ExpireHosts') }
16
17
  end
17
18
 
18
19
  true
19
20
  end
20
-
21
21
  end
@@ -0,0 +1,57 @@
1
+ module ForemanExpireHosts
2
+ module Action
3
+ class Base
4
+ attr_accessor :successful_hosts, :failed_hosts
5
+
6
+ def initialize
7
+ self.successful_hosts = []
8
+ self.failed_hosts = []
9
+ end
10
+
11
+ def engage
12
+ process
13
+ notify
14
+ end
15
+
16
+ private
17
+
18
+ def process
19
+ hosts.each do |host|
20
+ if action(host)
21
+ self.successful_hosts << host
22
+ else
23
+ self.failed_hosts << host
24
+ end
25
+ end
26
+ end
27
+
28
+ def notify
29
+ success_notification.new(
30
+ success_notification_options
31
+ ).deliver
32
+ failure_notification.new(
33
+ failure_notification_options
34
+ ).deliver
35
+ end
36
+
37
+ def hosts
38
+ selector.preload(:owner)
39
+ end
40
+
41
+ def success_notification_options
42
+ {
43
+ :hosts => successful_hosts
44
+ }
45
+ end
46
+
47
+ def failure_notification_options
48
+ {
49
+ :hosts => failed_hosts,
50
+ :to => User.anonymous_admin
51
+ }
52
+ end
53
+
54
+ delegate :logger, :to => :Rails
55
+ end
56
+ end
57
+ end