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

Raise Miq exceptions on connect #162

Merged
merged 1 commit into from
Nov 30, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,25 @@ def verify_credentials_for_rhevm(options = {})
raise e
rescue RestClient::Unauthorized
raise MiqException::MiqInvalidCredentialsError, "Incorrect user name or password."
rescue OvirtSDK4::Error => e
rethrow_as_a_miq_error(e)
rescue
_log.error("Error while verifying credentials #{$ERROR_INFO}")
raise MiqException::MiqEVMLoginError, $ERROR_INFO
end

def rethrow_as_a_miq_error(e)
case e.message
when /The username or password is incorrect/
raise MiqException::MiqInvalidCredentialsError
when /Couldn't connect to server/, /Couldn't resolve host name/
raise MiqException::MiqUnreachableError, $ERROR_INFO
else
_log.error("Error while verifying credentials #{$ERROR_INFO}")
raise MiqException::MiqEVMLoginError, $ERROR_INFO
end
end

def rhevm_metrics_connect_options(options = {})
metrics_hostname = connection_configuration_by_role('metrics')
.try(:endpoint)
Expand Down