Skip to content

Commit

Permalink
Automate - Notification for Ansible and Cloud provisioning errors.
Browse files Browse the repository at this point in the history
This sends a notification with an error occurs.

Modified update_serviceprovision_status methods in
Cloud/Orchestration/Provisioning/StateMachines/Provision/ and
ConfigurationManagement/AnsibleTower/Service/Provisioning/StateMachines/Provision
Methods class.
  • Loading branch information
billfitzgerald0120 committed Jan 4, 2017
1 parent f4a1913 commit d777eaf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@
if $evm.root['ae_result'] == 'retry'
prov.miq_request.user_message = updated_message
prov.message = status

if $evm.root['ae_result'] == "error"
$evm.create_notification(:level => 'error', :subject => prov.miq_request, \
:message => "Instance Provision Error: #{updated_message}")
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
updated_message += "Step [#{$evm.root['ae_state']}] "
updated_message += "Status [#{status}] "
updated_message += "Message [#{prov.message}] "
updated_message += "Current Retry Number [#{$evm.root['ae_state_retries']}]"\
if $evm.root['ae_result'] == 'retry'
updated_message += "Current Retry Number [#{$evm.root['ae_state_retries']}]" if $evm.root['ae_result'] == 'retry'
prov.miq_request.user_message = updated_message
prov.message = status

if $evm.root['ae_result'] == 'error'
$evm.create_notification(:level => 'error', :subject => prov.miq_request, \
:message => "Ansible Tower Provision Error: #{updated_message}")
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
let(:user) { FactoryGirl.create(:user_with_group) }
let(:miq_server) { EvmSpecHelper.local_miq_server }
let(:miq_request_task) do
FactoryGirl.create(:miq_request_task, :destination => service_orchestration,
:miq_request => request, :state => 'fred')
FactoryGirl.create(:miq_request_task,
:destination => service_orchestration,
:miq_request => request,
:state => 'fred')
end
let(:request) do
FactoryGirl.create(:service_template_provision_request, :requester => user)
Expand Down Expand Up @@ -68,6 +70,19 @@
add_call_method
expect(ws.root).to be_nil
end

it 'Cloud Orchestration Class Error notification' do
@args = "status=fred&ae_result=error&MiqRequestTask::service_template_provision_task=#{miq_request_task.id}&" \
"MiqServer::miq_server=#{miq_server.id}"
type = :automate_user_error
FactoryGirl.create(:notification_type, :name => type)

expect(Notification.count).to eq(0)
add_call_method
ws
expect(request.reload.status).to eq('Ok')
expect(Notification.find_by(:notification_type_id => NotificationType.find_by_name(type).id)).not_to be_nil
end
end
context "AnsibleTower Class" do
let(:ws) do
Expand Down Expand Up @@ -98,5 +113,18 @@
add_call_method
expect(ws.root).to be_nil
end

it 'AnsibleTower Class Error notification' do
@args = "status=fred&ae_result=error&MiqRequestTask::service_template_provision_task=#{miq_request_task.id}&" \
"MiqServer::miq_server=#{miq_server.id}"
type = :automate_user_error
FactoryGirl.create(:notification_type, :name => type)

expect(Notification.count).to eq(0)
add_call_method
ws
expect(request.reload.status).to eq('Ok')
expect(Notification.find_by(:notification_type_id => NotificationType.find_by_name(type).id)).not_to be_nil
end
end
end
end

0 comments on commit d777eaf

Please sign in to comment.