diff --git a/app/models/manageiq/providers/redhat/infra_manager.rb b/app/models/manageiq/providers/redhat/infra_manager.rb index 2d7fa3e46..1faee3079 100644 --- a/app/models/manageiq/providers/redhat/infra_manager.rb +++ b/app/models/manageiq/providers/redhat/infra_manager.rb @@ -22,6 +22,10 @@ class ManageIQ::Providers::Redhat::InfraManager < ManageIQ::Providers::InfraMana supports :provisioning supports :refresh_new_target + supports :vm_import do + # The version of the RHV needs to be at least 4.1.5 due to https://bugzilla.redhat.com/1477375 + unsupported_reason_add(:vm_import, _('Cannot import to a RHV provider of version < 4.1.5')) unless version_at_least?('4.1.5') + end def supports_admin_ui? # Link to oVirt Admin UI is supported for Engine version 4.1.8 or better. diff --git a/app/models/manageiq/providers/redhat/infra_manager/vm_import.rb b/app/models/manageiq/providers/redhat/infra_manager/vm_import.rb index 7a6e2846b..0a3aee054 100644 --- a/app/models/manageiq/providers/redhat/infra_manager/vm_import.rb +++ b/app/models/manageiq/providers/redhat/infra_manager/vm_import.rb @@ -58,11 +58,6 @@ def submit_import_vm(userid, source_vm_id, target_params) task.task_results end - def validate_import_vm - # The version of the RHV needs to be at least 4.1.5 due to https://bugzilla.redhat.com/1477375 - version_at_least?('4.1.5') - end - def submit_configure_imported_vm_networks(userid, vm_id) task_id = queue_self_method_call(userid, "Configure imported VM's networks", 'configure_imported_vm_networks', vm_id) task = MiqTask.wait_for_taskid(task_id) @@ -77,7 +72,7 @@ def submit_configure_imported_vm_networks(userid, vm_id) def check_import_supported!(source_provider) raise _('Cannot import archived VMs') if source_provider.nil? - raise _('Cannot import to a RHEV provider of version < 4.1.5') unless validate_import_vm + raise unsupported_reason(:vm_import) unless supports_vm_import? unless source_provider.type == ManageIQ::Providers::Vmware::InfraManager.name raise _('Source provider must be of type Vmware') end diff --git a/spec/models/manageiq/providers/redhat/infra_manager/vm_import_spec.rb b/spec/models/manageiq/providers/redhat/infra_manager/vm_import_spec.rb index ccb5a68f6..4d501887f 100644 --- a/spec/models/manageiq/providers/redhat/infra_manager/vm_import_spec.rb +++ b/spec/models/manageiq/providers/redhat/infra_manager/vm_import_spec.rb @@ -106,17 +106,17 @@ def expect_import(params, expected_request) it 'validates successfully' do allow(ems).to receive(:api_version).and_return('4.1.5') - expect(ems.validate_import_vm).to be_truthy + expect(ems.supports_vm_import?).to be_truthy end it 'fails validation on old api version' do allow(ems).to receive(:api_version).and_return('4.1.4') - expect(ems.validate_import_vm).to be_falsey + expect(ems.supports_vm_import?).to be_falsey end it 'validates before connecting' do allow(ems).to receive(:api_version).and_return(nil) - expect(ems.validate_import_vm).to be_falsey + expect(ems.supports_vm_import?).to be_falsey end end end