From 646a1597079695cf0004beb35f467ff447e7625d Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 11:59:26 -0400 Subject: [PATCH 01/13] Revert "Merge pull request #20102 from fdupont-redhat/v2v_bz_1825023" This reverts commit eca97f587617c57b9043da6d0a0c1791fa22cce8, reversing changes made to 5f2b43ae8c8457e2dd1acfd001978124410d0d73. --- app/models/service_template_transformation_plan_task.rb | 1 - spec/models/service_template_transformation_plan_task_spec.rb | 3 --- 2 files changed, 4 deletions(-) diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index d95e698c3b2..eb932bf848b 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -425,7 +425,6 @@ def conversion_options_source_provider_vmwarews_ssh(storage) :path => "/vmfs/volumes/#{Addressable::URI.escape(storage.name)}/#{Addressable::URI.escape(source.location)}" ).to_s, :vmware_password => source.host.authentication_password, - :ssh_key_file => '/var/lib/uci/ssh_private_key', :two_phase => two_phase?, :warm => false, :daemonize => false diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index ab0c2a64159..a5bab4d2bf2 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -661,7 +661,6 @@ :vmware_fingerprint => '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67', :vmware_uri => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :vmware_password => 'esx_passwd', - :ssh_key_file => '/var/lib/uci/ssh_private_key', :rhv_url => "https://#{redhat_ems.hostname}/ovirt-engine/api", :rhv_cluster => redhat_cluster.name, :rhv_storage => redhat_storages.first.name, @@ -686,7 +685,6 @@ :vmware_fingerprint => '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67', :vmware_uri => "ssh://root@192.168.254.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :vmware_password => 'esx_passwd', - :ssh_key_file => '/var/lib/uci/ssh_private_key', :rhv_url => "https://#{redhat_ems.hostname}/ovirt-engine/api", :rhv_cluster => redhat_cluster.name, :rhv_storage => redhat_storages.first.name, @@ -835,7 +833,6 @@ :vmware_fingerprint => '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67', :vmware_uri => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :vmware_password => 'esx_passwd', - :ssh_key_file => '/var/lib/uci/ssh_private_key', :osp_environment => { :os_auth_url => URI::Generic.build( :scheme => openstack_ems.security_protocol == 'non-ssl' ? 'http' : 'https', From 43209a1cfddf3bf2ae95510273a042b120840dac Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 11:59:51 -0400 Subject: [PATCH 02/13] Revert "Merge pull request #20011 from fdupont-redhat/v2v_enable_two_phase_for_ssh" This reverts commit 2ef15ce8a917125017bd6c6062173f262651e57e, reversing changes made to fcfb16d7426412a7c14c5821598a6def88dbe15b. --- app/models/infra_conversion_job.rb | 6 ++-- ...rvice_template_transformation_plan_task.rb | 26 +++++----------- spec/models/infra_conversion_job_spec.rb | 9 +++--- ..._template_transformation_plan_task_spec.rb | 31 +++++-------------- 4 files changed, 23 insertions(+), 49 deletions(-) diff --git a/app/models/infra_conversion_job.rb b/app/models/infra_conversion_job.rb index ad98cd2a7f1..a49f7a46bd6 100644 --- a/app/models/infra_conversion_job.rb +++ b/app/models/infra_conversion_job.rb @@ -490,9 +490,7 @@ def poll_transform_vm_complete migration_task.get_conversion_state case migration_task.options[:virtv2v_status] when 'active' - if migration_task.two_phase? - update_migration_task_progress(:on_retry, :message => 'Converting disks') - else + unless migration_task.warm_migration? virtv2v_disks = migration_task.options[:virtv2v_disks] converted_disks = virtv2v_disks.reject { |disk| disk[:percent].zero? } if converted_disks.empty? @@ -504,6 +502,8 @@ def poll_transform_vm_complete message = "Converting disk #{converted_disks.length} / #{virtv2v_disks.length} [#{percent.round(2)}%]." end update_migration_task_progress(:on_retry, :message => message, :percent => percent) + else + update_migration_task_progress(:on_retry, :message => 'Warm migration in progress') end queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) when 'failed' diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index eb932bf848b..8c775995cb3 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -66,8 +66,7 @@ def preflight_check raise 'OSP destination and source power_state is off' if destination_ems.emstype == 'openstack' && source.power_state == 'off' update_options( :source_vm_power_state => source.power_state, # This will determine power_state of destination_vm - :source_vm_ipaddresses => source.ipaddresses, # This will determine if we need to wait for ip addresses to appear - :two_phase => two_phase? # This will help the UI to know how to display the data + :source_vm_ipaddresses => source.ipaddresses # This will determine if we need to wait for ip addresses to appear ) destination_cluster preflight_check_vm_exists_in_destination @@ -99,10 +98,6 @@ def preflight_check_vm_exists_in_destination_openstack end end - def two_phase? - source.snapshots.empty? - end - def source_cluster source.ems_cluster end @@ -276,7 +271,7 @@ def get_conversion_state updates[:virtv2v_message] = virtv2v_state['last_message']['message'] if virtv2v_state['last_message'].present? if virtv2v_state['finished'].nil? updates[:virtv2v_status] = virtv2v_state['status'] == 'Paused' ? 'paused' : 'active' - if two_phase? + if warm_migration? updated_disks = virtv2v_state['disks'] else updated_disks.each do |disk| @@ -302,7 +297,7 @@ def get_conversion_state rescue failures = options[:get_conversion_state_failures] || 0 update_options(:get_conversion_state_failures => failures + 1) - raise "Failed to get conversion state 20 times in a row" if options[:get_conversion_state_failures] > 20 + raise "Failed to get conversion state 5 times in a row" if options[:get_conversion_state_failures] > 5 ensure _log.info("InfraConversionJob get_conversion_state to update_options: #{updates}") update_options(updates) @@ -405,7 +400,7 @@ def conversion_options_source_provider_vmwarews_vddk(_storage) :query => { :no_verify => 1 }.to_query ).to_s, :vmware_password => source.host.authentication_password, - :two_phase => two_phase?, + :two_phase => warm_migration?, :warm => warm_migration?, :daemonize => false } @@ -413,20 +408,15 @@ def conversion_options_source_provider_vmwarews_vddk(_storage) def conversion_options_source_provider_vmwarews_ssh(storage) { - :vm_name => source.name, - :vm_uuid => source.uid_ems, - :conversion_host_uuid => conversion_host_resource_ref(conversion_host.resource), - :transport_method => 'ssh', - :vmware_fingerprint => source.host.thumbprint_sha1, - :vmware_uri => URI::Generic.build( + :vm_name => URI::Generic.build( :scheme => 'ssh', :userinfo => 'root', :host => source.host.miq_custom_get('TransformationIPAddress') || source.host.ipaddress, :path => "/vmfs/volumes/#{Addressable::URI.escape(storage.name)}/#{Addressable::URI.escape(source.location)}" ).to_s, - :vmware_password => source.host.authentication_password, - :two_phase => two_phase?, - :warm => false, + :vm_uuid => source.uid_ems, + :conversion_host_uuid => conversion_host_resource_ref(conversion_host.resource), + :transport_method => 'ssh', :daemonize => false } end diff --git a/spec/models/infra_conversion_job_spec.rb b/spec/models/infra_conversion_job_spec.rb index 132d5c4b4b5..5fa5a33b1bb 100644 --- a/spec/models/infra_conversion_job_spec.rb +++ b/spec/models/infra_conversion_job_spec.rb @@ -1501,7 +1501,6 @@ it 'returns a message stating conversion has not started' do task.update_options(:virtv2v_status => 'active', :virtv2v_disks => virtv2v_disks) - allow(job.migration_task).to receive(:two_phase?).and_return(false) Timecop.freeze(2019, 2, 6) do expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry).and_call_original expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry, :message => 'Disk transformation is initializing.', :percent => 1).and_call_original @@ -1523,9 +1522,9 @@ ] end - it "updates message and percentage, and retries if conversion is one-phase and not finished" do + it "updates message and percentage, and retries if conversion is cold and not finished" do task.update_options(:virtv2v_status => 'active', :virtv2v_disks => virtv2v_disks) - allow(job.migration_task).to receive(:two_phase?).and_return(false) + allow(job.migration_task).to receive(:warm_migration?).and_return(false) Timecop.freeze(2019, 2, 6) do expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry).and_call_original expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry, :message => 'Converting disk 2 / 2 [43.75%].', :percent => 43.75).and_call_original @@ -1538,12 +1537,12 @@ end end - it "retries if conversion is two-phase and not finished" do + it "retries if conversion is warm and not finished" do task.update_options(:virtv2v_status => 'active', :virtv2v_disks => virtv2v_disks) allow(job.migration_task).to receive(:warm_migration?).and_return(true) Timecop.freeze(2019, 2, 6) do expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry).and_call_original - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry, :message => 'Converting disks') + expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry, :message => 'Warm migration in progress') expect(job).to receive(:queue_signal).with(:poll_transform_vm_complete, :deliver_on => Time.now.utc + job.state_retry_interval) job.signal(:poll_transform_vm_complete) end diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index a5bab4d2bf2..cf7ffd45895 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -399,18 +399,18 @@ ) end - it "rescues when conversion_host.get_conversion_state fails less than 20 times" do + it "rescues when conversion_host.get_conversion_state fails less than 5 times" do task_1.update_options(:get_conversion_state_failures => 2) allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_raise("Fake error") task_1.get_conversion_state expect(task_1.options[:get_conversion_state_failures]).to eq(3) end - it "rescues when conversion_host.get_conversion_state fails more than 20 times" do - task_1.update_options(:get_conversion_state_failures => 20) + it "rescues when conversion_host.get_conversion_state fails more than 5 times" do + task_1.update_options(:get_conversion_state_failures => 5) allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_raise("Fake error") - expect { task_1.get_conversion_state }.to raise_error("Failed to get conversion state 20 times in a row") - expect(task_1.options[:get_conversion_state_failures]).to eq(21) + expect { task_1.get_conversion_state }.to raise_error("Failed to get conversion state 5 times in a row") + expect(task_1.options[:get_conversion_state_failures]).to eq(6) end it "updates progress when conversion is failed" do @@ -654,13 +654,10 @@ it "generates conversion options hash" do expect(task_1.conversion_options).to eq( - :vm_name => src_vm_1.name, + :vm_name => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :vm_uuid => src_vm_1.uid_ems, :conversion_host_uuid => conversion_host.resource.ems_ref, :transport_method => 'ssh', - :vmware_fingerprint => '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67', - :vmware_uri => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", - :vmware_password => 'esx_passwd', :rhv_url => "https://#{redhat_ems.hostname}/ovirt-engine/api", :rhv_cluster => redhat_cluster.name, :rhv_storage => redhat_storages.first.name, @@ -669,8 +666,6 @@ :network_mappings => task_1.network_mappings, :install_drivers => true, :insecure_connection => true, - :two_phase => true, - :warm => false, :daemonize => false ) end @@ -678,13 +673,10 @@ it "generates conversion options hash with host custom IP address" do src_host.miq_custom_set('TransformationIPAddress', '192.168.254.1') expect(task_1.conversion_options).to eq( - :vm_name => src_vm_1.name, + :vm_name => "ssh://root@192.168.254.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :vm_uuid => src_vm_1.uid_ems, :conversion_host_uuid => conversion_host.resource.ems_ref, :transport_method => 'ssh', - :vmware_fingerprint => '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67', - :vmware_uri => "ssh://root@192.168.254.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", - :vmware_password => 'esx_passwd', :rhv_url => "https://#{redhat_ems.hostname}/ovirt-engine/api", :rhv_cluster => redhat_cluster.name, :rhv_storage => redhat_storages.first.name, @@ -693,8 +685,6 @@ :network_mappings => task_1.network_mappings, :install_drivers => true, :insecure_connection => true, - :two_phase => true, - :warm => false, :daemonize => false ) end @@ -826,13 +816,10 @@ it "generates conversion options hash" do expect(task_1.conversion_options).to eq( - :vm_name => src_vm_1.name, + :vm_name => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", :vm_uuid => src_vm_1.uid_ems, :conversion_host_uuid => conversion_host.ems_ref, :transport_method => 'ssh', - :vmware_fingerprint => '01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef:01:23:45:67', - :vmware_uri => "ssh://root@10.0.0.1/vmfs/volumes/stockage%20r%C3%A9cent/#{src_vm_1.location}", - :vmware_password => 'esx_passwd', :osp_environment => { :os_auth_url => URI::Generic.build( :scheme => openstack_ems.security_protocol == 'non-ssl' ? 'http' : 'https', @@ -853,8 +840,6 @@ :osp_security_groups_ids => [openstack_security_group.ems_ref], :source_disks => [src_disk_1.filename, src_disk_2.filename], :network_mappings => task_1.network_mappings, - :two_phase => true, - :warm => false, :daemonize => false ) end From 9852ae34cee026c1454b00f7f8edd641a1238f57 Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:00:17 -0400 Subject: [PATCH 03/13] Revert "Merge pull request #20040 from fdupont-redhat/bz_1817096_2" This reverts commit 65c2add79a38a44e134576be953969fa2fcebb32, reversing changes made to 369433b64de9bb0fccfd118890256ad94d3697bd. --- app/models/infra_conversion_job.rb | 4 +--- spec/models/infra_conversion_job_spec.rb | 14 +------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/models/infra_conversion_job.rb b/app/models/infra_conversion_job.rb index a49f7a46bd6..d0a51545df8 100644 --- a/app/models/infra_conversion_job.rb +++ b/app/models/infra_conversion_job.rb @@ -502,10 +502,8 @@ def poll_transform_vm_complete message = "Converting disk #{converted_disks.length} / #{virtv2v_disks.length} [#{percent.round(2)}%]." end update_migration_task_progress(:on_retry, :message => message, :percent => percent) - else - update_migration_task_progress(:on_retry, :message => 'Warm migration in progress') + queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) end - queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) when 'failed' raise migration_task.options[:virtv2v_message] when 'succeeded' diff --git a/spec/models/infra_conversion_job_spec.rb b/spec/models/infra_conversion_job_spec.rb index 5fa5a33b1bb..1835b3403be 100644 --- a/spec/models/infra_conversion_job_spec.rb +++ b/spec/models/infra_conversion_job_spec.rb @@ -1522,9 +1522,8 @@ ] end - it "updates message and percentage, and retries if conversion is cold and not finished" do + it "updates message and percentage, and retries if conversion is not finished" do task.update_options(:virtv2v_status => 'active', :virtv2v_disks => virtv2v_disks) - allow(job.migration_task).to receive(:warm_migration?).and_return(false) Timecop.freeze(2019, 2, 6) do expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry).and_call_original expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry, :message => 'Converting disk 2 / 2 [43.75%].', :percent => 43.75).and_call_original @@ -1537,17 +1536,6 @@ end end - it "retries if conversion is warm and not finished" do - task.update_options(:virtv2v_status => 'active', :virtv2v_disks => virtv2v_disks) - allow(job.migration_task).to receive(:warm_migration?).and_return(true) - Timecop.freeze(2019, 2, 6) do - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry).and_call_original - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry, :message => 'Warm migration in progress') - expect(job).to receive(:queue_signal).with(:poll_transform_vm_complete, :deliver_on => Time.now.utc + job.state_retry_interval) - job.signal(:poll_transform_vm_complete) - end - end - it "aborts if conversion failed" do task.update_options(:virtv2v_status => 'failed', :virtv2v_message => 'virt-v2v failed for some reason') expect(job).to receive(:abort_conversion).with('virt-v2v failed for some reason', 'error').and_call_original From 52989bdee8886bc4d5ea521cef21ed6831c63b8f Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:00:34 -0400 Subject: [PATCH 04/13] Revert "Merge pull request #20012 from fdupont-redhat/v2v_bz_1817151" This reverts commit d3a5da9e64b6bf6e7061d559b027fbfeda0cc0e1, reversing changes made to c2a97a01c77381e20fc3dfbdf265f37dd56593e8. --- app/models/conversion_host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index b0ff002d94b..1c7c52c4b38 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -300,7 +300,7 @@ def create_cutover_file(task_id) # if no signal is specified. # def kill_virtv2v(task_id, signal = 'TERM') - command = AwesomeSpawn.build_command_line("/usr/bin/podman", ["exec", "conversion-#{task_id}", "/usr/bin/killall", :signal, signal, "virt-v2v"]) + command = AwesomeSpawn.build_command_line("/usr/bin/podman", ["exec", "conversion-#{task_id}", "/usr/bin/killall", :s, signal, "virt-v2v"]) connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } true rescue From 4bf01892935c503cc70680ccfeb642e5fe172c4d Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:00:56 -0400 Subject: [PATCH 05/13] Revert "Merge pull request #19989 from fdupont-redhat/v2v_bz_1814258_2" This reverts commit 394f54a4c90a43a33021ce8b458fc7f3518e62c0, reversing changes made to 6195fdb3f93e49bb8657f7ca26e696fa455ef36e. --- app/models/conversion_host.rb | 8 -------- app/models/infra_conversion_job.rb | 8 ++------ app/models/service_template_transformation_plan_task.rb | 6 ------ spec/models/infra_conversion_job_spec.rb | 2 +- 4 files changed, 3 insertions(+), 21 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 1c7c52c4b38..1535a3d815f 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -280,14 +280,6 @@ def create_pause_disks_precopy_file(task_id) false end - def delete_pause_disks_precopy_file(task_id) - command = AwesomeSpawn.build_command_line("rm", {:f =>["/var/lib/uci/#{task_id}/pause_operations"]}) - connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } - true - rescue - false - end - def create_cutover_file(task_id) command = AwesomeSpawn.build_command_line("touch", ["/var/lib/uci/#{task_id}/cutover"]) connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } diff --git a/app/models/infra_conversion_job.rb b/app/models/infra_conversion_job.rb index d0a51545df8..4250e288618 100644 --- a/app/models/infra_conversion_job.rb +++ b/app/models/infra_conversion_job.rb @@ -470,12 +470,8 @@ def poll_shutdown_vm_complete def transform_vm update_migration_task_progress(:on_entry) - if migration_task.warm_migration? - migration_task.cutover - migration_task.unpause_disks_precopy - else - migration_task.run_conversion - end + migration_task.run_conversion unless migration_task.warm_migration? + migration_task.cutover update_migration_task_progress(:on_exit) queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) rescue => error diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 8c775995cb3..61f260929c8 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -309,12 +309,6 @@ def pause_disks_precopy end end - def unpause_disks_precopy - unless conversion_host.delete_pause_disks_precopy_file(id) - raise _("Couldn't delete disks precopy pause file for #{source.name} on #{conversion_host.name}") - end - end - def cutover unless conversion_host.create_cutover_file(id) raise _("Couldn't create cutover file for #{source.name} on #{conversion_host.name}") diff --git a/spec/models/infra_conversion_job_spec.rb b/spec/models/infra_conversion_job_spec.rb index 1835b3403be..fb70ec2e9f5 100644 --- a/spec/models/infra_conversion_job_spec.rb +++ b/spec/models/infra_conversion_job_spec.rb @@ -1461,6 +1461,7 @@ expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry) expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_exit) expect(job.migration_task).to receive(:run_conversion) + expect(job.migration_task).to receive(:cutover) expect(job).to receive(:queue_signal).with(:poll_transform_vm_complete, :deliver_on => Time.now.utc + job.state_retry_interval) job.signal(:transform_vm) end @@ -1471,7 +1472,6 @@ Timecop.freeze(2019, 2, 6) do expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry) expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_exit) - expect(job.migration_task).to receive(:unpause_disks_precopy) expect(job.migration_task).to receive(:cutover) expect(job).to receive(:queue_signal).with(:poll_transform_vm_complete, :deliver_on => Time.now.utc + job.state_retry_interval) job.signal(:transform_vm) From 96e02d380f7907658fa935b9549d86acf8aa3a21 Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:01:13 -0400 Subject: [PATCH 06/13] Revert "Merge pull request #19980 from fdupont-redhat/v2v_bz_1815046" This reverts commit bca006442018c7f755807e11495dd417adf413e6, reversing changes made to 9e1f10a8d8c55139610dfd2f0acf8bf55adcb453. --- app/models/conversion_host.rb | 2 +- spec/models/conversion_host_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 1535a3d815f..885409d46a8 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -246,8 +246,8 @@ def build_podman_command(task_id, conversion_options) [:volume, "/var/tmp:/var/tmp"], [:volume, "/var/lib/uci/#{task_id}:/var/lib/uci"], [:volume, "/var/log/uci/#{task_id}:/var/log/uci"], + [:volume, "/opt/vmware-vix-disklib-distrib:/opt/vmware-vix-disklib-distrib"] ] - params << [:volume, "/opt/vmware-vix-disklib-distrib:/opt/vmware-vix-disklib-distrib"] unless conversion_options[:transport_method] == 'ssh' params << [:volume, "/root/.ssh/id_rsa:/var/lib/uci/ssh_private_key"] if conversion_options[:transport_method] == 'ssh' params << [:volume, "/root/.v2v_luks_keys_vault.json:/var/lib/uci/luks_keys_vault.json"] if luks_keys_vault_valid? params << uci_image diff --git a/spec/models/conversion_host_spec.rb b/spec/models/conversion_host_spec.rb index 09971a8f477..44c046a4a96 100644 --- a/spec/models/conversion_host_spec.rb +++ b/spec/models/conversion_host_spec.rb @@ -602,6 +602,7 @@ " --volume /var/tmp:/var/tmp"\ " --volume /var/lib/uci/#{task.id}:/var/lib/uci"\ " --volume /var/log/uci/#{task.id}:/var/log/uci"\ + " --volume /opt/vmware-vix-disklib-distrib:/opt/vmware-vix-disklib-distrib"\ " --volume /root/.ssh/id_rsa:/var/lib/uci/ssh_private_key"\ " --volume /root/.v2v_luks_keys_vault.json:/var/lib/uci/luks_keys_vault.json"\ " manageiq/v2v-conversion-host:latest" From f8fa6ec6d3808e540966f0aec25a6a1ad025bca7 Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:01:26 -0400 Subject: [PATCH 07/13] Revert "Merge pull request #19978 from fdupont-redhat/v2v_bz_1814258" This reverts commit 4f0ec595df6c2c542d73454a1b08e4754aa6331a, reversing changes made to 73eeb8fc65508c010a315201e35920f084d97a29. --- app/models/conversion_host.rb | 8 -- app/models/infra_conversion_job.rb | 94 +++++---------- ...rvice_template_transformation_plan_task.rb | 39 ++---- spec/models/infra_conversion_job_spec.rb | 112 +----------------- ..._template_transformation_plan_task_spec.rb | 4 +- 5 files changed, 43 insertions(+), 214 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 885409d46a8..e0610f1bb8f 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -272,14 +272,6 @@ def run_conversion(task_id, conversion_options) raise "Starting conversion for task '#{task_id}' failed on '#{resource.name}' with [#{err.class}: #{err}]" end - def create_pause_disks_precopy_file(task_id) - command = AwesomeSpawn.build_command_line("touch", ["/var/lib/uci/#{task_id}/pause_operations"]) - connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } - true - rescue - false - end - def create_cutover_file(task_id) command = AwesomeSpawn.build_command_line("touch", ["/var/lib/uci/#{task_id}/cutover"]) connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } diff --git a/app/models/infra_conversion_job.rb b/app/models/infra_conversion_job.rb index 4250e288618..854d7fe96c0 100644 --- a/app/models/infra_conversion_job.rb +++ b/app/models/infra_conversion_job.rb @@ -26,15 +26,13 @@ def load_transitions self.state ||= 'initialize' { - :initializing => {'initialize' => 'waiting_to_start'}, - :start => {'waiting_to_start' => 'started'}, - :start_precopying_disks => {'started' => 'precopying_disks'}, - :poll_precopying_disks => {'precopying_disks' => 'precopying_disks'}, - :pause_disks_precopy => {'precopying_disks' => 'pausing_disks_precopy'}, - :poll_pause_disks_precopy_complete => {'pausing_disks_precopy' => 'pausing_disks_precopy'}, + :initializing => {'initialize' => 'waiting_to_start'}, + :start => {'waiting_to_start' => 'started'}, + :start_precopying_disks => {'started' => 'precopying_disks'}, + :poll_precopying_disks => {'precopying_disks' => 'precopying_disks'}, :wait_for_ip_address => { 'started' => 'waiting_for_ip_address', - 'pausing_disks_precopy' => 'waiting_for_ip_address', + 'precopying_disks' => 'waiting_for_ip_address', 'powering_on_vm' => 'waiting_for_ip_address', 'waiting_for_ip_address' => 'waiting_for_ip_address' }, @@ -85,10 +83,6 @@ def state_settings :description => 'Precopying disks', :max_retries => 36.hours / state_retry_interval }, - :pausing_disks_precopy => { - :description => 'Pausing disks precopy', - :max_retries => 36.hours / state_retry_interval - }, :waiting_for_ip_address => { :description => 'Waiting for VM IP address', :weight => 2, @@ -303,7 +297,7 @@ def start_precopying_disks update_migration_task_progress(:on_entry) migration_task.run_conversion queue_signal(:poll_precopying_disks, :deliver_on => Time.now.utc + state_retry_interval) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -319,35 +313,9 @@ def poll_precopying_disks return queue_signal(:poll_precopying_disks, :deliver_on => Time.now.utc + state_retry_interval) end - update_migration_task_progress(:on_exit) - queue_signal(:pause_disks_precopy) - rescue => error - update_migration_task_progress(:on_error) - abort_conversion(error.message, 'error') - end - - def pause_disks_precopy - update_migration_task_progress(:on_entry) - migration_task.pause_disks_precopy - queue_signal(:poll_pause_disks_precopy_complete, :deliver_on => Time.now.utc + state_retry_interval) - rescue => error - update_migration_task_progress(:on_error) - abort_conversion(error.message, 'error') - end - - def poll_pause_disks_precopy_complete - update_migration_task_progress(:on_entry) - return abort_conversion('Pausing disks precopy timed out', 'error') if polling_timeout - - migration_task.get_conversion_state - unless migration_task.options[:virtv2v_status] == 'paused' - update_migration_task_progress(:on_retry) - return queue_signal(:poll_pause_disks_precopy_complete, :deliver_on => Time.now.utc + state_retry_interval) - end - update_migration_task_progress(:on_exit) queue_signal(:wait_for_ip_address) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -374,7 +342,7 @@ def wait_for_ip_address update_migration_task_progress(:on_exit) queue_signal(:run_migration_playbook) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -397,7 +365,7 @@ def run_migration_playbook return queue_signal(:shutdown_vm) if migration_phase == 'pre' queue_signal(:mark_vm_migrated) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) return abort_conversion(error.message, 'error') if migration_phase == 'pre' @@ -426,7 +394,7 @@ def poll_run_migration_playbook_complete update_migration_task_progress(:on_retry) queue_signal(:poll_run_migration_playbook_complete, :deliver_on => Time.now.utc + state_retry_interval) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) return abort_conversion(error.message, 'error') if migration_phase == 'pre' @@ -447,7 +415,7 @@ def shutdown_vm update_migration_task_progress(:on_exit) queue_signal(:transform_vm) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -463,7 +431,7 @@ def poll_shutdown_vm_complete update_migration_task_progress(:on_retry) queue_signal(:poll_shutdown_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -474,7 +442,7 @@ def transform_vm migration_task.cutover update_migration_task_progress(:on_exit) queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -486,27 +454,25 @@ def poll_transform_vm_complete migration_task.get_conversion_state case migration_task.options[:virtv2v_status] when 'active' - unless migration_task.warm_migration? - virtv2v_disks = migration_task.options[:virtv2v_disks] - converted_disks = virtv2v_disks.reject { |disk| disk[:percent].zero? } - if converted_disks.empty? - message = 'Disk transformation is initializing.' - percent = 1 - else - percent = 0 - converted_disks.each { |disk| percent += (disk[:percent].to_f * disk[:weight].to_f / 100.0) } - message = "Converting disk #{converted_disks.length} / #{virtv2v_disks.length} [#{percent.round(2)}%]." - end - update_migration_task_progress(:on_retry, :message => message, :percent => percent) - queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) + virtv2v_disks = migration_task.options[:virtv2v_disks] + converted_disks = virtv2v_disks.reject { |disk| disk[:percent].zero? } + if converted_disks.empty? + message = 'Disk transformation is initializing.' + percent = 1 + else + percent = 0 + converted_disks.each { |disk| percent += (disk[:percent].to_f * disk[:weight].to_f / 100.0) } + message = "Converting disk #{converted_disks.length} / #{virtv2v_disks.length} [#{percent.round(2)}%]." end + update_migration_task_progress(:on_retry, :message => message, :percent => percent) + queue_signal(:poll_transform_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) when 'failed' raise migration_task.options[:virtv2v_message] when 'succeeded' update_migration_task_progress(:on_exit) queue_signal(:inventory_refresh) end - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -545,7 +511,7 @@ def poll_inventory_refresh_complete migration_task.update_options(:migration_phase => 'post') update_migration_task_progress(:on_exit) queue_signal(:apply_right_sizing) - rescue => error + rescue StandardError => error update_migration_task_progress(:on_error) abort_conversion(error.message, 'error') end @@ -560,7 +526,7 @@ def apply_right_sizing update_migration_task_progress(:on_exit) queue_signal(:restore_vm_attributes) - rescue + rescue StandardError update_migration_task_progress(:on_error) queue_signal(:restore_vm_attributes) end @@ -599,7 +565,7 @@ def restore_vm_attributes update_migration_task_progress(:on_exit) queue_signal(:power_on_vm) - rescue + rescue StandardError update_migration_task_progress(:on_error) queue_signal(:power_on_vm) end @@ -623,7 +589,7 @@ def power_on_vm end queue_signal(:mark_vm_migrated) - rescue + rescue StandardError update_migration_task_progress(:on_error) migration_task.canceled if migration_task.canceling? queue_signal(:poll_automate_state_machine) @@ -644,7 +610,7 @@ def poll_power_on_vm_complete update_migration_task_progress(:on_retry) queue_signal(:poll_power_on_vm_complete, :deliver_on => Time.now.utc + state_retry_interval) - rescue + rescue StandardError update_migration_task_progress(:on_error) migration_task.canceled if migration_task.canceling? handover_to_automate diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 61f260929c8..568276c9428 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -144,18 +144,6 @@ def destination_network_ref_openstack(network) network.ems_ref end - def conversion_host_resource_ref(resource) - send("conversion_host_resource_ref_#{destination_ems.emstype}", resource) - end - - def conversion_host_resource_ref_rhevm(resource) - resource.ems_ref.split('/').last - end - - def conversion_host_resource_ref_openstack(resource) - resource.ems_ref - end - def destination_flavor Flavor.find_by(:id => vm_resource.options["osp_flavor_id"]) end @@ -270,17 +258,12 @@ def get_conversion_state updates[:virtv2v_pid] = virtv2v_state['pid'] if virtv2v_state['pid'].present? updates[:virtv2v_message] = virtv2v_state['last_message']['message'] if virtv2v_state['last_message'].present? if virtv2v_state['finished'].nil? - updates[:virtv2v_status] = virtv2v_state['status'] == 'Paused' ? 'paused' : 'active' - if warm_migration? - updated_disks = virtv2v_state['disks'] - else - updated_disks.each do |disk| - matching_disks = virtv2v_state['disks'].select { |d| d['path'] == disk[:path] } - raise "No disk matches '#{disk[:path]}'. Aborting." if matching_disks.length.zero? - raise "More than one disk matches '#{disk[:path]}'. Aborting." if matching_disks.length > 1 - - disk[:percent] = matching_disks.first['progress'] - end + updates[:virtv2v_status] = 'active' + updated_disks.each do |disk| + matching_disks = virtv2v_state['disks'].select { |d| d['path'] == disk[:path] } + raise "No disk matches '#{disk[:path]}'. Aborting." if matching_disks.length.zero? + raise "More than one disk matches '#{disk[:path]}'. Aborting." if matching_disks.length > 1 + disk[:percent] = matching_disks.first['progress'] end else updates[:virtv2v_finished_on] = Time.now.utc.strftime('%Y-%m-%d %H:%M:%S') @@ -303,12 +286,6 @@ def get_conversion_state update_options(updates) end - def pause_disks_precopy - unless conversion_host.create_pause_disks_precopy_file(id) - raise _("Couldn't create disks precopy pause file for #{source.name} on #{conversion_host.name}") - end - end - def cutover unless conversion_host.create_cutover_file(id) raise _("Couldn't create cutover file for #{source.name} on #{conversion_host.name}") @@ -383,7 +360,7 @@ def conversion_options_source_provider_vmwarews_vddk(_storage) { :vm_name => source.name, :vm_uuid => source.uid_ems, - :conversion_host_uuid => conversion_host_resource_ref(conversion_host.resource), + :conversion_host_uuid => conversion_host.resource.ems_ref, :transport_method => 'vddk', :vmware_fingerprint => source.host.thumbprint_sha1, :vmware_uri => URI::Generic.build( @@ -409,7 +386,7 @@ def conversion_options_source_provider_vmwarews_ssh(storage) :path => "/vmfs/volumes/#{Addressable::URI.escape(storage.name)}/#{Addressable::URI.escape(source.location)}" ).to_s, :vm_uuid => source.uid_ems, - :conversion_host_uuid => conversion_host_resource_ref(conversion_host.resource), + :conversion_host_uuid => conversion_host.resource.ems_ref, :transport_method => 'ssh', :daemonize => false } diff --git a/spec/models/infra_conversion_job_spec.rb b/spec/models/infra_conversion_job_spec.rb index fb70ec2e9f5..55e6d59118f 100644 --- a/spec/models/infra_conversion_job_spec.rb +++ b/spec/models/infra_conversion_job_spec.rb @@ -581,7 +581,7 @@ end context 'state transitions' do - %w[start start_precopying_disks poll_precopying_disks pause_disks_precopy poll_pause_disks_precopy_complete wait_for_ip_address run_migration_playbook poll_run_migration_playbook_complete shutdown_vm poll_shutdown_vm_complete transform_vm poll_transform_vm_complete inventory_refresh poll_inventory_refresh_complete apply_right_sizing restore_vm_attributes power_on_vm poll_power_on_vm_complete mark_vm_migrated abort_virtv2v poll_automate_state_machine finish abort_job cancel error].each do |signal| + %w[start start_precopying_disks poll_precopying_disks wait_for_ip_address run_migration_playbook poll_run_migration_playbook_complete shutdown_vm poll_shutdown_vm_complete transform_vm poll_transform_vm_complete inventory_refresh poll_inventory_refresh_complete apply_right_sizing restore_vm_attributes power_on_vm poll_power_on_vm_complete mark_vm_migrated abort_virtv2v poll_automate_state_machine finish abort_job cancel error].each do |signal| shared_examples_for "allows #{signal} signal" do it signal.to_s do expect(job).to receive(signal.to_sym) @@ -590,7 +590,7 @@ end end - %w[start start_precopying_disks poll_precopying_disks pause_disks_precopy poll_pause_disks_precopy_complete wait_for_ip_address run_migration_playbook poll_run_migration_playbook_complete shutdown_vm poll_shutdown_vm_complete transform_vm poll_transform_vm_complete inventory_refresh poll_inventory_refresh_complete apply_right_sizing restore_vm_attributes power_on_vm poll_power_on_vm_complete mark_vm_migrated abort_virtv2v poll_automate_state_machine].each do |signal| + %w[start start_precopying_disks poll_precopying_disks wait_for_ip_address run_migration_playbook poll_run_migration_playbook_complete shutdown_vm poll_shutdown_vm_complete transform_vm poll_transform_vm_complete inventory_refresh poll_inventory_refresh_complete apply_right_sizing restore_vm_attributes power_on_vm poll_power_on_vm_complete mark_vm_migrated abort_virtv2v poll_automate_state_machine].each do |signal| shared_examples_for "doesn't allow #{signal} signal" do it signal.to_s do expect { job.signal(signal.to_sym) }.to raise_error(RuntimeError, /#{signal} is not permitted at state #{job.state}/) @@ -641,8 +641,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' it_behaves_like 'doesn\'t allow shutdown_vm signal' @@ -664,37 +662,6 @@ end it_behaves_like 'allows poll_precopying_disks signal' - it_behaves_like 'allows pause_disks_precopy signal' - it_behaves_like 'allows finish signal' - it_behaves_like 'allows abort_job signal' - it_behaves_like 'allows cancel signal' - it_behaves_like 'allows error signal' - - it_behaves_like 'doesn\'t allow start signal' - it_behaves_like 'doesn\'t allow start_precopying_disks signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' - it_behaves_like 'doesn\'t allow wait_for_ip_address signal' - it_behaves_like 'doesn\'t allow run_migration_playbook signal' - it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' - it_behaves_like 'doesn\'t allow shutdown_vm signal' - it_behaves_like 'doesn\'t allow poll_shutdown_vm_complete signal' - it_behaves_like 'doesn\'t allow transform_vm signal' - it_behaves_like 'doesn\'t allow poll_transform_vm_complete signal' - it_behaves_like 'doesn\'t allow poll_inventory_refresh_complete signal' - it_behaves_like 'doesn\'t allow apply_right_sizing signal' - it_behaves_like 'doesn\'t allow restore_vm_attributes signal' - it_behaves_like 'doesn\'t allow power_on_vm signal' - it_behaves_like 'doesn\'t allow poll_power_on_vm_complete signal' - it_behaves_like 'doesn\'t allow mark_vm_migrated signal' - it_behaves_like 'doesn\'t allow poll_automate_state_machine signal' - end - - context 'pausing_disks_precopy' do - before do - job.state = 'pausing_disks_precopy' - end - - it_behaves_like 'allows poll_pause_disks_precopy_complete signal' it_behaves_like 'allows wait_for_ip_address signal' it_behaves_like 'allows finish signal' it_behaves_like 'allows abort_job signal' @@ -703,8 +670,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' - it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' it_behaves_like 'doesn\'t allow shutdown_vm signal' @@ -735,8 +700,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' it_behaves_like 'doesn\'t allow shutdown_vm signal' it_behaves_like 'doesn\'t allow poll_shutdown_vm_complete signal' @@ -767,8 +730,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_shutdown_vm_complete signal' @@ -796,8 +757,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -827,8 +786,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -859,8 +816,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -890,8 +845,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -921,8 +874,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -955,8 +906,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' it_behaves_like 'doesn\'t allow shutdown_vm signal' @@ -983,8 +932,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -1014,8 +961,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -1047,8 +992,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -1078,8 +1021,6 @@ it_behaves_like 'doesn\'t allow start signal' it_behaves_like 'doesn\'t allow start_precopying_disks signal' it_behaves_like 'doesn\'t allow poll_precopying_disks signal' - it_behaves_like 'doesn\'t allow pause_disks_precopy signal' - it_behaves_like 'doesn\'t allow poll_pause_disks_precopy_complete signal' it_behaves_like 'doesn\'t allow wait_for_ip_address signal' it_behaves_like 'doesn\'t allow run_migration_playbook signal' it_behaves_like 'doesn\'t allow poll_run_migration_playbook_complete signal' @@ -1153,57 +1094,10 @@ Timecop.freeze(2019, 2, 6) do request.options[:cutover_datetime] = Time.now.utc - 1.minute request.save! - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry) - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_exit) - expect(job).to receive(:queue_signal).with(:pause_disks_precopy) - job.signal(:poll_precopying_disks) - end - end - end - - context '#pause_disks_precopy' do - before do - job.state = 'precopying_disks' - end - - it 'pause disks precopy' do - Timecop.freeze(2019, 2, 6) do - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry) - expect(job.migration_task).to receive(:pause_disks_precopy) - expect(job).to receive(:queue_signal).with(:poll_pause_disks_precopy_complete, :deliver_on => Time.now.utc + job.state_retry_interval) - job.signal(:pause_disks_precopy) - end - end - end - - context '#poll_pause_disks_precopy_complete' do - before do - job.state = 'pausing_disks_precopy' - allow(job.migration_task).to receive(:get_conversion_state) - end - - it 'abort_conversion when pausing_disks_precopy times out' do - job.context[:retries_pausing_disks_precopy] = 8640 - expect(job).to receive(:abort_conversion).with('Pausing disks precopy timed out', 'error') - job.signal(:poll_pause_disks_precopy_complete) - end - - it 'retries if disks precopy is not paused' do - Timecop.freeze(2019, 2, 6) do - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry) - expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_retry) - expect(job).to receive(:queue_signal).with(:poll_pause_disks_precopy_complete, :deliver_on => Time.now.utc + job.state_retry_interval) - job.signal(:poll_pause_disks_precopy_complete) - end - end - - it 'exits if disks precopy is paused' do - job.migration_task.update_options(:virtv2v_status => 'paused') - Timecop.freeze(2019, 2, 6) do expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_entry) expect(job).to receive(:update_migration_task_progress).once.ordered.with(:on_exit) expect(job).to receive(:queue_signal).with(:wait_for_ip_address) - job.signal(:poll_pause_disks_precopy_complete) + job.signal(:poll_precopying_disks) end end end diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index cf7ffd45895..33d1a6a2a6e 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -449,8 +449,8 @@ task_1.get_conversion_state expect(task_1.options[:virtv2v_disks]).to eq( [ - {"path" => src_disk_1.filename, "progress" => 100}, - {"path" => src_disk_2.filename, "progress" => 50} + { :path => src_disk_1.filename, :size => src_disk_1.size, :percent => 100, :weight => 50 }, + { :path => src_disk_2.filename, :size => src_disk_2.size, :percent => 50, :weight => 50 } ] ) expect(task_1.options[:virtv2v_status]).to eq('active') From c7c876388616f33306e3338860ec1ed3166568ee Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:01:54 -0400 Subject: [PATCH 08/13] Revert "Merge pull request #19891 from fdupont-redhat/v2v_fix_bz_1808360" This reverts commit b3996f3a080f8964cef1ad2086969127f29e108e, reversing changes made to fad2f9e08147b592a69dc944b62f59c8744432d9. --- app/models/conversion_host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index e0610f1bb8f..bc92cdc3950 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -233,7 +233,7 @@ def luks_keys_vault_valid? def build_podman_command(task_id, conversion_options) uci_settings = Settings.transformation.uci.container uci_image = uci_settings.image - uci_image = "#{uci_settings.registry}/#{uci_image}" if uci_settings.registry.present? + uci_image = "#{uci_settings.registry}/#{image}" if uci_settings.registry.present? params = [ "run", From 932f77f0c3540dd5712dc5da5527edea03d7bb9b Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:02:12 -0400 Subject: [PATCH 09/13] Revert "Merge pull request #19880 from fdupont-redhat/v2v_fix_bz_1807770" This reverts commit 91176bd5b5646bc043bc078bf1eff0214abaf2a2, reversing changes made to 3e6842b0e74ddae44558d4bbb8b2861b61bea9be. --- app/models/service_template_transformation_plan_task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 568276c9428..53bc4c6a9c5 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -371,7 +371,7 @@ def conversion_options_source_provider_vmwarews_vddk(_storage) :query => { :no_verify => 1 }.to_query ).to_s, :vmware_password => source.host.authentication_password, - :two_phase => warm_migration?, + :two_phase => true, :warm => warm_migration?, :daemonize => false } From ab173a8590fae042eae83b7fcea77a2b9104e449 Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:03:29 -0400 Subject: [PATCH 10/13] Revert "Merge pull request #19870 from djberg96/default_kill_virtv2v_signal" This reverts commit 3edab6d2c4fcaa63b5cc2030c089f088134b841c, reversing changes made to 71bea22a72ab0d7cff9cb06680d0d749f85267cb. --- app/models/conversion_host.rb | 2 +- app/models/service_template_transformation_plan_task.rb | 4 ++-- .../service_template_transformation_plan_task_spec.rb | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index bc92cdc3950..29b832a3b75 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -283,7 +283,7 @@ def create_cutover_file(task_id) # Kill a specific remote process over ssh, sending the specified +signal+, or 'TERM' # if no signal is specified. # - def kill_virtv2v(task_id, signal = 'TERM') + def kill_virtv2v(task_id, signal) command = AwesomeSpawn.build_command_line("/usr/bin/podman", ["exec", "conversion-#{task_id}", "/usr/bin/killall", :s, signal, "virt-v2v"]) connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } true diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 53bc4c6a9c5..38cbb972507 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -292,7 +292,7 @@ def cutover end end - def kill_virtv2v(signal = 'TERM') + def kill_virtv2v get_conversion_state unless virtv2v_running? @@ -301,7 +301,7 @@ def kill_virtv2v(signal = 'TERM') end _log.info("Killing conversion pod for task '#{id}'.") - conversion_host.kill_virtv2v(id, signal) + conversion_host.kill_virtv2v(id) rescue => err _log.error("Couldn't kill conversion pod for task '#{id}': #{err.message}") update_options(:virtv2v_finished_on => Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')) diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index 33d1a6a2a6e..f5ae8b78074 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -232,13 +232,13 @@ end it "returns false if if kill command failed" do - allow(conversion_host).to receive(:kill_virtv2v).with(task.id, 'KILL').and_return(false) - expect(task.kill_virtv2v('KILL')).to eq(false) + allow(conversion_host).to receive(:kill_virtv2v).with(task.id).and_return(false) + expect(task.kill_virtv2v).to eq(false) end it "returns true if if kill command succeeded" do - allow(conversion_host).to receive(:kill_virtv2v).with(task.id, 'KILL').and_return(true) - expect(task.kill_virtv2v('KILL')).to eq(true) + allow(conversion_host).to receive(:kill_virtv2v).with(task.id).and_return(true) + expect(task.kill_virtv2v).to eq(true) end it "considers virt-v2v finished or returns false if an exception occurs" do From 2af2f64625971150c4fb0d6c85486d2526df96f6 Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Wed, 13 May 2020 12:04:00 -0400 Subject: [PATCH 11/13] Revert "Merge pull request #19864 from fdupont-redhat/v2v_conversion_host_fix_extra_vars" This reverts commit d61bf49cbdc7fd6fc3fac2fc53466bffa165a6a3, reversing changes made to 835789226e78f05206841c32ad695db147fbe010. --- app/models/conversion_host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 29b832a3b75..8c31441b39e 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -461,7 +461,7 @@ def ansible_playbook(playbook, extra_vars = {}, miq_task_id = nil, auth_type = ' raise MiqException::MiqInvalidCredentialsError, _("Unknown auth type: %{auth_type}") % {:auth_type => auth.authtype} end - extra_vars.each { |k, v| params << {:extra_vars= => "#{k}='#{v}'"} } + params << {:extra_vars => "'#{extra_vars.to_json}'"} command = AwesomeSpawn.build_command_line("ansible-playbook", params) result = AwesomeSpawn.run(command) From 491c13ded8e7f4c61228c3c2784f491d83f6eafd Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Sat, 23 May 2020 10:42:07 -0400 Subject: [PATCH 12/13] Revert "Merge pull request #19698 from fdupont-redhat/v2v_use_podman_for_wrapper" This reverts commit 370cc23ec39c989ce5435ef3030a70f0c451a072, reversing changes made to 92446923b1df5c8587bb5c54019a694cd4d05c63. --- app/models/conversion_host.rb | 103 ++++------------ ...rvice_template_transformation_plan_task.rb | 36 +++--- config/settings.yml | 4 - lib/infra_conversion_throttler.rb | 3 +- spec/lib/infra_conversion_throttler_spec.rb | 16 ++- spec/models/conversion_host_spec.rb | 112 +++++------------- ..._template_transformation_plan_task_spec.rb | 58 ++++----- 7 files changed, 107 insertions(+), 225 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 8c31441b39e..68d44a260a8 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -159,50 +159,14 @@ def ipaddress(family = 'ipv4') # @raise [Net::SSH::HostKeyMismatch] if conversion host key has changed # @raise [JSON::GeneratorError] if limits hash can't be converted to JSON # @raise [StandardError] if any other problem happens - def apply_task_limits(task_id, limits = {}) - connect_ssh do |ssu| - ssu.put_file("/tmp/#{task_id}-limits.json", limits.to_json) - command = AwesomeSpawn.build_command_line("mv", ["/tmp/#{task_id}-limits.json", "/var/lib/uci/#{task_id}/limits.json"]) - ssu.shell_exec(command, nil, nil, nil) - end + def apply_task_limits(path, limits = {}) + connect_ssh { |ssu| ssu.put_file(path, limits.to_json) } rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => err - raise "Failed to connect and apply limits for task '#{task_id}' with [#{err.class}: #{err}]" + raise "Failed to connect and apply limits in file '#{path}' with [#{err.class}: #{err}]" rescue JSON::GeneratorError => err raise "Could not generate JSON from limits '#{limits}' with [#{err.class}: #{err}]" rescue => err - raise "Could not apply the limits for task '#{task_id}' on '#{resource.name}' with [#{err.class}: #{err}]" - end - - # Prepare the conversion assets for a specific task. - # - # @param [Integer] id of the task that needs the preparation - # @param [Hash] conversion options to write on the conversion host - # - # @return [Integer] length of data written to conversion options file - # - # @raise [Net::SSH::AuthenticationFailed] if conversion host credentials are invalid - # @raise [Net::SSH::HostKeyMismatch] if conversion host key has changed - # @raise [JSON::GeneratorError] if limits hash can't be converted to JSON - # @raise [StandardError] if any other problem happens - def prepare_conversion(task_id, conversion_options) - filtered_options = filter_options(conversion_options) - - connect_ssh do |ssu| - # Prepare the conversion folders - command = AwesomeSpawn.build_command_line("mkdir", [:p, "/var/lib/uci/#{task_id}", "/var/log/uci/#{task_id}"]) - ssu.shell_exec(command, nil, nil, nil) - - # Write the conversion options file - ssu.put_file("/tmp/#{task_id}-input.json", conversion_options.to_json) - command = AwesomeSpawn.build_command_line("mv", ["/tmp/#{task_id}-input.json", "/var/lib/uci/#{task_id}/input.json"]) - ssu.shell_exec(command, nil, nil, nil) - end - rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => err - raise "Failed to connect and prepare conversion for task '#{task_id}' with [#{err.class}: #{err}]" - rescue JSON::GeneratorError => err - raise "Could not generate JSON for task '#{task_id}' from options '#{filtered_options}' with [#{err.class}: #{err}]" - rescue => err - raise "Preparation of conversion for task '#{task_id}' failed on '#{resource.name}' with [#{err.class}: #{err}]" + raise "Could not apply the limits in file '#{path}' on '#{resource.name}' with [#{err.class}: #{err}]" end # Checks that LUKS keys vault exists and is valid JSON @@ -225,36 +189,6 @@ def luks_keys_vault_valid? false end - # Build the podman command to execute conversion - # - # @param [Integer] id of the task that conversion applies to - # - # @return [String] podman command to be executed on conversion host - def build_podman_command(task_id, conversion_options) - uci_settings = Settings.transformation.uci.container - uci_image = uci_settings.image - uci_image = "#{uci_settings.registry}/#{image}" if uci_settings.registry.present? - - params = [ - "run", - :detach, - :privileged, - [:name, "conversion-#{task_id}"], - [:network, "host"], - [:volume, "/dev:/dev"], - [:volume, "/etc/pki/ca-trust:/etc/pki/ca-trust"], - [:volume, "/var/tmp:/var/tmp"], - [:volume, "/var/lib/uci/#{task_id}:/var/lib/uci"], - [:volume, "/var/log/uci/#{task_id}:/var/log/uci"], - [:volume, "/opt/vmware-vix-disklib-distrib:/opt/vmware-vix-disklib-distrib"] - ] - params << [:volume, "/root/.ssh/id_rsa:/var/lib/uci/ssh_private_key"] if conversion_options[:transport_method] == 'ssh' - params << [:volume, "/root/.v2v_luks_keys_vault.json:/var/lib/uci/luks_keys_vault.json"] if luks_keys_vault_valid? - params << uci_image - - AwesomeSpawn.build_command_line("/usr/bin/podman", params) - end - # Run the virt-v2v-wrapper script on the remote host and return a hash # result from the parsed JSON output. # @@ -262,18 +196,21 @@ def build_podman_command(task_id, conversion_options) # that information from showing up in the UI or logs. # # @param [Integer] id of the task that conversion applies to - def run_conversion(task_id, conversion_options) + def run_conversion(conversion_options) filtered_options = filter_options(conversion_options) - prepare_conversion(task_id, conversion_options) - connect_ssh { |ssu| ssu.shell_exec(build_podman_command(task_id, conversion_options), nil, nil, nil) } + command = AwesomeSpawn.build_command_line("/usr/bin/virt-v2v-wrapper") + result = connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, conversion_options.to_json) } + JSON.parse(result) rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => err raise "Failed to connect and run conversion using options #{filtered_options} with [#{err.class}: #{err}]" + rescue JSON::ParserError + raise "Could not parse result data after running virt-v2v-wrapper using options: #{filtered_options}. Result was: #{result}" rescue => err - raise "Starting conversion for task '#{task_id}' failed on '#{resource.name}' with [#{err.class}: #{err}]" + raise "Starting conversion failed on '#{resource.name}' with [#{err.class}: #{err}]" end - def create_cutover_file(task_id) - command = AwesomeSpawn.build_command_line("touch", ["/var/lib/uci/#{task_id}/cutover"]) + def create_cutover_file(path) + command = AwesomeSpawn.build_command_line("touch", [path]) connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } true rescue @@ -283,8 +220,8 @@ def create_cutover_file(task_id) # Kill a specific remote process over ssh, sending the specified +signal+, or 'TERM' # if no signal is specified. # - def kill_virtv2v(task_id, signal) - command = AwesomeSpawn.build_command_line("/usr/bin/podman", ["exec", "conversion-#{task_id}", "/usr/bin/killall", :s, signal, "virt-v2v"]) + def kill_virtv2v(pid, signal = 'TERM') + command = AwesomeSpawn.build_command_line("/bin/kill", [:s, signal, pid]) connect_ssh { |ssu| ssu.shell_exec(command, nil, nil, nil) } true rescue @@ -294,15 +231,15 @@ def kill_virtv2v(task_id, signal) # Retrieve the conversion state information from a remote file as a stream. # Then parse and return the stream data as a hash using JSON.parse. # - def get_conversion_state(task_id) - json_state = connect_ssh { |ssu| ssu.get_file("/var/lib/uci/#{task_id}/state.json", nil) } + def get_conversion_state(path) + json_state = connect_ssh { |ssu| ssu.get_file(path, nil) } JSON.parse(json_state) rescue Net::SSH::AuthenticationFailed, Net::SSH::HostKeyMismatch => err - raise "Failed to connect and retrieve conversion state data from file '/var/lib/uci/#{task_id}/state.json' with [#{err.class}: #{err}]" + raise "Failed to connect and retrieve conversion state data from file '#{path}' with [#{err.class}: #{err}]" rescue JSON::ParserError - raise "Could not parse conversion state data from file '/var/lib/uci/#{task_id}/state.json': #{json_state}" + raise "Could not parse conversion state data from file '#{path}': #{json_state}" rescue => err - raise "Error retrieving and parsing conversion state file '/var/lib/uci/#{task_id}/state.json' from '#{resource.name}' with [#{err.class}: #{err}" + raise "Error retrieving and parsing conversion state file '#{path}' from '#{resource.name}' with [#{err.class}: #{err}" end # Get and return the contents of the remote conversion log at +path+. diff --git a/app/models/service_template_transformation_plan_task.rb b/app/models/service_template_transformation_plan_task.rb index 38cbb972507..71d90e8344a 100644 --- a/app/models/service_template_transformation_plan_task.rb +++ b/app/models/service_template_transformation_plan_task.rb @@ -237,14 +237,7 @@ def update_options(opts) def run_conversion start_timestamp = Time.now.utc.strftime('%Y-%m-%d %H:%M:%S') updates = {} - conversion_host.run_conversion(id, conversion_options) - updates[:virtv2v_wrapper] = { - "state_file" => "/var/lib/uci/#{id}/state.json", - "throttling_file" => "/var/lib/uci/#{id}/limits.json", - "cutover_file" => "/var/lib/uci/#{id}/cutover", - "v2v_log" => "/var/log/uci/#{id}/virt-v2v.log", - "wrapper_log" => "/var/log/uci/#{id}/virt-v2v-wrapper.log" - } + updates[:virtv2v_wrapper] = conversion_host.run_conversion(conversion_options) updates[:virtv2v_started_on] = start_timestamp updates[:virtv2v_status] = 'active' _log.info("InfraConversionJob run_conversion to update_options: #{updates}") @@ -253,7 +246,7 @@ def run_conversion def get_conversion_state updates = {} - virtv2v_state = conversion_host.get_conversion_state(id) + virtv2v_state = conversion_host.get_conversion_state(options[:virtv2v_wrapper]['state_file']) updated_disks = virtv2v_disks updates[:virtv2v_pid] = virtv2v_state['pid'] if virtv2v_state['pid'].present? updates[:virtv2v_message] = virtv2v_state['last_message']['message'] if virtv2v_state['last_message'].present? @@ -287,12 +280,14 @@ def get_conversion_state end def cutover - unless conversion_host.create_cutover_file(id) - raise _("Couldn't create cutover file for #{source.name} on #{conversion_host.name}") + if options[:virtv2v_wrapper]['cutover_file'].present? + unless conversion_host.create_cutover_file(options[:virtv2v_wrapper]['cutover_file']) + raise _("Couldn't create cutover file for #{source.name} on #{conversion_host.name}") + end end end - def kill_virtv2v + def kill_virtv2v(signal = 'TERM') get_conversion_state unless virtv2v_running? @@ -300,10 +295,15 @@ def kill_virtv2v return false end - _log.info("Killing conversion pod for task '#{id}'.") - conversion_host.kill_virtv2v(id) + unless options[:virtv2v_pid] + _log.info("No PID has been reported by virt-v2v-wrapper, so we can't kill it.") + return false + end + + _log.info("Killing virt-v2v (PID: #{options[:virtv2v_pid]}) with #{signal} signal.") + conversion_host.kill_virtv2v(options[:virtv2v_pid], signal) rescue => err - _log.error("Couldn't kill conversion pod for task '#{id}': #{err.message}") + _log.error("Couldn't kill virt-v2v (PID: #{options[:virtv2v_pid]}) with #{signal} signal: #{err.message}") update_options(:virtv2v_finished_on => Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')) false end @@ -372,8 +372,7 @@ def conversion_options_source_provider_vmwarews_vddk(_storage) ).to_s, :vmware_password => source.host.authentication_password, :two_phase => true, - :warm => warm_migration?, - :daemonize => false + :warm => warm_migration? } end @@ -387,8 +386,7 @@ def conversion_options_source_provider_vmwarews_ssh(storage) ).to_s, :vm_uuid => source.uid_ems, :conversion_host_uuid => conversion_host.resource.ems_ref, - :transport_method => 'ssh', - :daemonize => false + :transport_method => 'ssh' } end diff --git a/config/settings.yml b/config/settings.yml index 51b56043050..af517db5539 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -1047,10 +1047,6 @@ :max_concurrent_tasks_per_conversion_host: 10 :cpu_limit_per_host: unlimited :network_limit_per_host: unlimited - :uci: - :container: - :registry: - :image: manageiq/v2v-conversion-host:latest :ui: :mark_translated_strings: false :url: diff --git a/lib/infra_conversion_throttler.rb b/lib/infra_conversion_throttler.rb index 845eb6c5f35..ccc1c08c24d 100644 --- a/lib/infra_conversion_throttler.rb +++ b/lib/infra_conversion_throttler.rb @@ -97,13 +97,14 @@ def self.apply_limits jobs.each do |job| migration_task = job.migration_task next unless migration_task.virtv2v_running? + next unless migration_task.options.fetch_path(:virtv2v_wrapper, 'throttling_file') limits = { :cpu => cpu_limit, :network => network_limit } unless migration_task.options[:virtv2v_limits] == limits - ch.apply_task_limits(migration_task.id, limits) + ch.apply_task_limits(migration_task.options.fetch_path(:virtv2v_wrapper, 'throttling_file'), limits) migration_task.update_options(:virtv2v_limits => limits) end end diff --git a/spec/lib/infra_conversion_throttler_spec.rb b/spec/lib/infra_conversion_throttler_spec.rb index de9b7668f58..16cc4fe140e 100644 --- a/spec/lib/infra_conversion_throttler_spec.rb +++ b/spec/lib/infra_conversion_throttler_spec.rb @@ -120,12 +120,18 @@ } task_running_1.update_options( :virtv2v_started_on => Time.now.utc, - :virtv2v_wrapper => {'state_file' => "/var/lib/uci/#{task_running_1.id}/state.json"} + :virtv2v_wrapper => { + 'state_file' => "/tmp/state_1.json", + 'throttling_file' => '/tmp/throttling_1.json' + } ) - task_running_2.options[:virtv2v_started_on] = Time.now.utc - task_running_2.options[:virtv2v_wrapper] = {'state_file' => "/var/lib/uci/#{task_running_2.id}/state.json"} - expect(conversion_host).to receive(:apply_task_limits).with(task_running_1.id, limits) - expect(conversion_host).not_to receive(:apply_task_limits).with(task_running_2.id, limits) + task_running_2.update_options( + :virtv2v_started_on => Time.now.utc, + :virtv2v_wrapper => { + 'state_file' => "/tmp/state_2.json" + } + ) + expect(conversion_host).to receive(:apply_task_limits).with('/tmp/throttling_1.json', limits) described_class.apply_limits expect(task_running_1.reload.options[:virtv2v_limits]).to eq(limits) expect(task_running_2.reload.options[:virtv2v_limits]).to be_nil diff --git a/spec/models/conversion_host_spec.rb b/spec/models/conversion_host_spec.rb index 44c046a4a96..0f4a4c6ff05 100644 --- a/spec/models/conversion_host_spec.rb +++ b/spec/models/conversion_host_spec.rb @@ -542,91 +542,33 @@ end end - context "#prepare_conversion" do + context "#run_conversion" do let(:vm) { FactoryBot.create(:vm_openstack) } let(:conversion_host) { FactoryBot.create(:conversion_host, :resource => vm) } - let(:task) { FactoryBot.create(:service_template_transformation_plan_task, :conversion_host => conversion_host) } - let(:conversion_options) { {:foo => 1, :bar => 'hello', :password => 'xxx', :ssh_key => 'xyz'} } + let(:conversion_options) { {:foo => 1, :bar => 'hello', :password => 'xxx', :ssh_key => 'xyz' } } let(:filtered_options) { conversion_options.clone.update(:ssh_key => '__FILTERED__', :password => '__FILTERED__') } - it "works as expected if the connection is successful but the JSON is invalid" do - allow(conversion_host).to receive(:connect_ssh).and_raise(JSON::GeneratorError, 'fake unparser error') - expected_message = "Could not generate JSON for task '#{task.id}' from options '#{filtered_options}' with [JSON::GeneratorError: fake unparser error]" - expect { conversion_host.prepare_conversion(task.id, conversion_options) }.to raise_error(expected_message) - end - it "works as expected if the connection is unsuccessful" do allow(conversion_host).to receive(:connect_ssh).and_raise(Net::SSH::AuthenticationFailed) - expected_message = "Failed to connect and prepare conversion for task '#{task.id}'" - expect { conversion_host.prepare_conversion(task.id, conversion_options) }.to raise_error(/#{expected_message}/) + expected_message = "Failed to connect and run conversion using options #{filtered_options}" + expect { conversion_host.run_conversion(conversion_options) }.to raise_error(/#{expected_message}/) end it "works as expected if an unknown error occurs" do - allow(conversion_host).to receive(:connect_ssh).and_raise(StandardError) - expected_message = "Preparation of conversion for task '#{task.id}' failed on '#{vm.name}'" - expect { conversion_host.prepare_conversion(task.id, conversion_options) }.to raise_error(/#{expected_message}/) - end - end - - context "#build_podman_command" do - let(:vm) { FactoryBot.create(:vm_openstack) } - let(:conversion_host) { FactoryBot.create(:conversion_host, :resource => vm) } - let(:conversion_options) { {:foo => 1, :bar => 'hello', :password => 'xxx', :ssh_key => 'xyz'} } - let(:task) { FactoryBot.create(:service_template_transformation_plan_task, :conversion_host => conversion_host) } - - it "works as expected and returns the command when transport is VDDK and LUKS keys vault check fails" do - allow(conversion_host).to receive(:connect_ssh).and_raise('Fake error') - expect(conversion_host.build_podman_command(task.id, conversion_options)).to eq( - "/usr/bin/podman run --detach --privileged"\ - " --name conversion-#{task.id}"\ - " --network host" \ - " --volume /dev:/dev"\ - " --volume /etc/pki/ca-trust:/etc/pki/ca-trust"\ - " --volume /var/tmp:/var/tmp"\ - " --volume /var/lib/uci/#{task.id}:/var/lib/uci"\ - " --volume /var/log/uci/#{task.id}:/var/log/uci"\ - " --volume /opt/vmware-vix-disklib-distrib:/opt/vmware-vix-disklib-distrib"\ - " manageiq/v2v-conversion-host:latest" - ) - end - - it "works as expected and returns the command when transport is SSH and LUKS keys vault check succeeds" do - conversion_options[:transport_method] = 'ssh' - allow(conversion_host).to receive(:connect_ssh).and_return('{"fake": "json"}') - expect(conversion_host.build_podman_command(task.id, conversion_options)).to eq( - "/usr/bin/podman run --detach --privileged"\ - " --name conversion-#{task.id}"\ - " --network host"\ - " --volume /dev:/dev"\ - " --volume /etc/pki/ca-trust:/etc/pki/ca-trust"\ - " --volume /var/tmp:/var/tmp"\ - " --volume /var/lib/uci/#{task.id}:/var/lib/uci"\ - " --volume /var/log/uci/#{task.id}:/var/log/uci"\ - " --volume /opt/vmware-vix-disklib-distrib:/opt/vmware-vix-disklib-distrib"\ - " --volume /root/.ssh/id_rsa:/var/lib/uci/ssh_private_key"\ - " --volume /root/.v2v_luks_keys_vault.json:/var/lib/uci/luks_keys_vault.json"\ - " manageiq/v2v-conversion-host:latest" - ) + allow(conversion_host).to receive(:connect_ssh).and_raise(StandardError, 'fake error') + expected_message = "Starting conversion failed on '#{vm.name}' with [StandardError: fake error]" + expect { conversion_host.run_conversion(conversion_options) }.to raise_error(expected_message) end - end - - context "#run_conversion" do - let(:vm) { FactoryBot.create(:vm_openstack) } - let(:conversion_host) { FactoryBot.create(:conversion_host, :resource => vm) } - let(:task) { FactoryBot.create(:service_template_transformation_plan_task, :conversion_host => conversion_host) } - let(:conversion_options) { {:foo => 1, :bar => 'hello', :password => 'xxx', :ssh_key => 'xyz' } } - let(:filtered_options) { conversion_options.clone.update(:ssh_key => '__FILTERED__', :password => '__FILTERED__') } - it "works as expected if the connection is unsuccessful" do - allow(conversion_host).to receive(:prepare_conversion).and_raise(Net::SSH::AuthenticationFailed) - expected_message = "Failed to connect and run conversion using options #{filtered_options}" - expect { conversion_host.run_conversion(task.id, conversion_options) }.to raise_error(/#{expected_message}/) + it "works as expected if the connection is successful and the JSON is valid" do + allow(conversion_host).to receive(:connect_ssh).and_return({:alpha => {:beta => 'hello'}}.to_json) + expect(conversion_host.run_conversion(conversion_options)).to eql('alpha' => {'beta' => 'hello'}) end - it "works as expected if an unknown error occurs" do - allow(conversion_host).to receive(:connect_ssh).and_raise(StandardError) - expected_message = "Starting conversion for task '#{task.id}' failed on '#{vm.name}'" - expect { conversion_host.run_conversion(task.id, conversion_options) }.to raise_error(/#{expected_message}/) + it "works as expected if the connection is successful but the JSON is invalid" do + allow(conversion_host).to receive(:connect_ssh).and_return('bogus') + expected_message = "Could not parse result data after running virt-v2v-wrapper using options: #{filtered_options}. Result was: bogus" + expect { conversion_host.run_conversion(conversion_options) }.to raise_error(expected_message) end end @@ -637,25 +579,25 @@ it "works as expected if the connection is successful and the JSON is valid" do allow(conversion_host).to receive(:connect_ssh).and_return({:alpha => {:beta => 'hello'}}.to_json) - expect(conversion_host.get_conversion_state(task.id)).to eql('alpha' => {'beta' => 'hello'}) + expect(conversion_host.get_conversion_state('/tmp/state.json')).to eql('alpha' => {'beta' => 'hello'}) end it "works as expected if the connection is successful but the JSON is invalid" do allow(conversion_host).to receive(:connect_ssh).and_return('bogus') - expected_message = "Could not parse conversion state data from file '/var/lib/uci/#{task.id}/state.json': bogus" - expect { conversion_host.get_conversion_state(task.id) }.to raise_error(expected_message) + expected_message = "Could not parse conversion state data from file '/tmp/state.json': bogus" + expect { conversion_host.get_conversion_state('/tmp/state.json') }.to raise_error(expected_message) end it "works as expected if the connection is unsuccessful" do allow(conversion_host).to receive(:connect_ssh).and_raise(Net::SSH::AuthenticationFailed) - expected_message = "Failed to connect and retrieve conversion state data from file '\/var\/lib\/uci\/#{task.id}\/state.json'" - expect { conversion_host.get_conversion_state(task.id) }.to raise_error(/#{expected_message}/) + expected_message = "Failed to connect and retrieve conversion state data from file '\/tmp\/state.json'" + expect { conversion_host.get_conversion_state('/tmp/state.json') }.to raise_error(/#{expected_message}/) end it "works as expected if an unknown error occurs" do allow(conversion_host).to receive(:connect_ssh).and_raise(StandardError) - expected_message = "Error retrieving and parsing conversion state file '\/var\/lib\/uci\/#{task.id}\/state.json' from '#{vm.name}'" - expect { conversion_host.get_conversion_state(task.id) }.to raise_error(/#{expected_message}/) + expected_message = "Error retrieving and parsing conversion state file '\/tmp\/state.json' from '#{vm.name}'" + expect { conversion_host.get_conversion_state('/tmp/state.json') }.to raise_error(/#{expected_message}/) end end @@ -667,25 +609,25 @@ it "works as expected if the connection is successful and the JSON is generated" do allow(conversion_host).to receive(:connect_ssh).and_return(true) - expect(conversion_host.apply_task_limits(task.id, limits)).to be_truthy + expect(conversion_host.apply_task_limits('/tmp/throttling.json', limits)).to be_truthy end it "works as expected if the connection is successful but the JSON is invalid" do allow(conversion_host).to receive(:connect_ssh).and_raise(JSON::GeneratorError, 'fake unparser error') expected_message = "Could not generate JSON from limits '#{limits}' with [JSON::GeneratorError: fake unparser error]" - expect { conversion_host.apply_task_limits(task.id, limits) }.to raise_error(expected_message) + expect { conversion_host.apply_task_limits('/tmp/throttling.json', limits) }.to raise_error(expected_message) end it "works as expected if the connection is unsuccessful" do allow(conversion_host).to receive(:connect_ssh).and_raise(Net::SSH::AuthenticationFailed) - expected_message = "Failed to connect and apply limits for task '#{task.id}'" - expect { conversion_host.apply_task_limits(task.id, limits) }.to raise_error(/#{expected_message}/) + expected_message = "Failed to connect and apply limits in file '/tmp/throttling.json'" + expect { conversion_host.apply_task_limits('/tmp/throttling.json', limits) }.to raise_error(/#{expected_message}/) end it "works as expected if an unknown error occurs" do allow(conversion_host).to receive(:connect_ssh).and_raise(StandardError, 'fake error') - expected_message = "Could not apply the limits for task '#{task.id}' on '#{vm.name}' with [StandardError: fake error]" - expect { conversion_host.apply_task_limits(task.id, limits) }.to raise_error(expected_message) + expected_message = "Could not apply the limits in file '/tmp/throttling.json' on '#{vm.name}' with [StandardError: fake error]" + expect { conversion_host.apply_task_limits('/tmp/throttling.json', limits) }.to raise_error(expected_message) end end diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index f5ae8b78074..e309f166dd1 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -231,14 +231,20 @@ expect(task.kill_virtv2v).to eq(false) end - it "returns false if if kill command failed" do - allow(conversion_host).to receive(:kill_virtv2v).with(task.id).and_return(false) + it "returns false if virtv2v_pid is absent" do + task.options[:virtv2v_pid] = nil + expect(conversion_host).not_to receive(:kill_virtv2v) expect(task.kill_virtv2v).to eq(false) end + it "returns false if if kill command failed" do + expect(conversion_host).to receive(:kill_virtv2v).with('1234', 'KILL').and_return(false) + expect(task.kill_virtv2v('KILL')).to eq(false) + end + it "returns true if if kill command succeeded" do - allow(conversion_host).to receive(:kill_virtv2v).with(task.id).and_return(true) - expect(task.kill_virtv2v).to eq(true) + expect(conversion_host).to receive(:kill_virtv2v).with('1234', 'KILL').and_return(true) + expect(task.kill_virtv2v('KILL')).to eq(true) end it "considers virt-v2v finished or returns false if an exception occurs" do @@ -319,17 +325,19 @@ let(:time_now) { Time.now.utc } before do allow(Time).to receive(:now).and_return(time_now) - allow(conversion_host).to receive(:run_conversion).with(task_1.id, task_1.conversion_options) + allow(conversion_host).to receive(:run_conversion).with(task_1.conversion_options).and_return( + "wrapper_log" => "/tmp/wrapper.log", + "v2v_log" => "/tmp/v2v.log", + "state_file" => "/tmp/v2v.state" + ) end it "collects the wrapper state hash" do task_1.run_conversion expect(task_1.options[:virtv2v_wrapper]).to eq( - "state_file" => "/var/lib/uci/#{task_1.id}/state.json", - "throttling_file" => "/var/lib/uci/#{task_1.id}/limits.json", - "cutover_file" => "/var/lib/uci/#{task_1.id}/cutover", - "v2v_log" => "/var/log/uci/#{task_1.id}/virt-v2v.log", - "wrapper_log" => "/var/log/uci/#{task_1.id}/virt-v2v-wrapper.log" + "wrapper_log" => "/tmp/wrapper.log", + "v2v_log" => "/tmp/v2v.log", + "state_file" => "/tmp/v2v.state" ) expect(task_1.options[:virtv2v_started_on]).to eq(time_now.strftime('%Y-%m-%d %H:%M:%S')) expect(task_1.options[:virtv2v_status]).to eq('active') @@ -401,20 +409,20 @@ it "rescues when conversion_host.get_conversion_state fails less than 5 times" do task_1.update_options(:get_conversion_state_failures => 2) - allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_raise("Fake error") + allow(conversion_host).to receive(:get_conversion_state).with('fake_state').and_raise("Fake error") task_1.get_conversion_state expect(task_1.options[:get_conversion_state_failures]).to eq(3) end it "rescues when conversion_host.get_conversion_state fails more than 5 times" do task_1.update_options(:get_conversion_state_failures => 5) - allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_raise("Fake error") + allow(conversion_host).to receive(:get_conversion_state).with('fake_state').and_raise("Fake error") expect { task_1.get_conversion_state }.to raise_error("Failed to get conversion state 5 times in a row") expect(task_1.options[:get_conversion_state_failures]).to eq(6) end it "updates progress when conversion is failed" do - allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_return( + allow(conversion_host).to receive(:get_conversion_state).with('fake_state').and_return( "failed" => true, "finished" => true, "started" => true, @@ -437,7 +445,7 @@ end it "updates disks progress" do - allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_return( + allow(conversion_host).to receive(:get_conversion_state).with('fake_state').and_return( "started" => true, "disks" => [ { "path" => src_disk_1.filename, "progress" => 100.0 }, @@ -457,7 +465,7 @@ end it "sets disks progress to 100% when conversion is finished and successful" do - allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_return( + allow(conversion_host).to receive(:get_conversion_state).with('fake_state').and_return( "finished" => true, "started" => true, "disks" => [ @@ -483,7 +491,7 @@ it "sets disks progress to 100% when conversion is finished and successful unless canceling" do task_1.canceling - allow(conversion_host).to receive(:get_conversion_state).with(task_1.id).and_return( + allow(conversion_host).to receive(:get_conversion_state).with('fake_state').and_return( "finished" => true, "started" => true, "disks" => [ @@ -614,8 +622,7 @@ :install_drivers => true, :insecure_connection => true, :two_phase => true, - :warm => true, - :daemonize => false + :warm => true ) end @@ -638,8 +645,7 @@ :install_drivers => true, :insecure_connection => true, :two_phase => true, - :warm => true, - :daemonize => false + :warm => true ) end @@ -665,8 +671,7 @@ :source_disks => [src_disk_1.filename, src_disk_2.filename], :network_mappings => task_1.network_mappings, :install_drivers => true, - :insecure_connection => true, - :daemonize => false + :insecure_connection => true ) end @@ -684,8 +689,7 @@ :source_disks => [src_disk_1.filename, src_disk_2.filename], :network_mappings => task_1.network_mappings, :install_drivers => true, - :insecure_connection => true, - :daemonize => false + :insecure_connection => true ) end end @@ -802,8 +806,7 @@ :source_disks => [src_disk_1.filename, src_disk_2.filename], :network_mappings => task_1.network_mappings, :two_phase => true, - :warm => true, - :daemonize => false + :warm => true ) end end @@ -839,8 +842,7 @@ :osp_flavor_id => openstack_flavor.ems_ref, :osp_security_groups_ids => [openstack_security_group.ems_ref], :source_disks => [src_disk_1.filename, src_disk_2.filename], - :network_mappings => task_1.network_mappings, - :daemonize => false + :network_mappings => task_1.network_mappings ) end end From 0b5bf97ff49f8c8dbae869783016e35db16a1b41 Mon Sep 17 00:00:00 2001 From: Satoe Imaishi Date: Tue, 26 May 2020 08:47:31 -0400 Subject: [PATCH 13/13] Revert "Merge pull request #19787 from fdupont-redhat/v2v_rename_variable_for_tls_ca_cert" This reverts commit 25c31676c04a89d85ec6556e453a91fe34963916, reversing changes made to 2a8c3b89b1ba0e7ed26f0870874338d4b50e3439. --- app/models/conversion_host.rb | 4 ++-- app/models/conversion_host/configurations.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 68d44a260a8..d4f425e0f89 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -264,7 +264,7 @@ def check_conversion_host_role(miq_task_id = nil) tag_resource_as('disabled') end - def enable_conversion_host_role(vmware_vddk_package_url = nil, vmware_ssh_private_key = nil, tls_ca_certs = nil, miq_task_id = nil) + def enable_conversion_host_role(vmware_vddk_package_url = nil, vmware_ssh_private_key = nil, openstack_tls_ca_certs = nil, miq_task_id = nil) return if resource.nil? || resource.ext_management_system.nil? raise "vmware_vddk_package_url is mandatory if transformation method is vddk" if vddk_transport_supported && vmware_vddk_package_url.nil? raise "vmware_ssh_private_key is mandatory if transformation_method is ssh" if ssh_transport_supported && vmware_ssh_private_key.nil? @@ -275,7 +275,7 @@ def enable_conversion_host_role(vmware_vddk_package_url = nil, vmware_ssh_privat :v2v_transport_method => source_transport_method, :v2v_vddk_package_url => vmware_vddk_package_url, :v2v_ssh_private_key => vmware_ssh_private_key, - :v2v_ca_bundle => tls_ca_certs || resource.ext_management_system.connection_configurations['default'].certificate_authority + :v2v_ca_bundle => openstack_tls_ca_certs || resource.ext_management_system.connection_configurations['default'].certificate_authority }.compact ansible_playbook(playbook, extra_vars, miq_task_id) ensure diff --git a/app/models/conversion_host/configurations.rb b/app/models/conversion_host/configurations.rb index b8fb427c03c..0e42bd2fc35 100644 --- a/app/models/conversion_host/configurations.rb +++ b/app/models/conversion_host/configurations.rb @@ -78,7 +78,7 @@ def enable(params, auth_user = nil) ssh_key = params.delete(:conversion_host_ssh_private_key) - tls_ca_certs = params.delete(:tls_ca_certs) + openstack_tls_ca_certs = params.delete(:openstack_tls_ca_certs) new(params).tap do |conversion_host| if ssh_key @@ -90,7 +90,7 @@ def enable(params, auth_user = nil) ) end - conversion_host.enable_conversion_host_role(vmware_vddk_package_url, vmware_ssh_private_key, tls_ca_certs, miq_task_id) + conversion_host.enable_conversion_host_role(vmware_vddk_package_url, vmware_ssh_private_key, openstack_tls_ca_certs, miq_task_id) conversion_host.save! if miq_task_id