diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 1c1cb4fdd88..a92c735f0de 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -7,6 +7,7 @@ class ConversionHost < ApplicationRecord has_many :service_template_transformation_plan_tasks, :dependent => :nullify has_many :active_tasks, -> { where(:state => 'active') }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host delegate :ext_management_system, :to => :resource, :allow_nil => true + delegate :hostname, :to => :resource, :allow_nil => true # To be eligible, a conversion host must have the following properties # - A transport mechanism is configured for source (set by 3rd party) @@ -39,7 +40,8 @@ def ipaddress(family = 'ipv4') end def run_conversion(conversion_options) - connect_ssh { |ssu| ssu.shell_exec('/usr/bin/virt-v2v-wrapper.py', nil, nil, conversion_options.to_json) } + result = connect_ssh { |ssu| ssu.shell_exec('/usr/bin/virt-v2v-wrapper.py', nil, nil, conversion_options.to_json) } + JSON.parse(result) rescue => e raise "Starting conversion failed on '#{resource.name}' with [#{e.class}: #{e}]" end @@ -121,7 +123,7 @@ def check_resource_credentials_openstack def connect_ssh require 'MiqSshUtil' - MiqSshUtil.shell_with_su(miq_ssh_util_args) do |ssu, _shell| + MiqSshUtil.shell_with_su(*miq_ssh_util_args) do |ssu, _shell| yield(ssu) end rescue Exception => e @@ -134,7 +136,7 @@ def miq_ssh_util_args end def miq_ssh_util_args_manageiq_providers_redhat_inframanager_host - [ ipaddress, resource.authentication_userid, resource.authentication_password, nil, nil ] + [hostname || ipaddress, resource.authentication_userid, resource.authentication_password, nil, nil] end def miq_ssh_util_args_manageiq_providers_openstack_cloudmanager_vm @@ -142,7 +144,7 @@ def miq_ssh_util_args_manageiq_providers_openstack_cloudmanager_vm .where(:authtype => 'ssh_keypair') .where.not(:userid => nil, :auth_key => nil) .first - [ ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] + [hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] end def ansible_playbook(playbook, extra_vars, connection)