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

Fix rescue during PXE and ISO provisioning #24

Merged
merged 1 commit into from
May 2, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module ManageIQ::Providers::Redhat::InfraManager::OvirtServices
require_nested :OvirtServices
class Error < StandardError; end
class VmNotReadyToBoot < Error; end
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def powered_off_in_provider?
end

def powered_on_in_provider?
destination.ext_management_system.ovirt_service.powered_on_in_provider?(destination)
destination.ext_management_system.ovirt_services.powered_on_in_provider?(destination)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def boot_from_cdrom

begin
ext_management_system.ovirt_services.vm_boot_from_cdrom(self, iso_image.name)
rescue OvirtServices::VmNotReadyToBoot
rescue ManageIQ::Providers::Redhat::InfraManager::OvirtServices::VmNotReadyToBoot
_log.info("#{destination_type} [#{dest_name}] is not yet ready to boot, will retry")
requeue_phase
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def boot_from_network
update_and_notify_parent(:message => message)

begin
ext_management_system.ovirt_services.vm_boot_from_network(self)
rescue OvirtServices::VmNotReadyToBoot
destination.ext_management_system.ovirt_services.vm_boot_from_network(self)
rescue ManageIQ::Providers::Redhat::InfraManager::OvirtServices::VmNotReadyToBoot
_log.info("#{destination_type} [#{dest_name}] is not yet ready to boot, will retry")
requeue_phase
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
before do
ems = FactoryGirl.create(:ems_redhat_with_authentication)
template = FactoryGirl.create(:template_redhat, :ext_management_system => ems)
vm = FactoryGirl.create(:vm_redhat)
options = {:src_vm_id => template.id}
@task = FactoryGirl.create(:miq_provision_redhat_via_pxe, :source => template, :destination => vm,
@vm = FactoryGirl.create(:vm_redhat, :ext_management_system => ems)
options = {:src_vm_id => template.id}
@task = FactoryGirl.create(:miq_provision_redhat_via_pxe, :source => template, :destination => @vm,
:state => 'pending', :status => 'Ok', :options => options)
allow(@task).to receive(:destination_image_locked?).and_return(false)
@ovirt_services = double("ovirt_services")
allow(ems).to receive(:ovirt_services).and_return(@ovirt_services)
allow(@task).to receive(:update_and_notify_parent).and_return(nil)
end

include_examples "common rhev state machine methods"
Expand All @@ -16,5 +19,30 @@
expect(@task).to receive(:create_pxe_configuration_file)
@task.configure_destination
end
describe "#boot_from_network" do
context "vm is ready" do
before do
allow(@ovirt_services).to receive(:vm_boot_from_network).with(@task).and_return(nil)
end

it "#powered_on_in_provider?" do
expect(@ovirt_services).to receive(:powered_on_in_provider?).with(@vm)
@task.boot_from_network
end
end

context "vm is not ready" do
before do
exception = ManageIQ::Providers::Redhat::InfraManager::OvirtServices::VmNotReadyToBoot
allow(@ovirt_services).to receive(:vm_boot_from_network).with(@task)
.and_raise(exception)
end

it "requeues the phase" do
expect(@task).to receive(:requeue_phase)
@task.boot_from_network
end
end
end
end
end