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

[V2V] Expose virt-v2v-wrapper error message in options hash #18564

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
1 change: 1 addition & 0 deletions app/models/service_template_transformation_plan_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def get_conversion_state
updates = {}
virtv2v_state = conversion_host.get_conversion_state(options[:virtv2v_wrapper]['state_file'])
updated_disks = virtv2v_disks
updates[:virtv2v_message] = virtv2v_state['last_message']['message'] if virtv2v_state['last_message'].present?
if virtv2v_state['finished'].nil?
updated_disks.each do |disk|
matching_disks = virtv2v_state['disks'].select { |d| d['path'] == disk[:path] }
Expand Down
22 changes: 14 additions & 8 deletions spec/models/service_template_transformation_plan_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,21 +387,26 @@
it "raises when conversion is failed" do
allow(conversion_host).to receive(:get_conversion_state).with(task.options[:virtv2v_wrapper]['state_file']).and_return(
{
"failed" => true,
"finished" => true,
"started" => true,
"disks" => [
"failed" => true,
"finished" => true,
"started" => true,
"disks" => [
{ "path" => src_disk_1.filename, "progress" => 23.0 },
{ "path" => src_disk_1.filename, "progress" => 0.0 }
],
"pid" => 5855,
"return_code" => 1,
"disk_count" => 2
"pid" => 5855,
"return_code" => 1,
"disk_count" => 2,
"last_message" => {
"message" => "virt-v2v failed somehow",
"type" => "error"
}
}
)
expect { task_1.get_conversion_state }.to raise_error("Disks transformation failed.")
expect(task_1.options[:virtv2v_status]).to eq('failed')
epxect(task_1.options[:virtv2v_finished_on]).to eq(time_now.strftime('%Y-%m-%d %H:%M:%S'))
expect(task_1.options[:virtv2v_finished_on]).to eq(time_now.strftime('%Y-%m-%d %H:%M:%S'))
expect(task_1.options[:virtv2v_message]).to eq('virt-v2v failed somehow')
end

it "updates disks progress" do
Expand Down Expand Up @@ -449,6 +454,7 @@
)
expect(task_1.options[:virtv2v_status]).to eq('finished')
epxect(task_1.options[:virtv2v_finished_on]).to eq(time)
expect(task_1.options[:virtv2v_message]).to be_nil
end
end

Expand Down