Skip to content

Commit

Permalink
Merge pull request #19927 from fdupont-redhat/v2v_fail_chost_config_i…
Browse files Browse the repository at this point in the history
…f_no_ip

Configuration of conversion host without IP should fail early
  • Loading branch information
agrare authored Mar 4, 2020
2 parents 12ac4ba + b336a19 commit df04518
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ def ansible_playbook(playbook, extra_vars = {}, miq_task_id = nil, auth_type = '
task = MiqTask.find(miq_task_id) if miq_task_id.present?

host = hostname || ipaddress
raise "#{resource.class.name.demodulize} '#{resource.name}' doesn't have a hostname or IP address in inventory" if host.nil?

params = [
playbook,
Expand Down
6 changes: 6 additions & 0 deletions spec/models/conversion_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@
expect { conversion_host.enable_conversion_host_role }.to raise_error("vmware_vddk_package_url is mandatory if transformation method is vddk")
end

it "enable_conversion_host_role raises if resource has no hostname nor IP address" do
allow(host).to receive(:hostname).and_return(nil)
allow(host).to receive(:ipaddresses).and_return([])
expect { conversion_host.enable_conversion_host_role('http://file.example.com/vddk-stable.tar.gz', nil) }.to raise_error("Host '#{host.name}' doesn't have a hostname or IP address in inventory")
end

it "enable_conversion_host_role calls ansible_playbook with extra_vars" do
check_playbook = '/usr/share/v2v-conversion-host-ansible/playbooks/conversion_host_check.yml'
enable_extra_vars = {
Expand Down

0 comments on commit df04518

Please sign in to comment.