From f864049fb3f0ee051a161e537b5d753282c18ffd Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Thu, 23 May 2019 08:35:04 -0400 Subject: [PATCH 1/4] Fix private key authentication for RHV conversion host --- app/models/conversion_host.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 83620a3cf83..551eba65665 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -232,17 +232,15 @@ def connect_ssh end def miq_ssh_util_args - send("miq_ssh_util_args_#{resource.type.gsub('::', '_').downcase}") - end - - def miq_ssh_util_args_manageiq_providers_redhat_inframanager_host authentication = find_credentials - [hostname || ipaddress, authentication.userid, authentication.password, nil, nil] - end - - def miq_ssh_util_args_manageiq_providers_openstack_cloudmanager_vm - authentication = find_credentials - [hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] + case authentication.type + when 'AuthPrivateKey' + return [hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] + when 'AuthUseridPassword' + return[hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] + else + raise 'Unsupported authentication type: #{authentication.type}' + end end # Run the specified ansible playbook using the ansible-playbook command. The From 67f668b5dd9ef1f7fbb2ed2355fab81f3d101f56 Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Thu, 23 May 2019 08:58:25 -0400 Subject: [PATCH 2/4] Add AuthToken for OSP legacy private key --- app/models/conversion_host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 551eba65665..f5694430807 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -234,7 +234,7 @@ def connect_ssh def miq_ssh_util_args authentication = find_credentials case authentication.type - when 'AuthPrivateKey' + when 'AuthPrivateKey', 'AuthToken' return [hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] when 'AuthUseridPassword' return[hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] From 9b4abbb7cf263890a5553df0f133ce4f24f8b068 Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Thu, 23 May 2019 09:22:23 -0400 Subject: [PATCH 3/4] Fix auth for AuthUseridPassword --- app/models/conversion_host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index f5694430807..049dee746d8 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -237,7 +237,7 @@ def miq_ssh_util_args when 'AuthPrivateKey', 'AuthToken' return [hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] when 'AuthUseridPassword' - return[hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }] + return [hostname || ipaddress, authentication.userid, authentication.password, nil, nil] else raise 'Unsupported authentication type: #{authentication.type}' end From e4ba9ed5feb87fccab50713c852c6eefea586be4 Mon Sep 17 00:00:00 2001 From: Fabien Dupont Date: Thu, 23 May 2019 09:56:40 -0400 Subject: [PATCH 4/4] Fixing string interpolation in exception --- app/models/conversion_host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 049dee746d8..7acd57ae96e 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -239,7 +239,7 @@ def miq_ssh_util_args when 'AuthUseridPassword' return [hostname || ipaddress, authentication.userid, authentication.password, nil, nil] else - raise 'Unsupported authentication type: #{authentication.type}' + raise "Unsupported authentication type: #{authentication.type}" end end