Skip to content

Commit

Permalink
Merge pull request #18564 from fdupont-redhat/v2v_error_reporting_exp…
Browse files Browse the repository at this point in the history
…ose_virtv2v_message

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

(cherry picked from commit a617d3c)

https://bugzilla.redhat.com/show_bug.cgi?id=1693747
  • Loading branch information
agrare authored and simaishi committed Apr 4, 2019
1 parent ba60e64 commit aa22a82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
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

0 comments on commit aa22a82

Please sign in to comment.