Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate - Notification for Ansible and Cloud provisioning errors. #15

Merged
merged 3 commits into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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