diff --git a/app/models/manageiq/providers/redhat/infra_manager/api_integration.rb b/app/models/manageiq/providers/redhat/infra_manager/api_integration.rb index 2d7242f51..4bb30701b 100644 --- a/app/models/manageiq/providers/redhat/infra_manager/api_integration.rb +++ b/app/models/manageiq/providers/redhat/infra_manager/api_integration.rb @@ -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)