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

Allow ssh auth for RHV #18805

Merged
merged 3 commits into from
May 23, 2019
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
32 changes: 10 additions & 22 deletions app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,31 +280,19 @@ def connect_ssh
raise e
end

# Collect appropriate authentication information based on the resource type.
#--
# TODO: This should be handled by a ConversionHost subclass within each supported provider.
# Collect appropriate authentication information based on the authentication type.
#
def miq_ssh_util_args
send("miq_ssh_util_args_#{resource.type.gsub('::', '_').downcase}")
end

# For the Redhat provider, use the userid and password associated directly with the resource.
#--
# TODO: Move this to ManageIQ::Providers::Redhat::InfraManager::ConversionHost
#
def miq_ssh_util_args_manageiq_providers_redhat_inframanager_host
authentication = find_credentials
[hostname || ipaddress, authentication.userid, authentication.password, nil, nil]
end

# For the OpenStack provider, use the first authentication containing an ssh keypair that has
# both a userid and auth key.
#--
# TODO: Move this to ManageIQ::Providers::OpenStack::CloudManager::ConversionHost
#
def miq_ssh_util_args_manageiq_providers_openstack_cloudmanager_vm
host = hostname || ipaddress
authentication = find_credentials
[hostname || ipaddress, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }]
case authentication.type
when 'AuthPrivateKey', 'AuthToken'
[host, authentication.userid, nil, nil, nil, { :key_data => authentication.auth_key, :passwordless_sudo => true }]
when 'AuthUseridPassword'
[host, authentication.userid, authentication.password, nil, nil]
else
raise "Unsupported authentication type: #{authentication.type}"
end
end

# Run the specified ansible playbook using the ansible-playbook command. The
Expand Down