Skip to content

Commit

Permalink
Merge pull request #154 from smelamud/supports-vm-import
Browse files Browse the repository at this point in the history
Use supports_vm_import? instead of validate_import_vm
(cherry picked from commit afa9354)
  • Loading branch information
masayag authored and simaishi committed Dec 11, 2017
1 parent 73d0ac5 commit ebaffa0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/models/manageiq/providers/redhat/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ebaffa0

Please sign in to comment.