Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion Host - Try hostname for SSH and fix MiqSshUtil args #18103

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops ;)

yield(ssu)
end
rescue Exception => e
Expand All @@ -134,15 +136,15 @@ 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
authentication = resource.ext_management_system.authentications
.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)
Expand Down