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 rubocop:disable LineLength
Instance Method Summary collapse
- #blueprint ⇒ Object
-
#deliver! ⇒ Object
rubocop:enable LineLength.
- #hosts_count ⇒ Object
- #insights_links ⇒ Object
- #job_links ⇒ Object
- #links ⇒ Object
- #message ⇒ Object
Instance Method Details
#blueprint ⇒ Object
22 23 24 25 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 22 def blueprint name = 'insights_remediation_successful' @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => name) end |
#deliver! ⇒ Object
rubocop:enable LineLength
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 9 def deliver! ::Notification.create!( :audience => Notification::AUDIENCE_USER, :notification_blueprint => blueprint, :initiator => initiator, :message => , :subject => subject, :actions => { :links => links } ) end |
#hosts_count ⇒ Object
27 28 29 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 27 def hosts_count @hosts_count ||= subject.template_invocations_hosts.size end |
#insights_links ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 40 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
56 57 58 59 60 61 62 63 64 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 56 def job_links UINotifications::URLResolver.new( subject, :links => [{ :path_method => :job_invocation_path, :title => _('Job Details') }] ).actions[:links] end |
#links ⇒ Object
36 37 38 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 36 def links job_links + insights_links end |
#message ⇒ Object
31 32 33 34 |
# File 'app/services/foreman_ansible/insights_notification_builder.rb', line 31 def UINotifications::StringParser.new(blueprint., :hosts_count => hosts_count) end |