Skip to content

Commit

Permalink
Merge pull request #18012 from AparnaKarve/backend_notifications_for_…
Browse files Browse the repository at this point in the history
…v2v_requests

Backend-initiated notifications in v2v for Successful and Failed Requests
  • Loading branch information
roliveri authored Oct 24, 2018
2 parents 9caf12f + 70f33e1 commit 14bdeb9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/service_template_transformation_plan_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ def cancel
update_attributes(:cancelation_status => MiqRequest::CANCEL_STATUS_REQUESTED)
miq_request_tasks.each(&:cancel)
end

def update_request_status
super
if request_state == 'finished' && status == 'Ok'
Notification.create(:type => "transformation_plan_request_succeeded", :options => {:plan_name => description})
elsif request_state == 'finished' && status != 'Ok'
Notification.create(:type => "transformation_plan_request_failed", :options => {:plan_name => description}, :subject => self)
end
end
end
11 changes: 11 additions & 0 deletions db/fixtures/notification_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
:expires_in: 14.days
:level: :warning
:audience: group
- :name: transformation_plan_request_succeeded
:message: Plan %{plan_name} has completed successfully
:expires_in: 14.days
:level: :success
:audience: global
- :name: transformation_plan_request_failed
:message: Plan %{plan_name} has completed with errors
:expires_in: 14.days
:level: :error
:audience: global
:link_to: "subject"
- :name: automate_user_success
:message: '%{message}'
:expires_in: 24.hours
Expand Down

0 comments on commit 14bdeb9

Please sign in to comment.