Class: ForemanAnsible::InsightsNotificationBuilder
- Inherits:
-
UINotifications::RemoteExecutionJobs::BaseJobFinish
- Object
- UINotifications::RemoteExecutionJobs::BaseJobFinish
- ForemanAnsible::InsightsNotificationBuilder
- Defined in:
- app/services/foreman_ansible/insights_notification_builder.rb
Overview
A class that builds custom notificaton for REX job if it’s insights remediation feature
Instance Method Summary collapse
- #blueprint ⇒ Object
- #deliver! ⇒ Object
- #hosts_count ⇒ Object
- #insights_links ⇒ Object
- #job_links ⇒ Object
- #links ⇒ Object
- #message ⇒ Object
Instance Method Details
#blueprint ⇒ Object
20 21 22 23 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 20 def blueprint name = 'insights_remediation_successful' @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => name) end |
#deliver! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 7 def deliver! ::Notification.create!( :audience => Notification::AUDIENCE_USER, :notification_blueprint => blueprint, :initiator => initiator, :message => , :subject => subject, :actions => { :links => links } ) end |
#hosts_count ⇒ Object
25 26 27 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 25 def hosts_count @hosts_count ||= subject.template_invocations_hosts.size end |
#insights_links ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 38 def insights_links pattern_template = subject.pattern_template_invocations.first plan_id = pattern_template.input_values. joins(:template_input). where('template_inputs.name' => 'plan_id'). first.try(:value) return [] if plan_id.nil? [ { :href => "/redhat_access/insights/planner/#{plan_id}", :title => _('Remediation Plan') } ] end |
#job_links ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 54 def job_links UINotifications::URLResolver.new( subject, :links => [{ :path_method => :job_invocation_path, :title => _('Job Details') }] ).actions[:links] end |
#links ⇒ Object
34 35 36 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 34 def links job_links + insights_links end |
#message ⇒ Object
29 30 31 32 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 29 def UINotifications::StringParser.new(blueprint., :hosts_count => hosts_count) end |