Skip to content

Commit

Permalink
Merge pull request #15 from billfitzgerald0120/cnotify_ansible
Browse files Browse the repository at this point in the history
Automate - Notification for Ansible and Cloud provisioning errors.
(cherry picked from commit ee6b46b)
  • Loading branch information
mkanoor authored and simaishi committed Mar 30, 2017
1 parent f5ac67c commit 70abcc2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Description: This method updates the service provision status.
# Required inputs: status
#

module ManageIQ
module Automate
module AutomationManagement
Expand All @@ -22,7 +22,13 @@ def main
raise "Service Template Provision Task not provided"
end

update_status_message(prov, @handle.inputs['status'])
updated_message = update_status_message(prov, @handle.inputs['status'])

if @handle.root['ae_result'] == "error"
@handle.create_notification(:level => "error",
:subject => prov.miq_request,
:message => "Instance Provision Error: #{updated_message}")
end
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ def main
raise "Service Template Provision Task not provided"
end

update_status_message(prov, @handle.inputs['status'])
updated_message = update_status_message(prov, @handle.inputs['status'])

if @handle.root['ae_result'] == "error"
@handle.create_notification(:level => "error",
:subject => prov.miq_request,
:message => "Instance Provision Error: #{updated_message}")
end
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ def main
raise "Service Template Provision Task not provided"
end

update_status_message(prov, @handle.inputs['status'])
updated_message = update_status_message(prov, @handle.inputs['status'])

if @handle.root['ae_result'] == 'error'
@handle.create_notification(:level => 'error',
:subject => prov.miq_request,
:message => "Ansible Tower Provision Error: #{updated_message}")
end
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
msg = "Server [#{miq_server.name}] Service [#{service_orchestration.name}] Step [] Status [fred] Message [] "
expect(svc_model_request.reload.message).to eq(msg)
end

it "creates notification due to ae_result is 'error'" do
ae_service.root['ae_result'] = "error"
expect(ae_service).to receive(:create_notification)
described_class.new(ae_service).main
end
end

context "without a stp request object" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
msg = "Server [#{miq_server.name}] Service [#{service_orchestration.name}] Step [] Status [fred] Message [] "
expect(svc_model_request.reload.message).to eq(msg)
end

it "creates notification due to ae_result is 'error'" do
ae_service.root['ae_result'] = "error"
expect(ae_service).to receive(:create_notification)
described_class.new(ae_service).main
end
end

context "without a stp request object" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
msg = "Server [#{miq_server.name}] Service [#{service_orchestration.name}] Step [] Status [fred] Message [] "
expect(svc_model_request.reload.message).to eq(msg)
end

it "creates notification due to ae_result is 'error'" do
ae_service.root['ae_result'] = "error"
expect(ae_service).to receive(:create_notification)
described_class.new(ae_service).main
end
end

context "without a stp request object" do
Expand Down

0 comments on commit 70abcc2

Please sign in to comment.