diff --git a/fuel_health/config.py b/fuel_health/config.py index a2b17a08..ff434c12 100644 --- a/fuel_health/config.py +++ b/fuel_health/config.py @@ -782,9 +782,13 @@ class NailgunConfig(object): insecure=False, timeout=10) return ip - except Exception: + except (keystoneclient.exceptions.AuthorizationFailure, + keystoneclient.exceptions.Unauthorized): + raise exceptions.InvalidCredentials + except Exception as e: LOG.warning('Can not pass authorization ' - 'with proxy on {0}'.format(ip)) + 'with proxy on {0}, error: {1}' + .format(ip, e)) LOG.debug(traceback.format_exc()) def set_proxy(self): diff --git a/fuel_health/exceptions.py b/fuel_health/exceptions.py index 858c3d0d..0ca15612 100644 --- a/fuel_health/exceptions.py +++ b/fuel_health/exceptions.py @@ -51,6 +51,14 @@ class InvalidConfiguration(FuelException): message = "Invalid Configuration" +class InvalidCredentials(InvalidConfiguration): + message = ( + "Authorization failure. " + "Please provide the valid credentials for your OpenStack environment, " + "and reattempt." + ) + + class SetProxy(InvalidConfiguration): message = ("Can not set proxy for Health Check." "Make sure that network configuration " diff --git a/fuel_health/nmanager.py b/fuel_health/nmanager.py index a485f6c6..6f39623a 100644 --- a/fuel_health/nmanager.py +++ b/fuel_health/nmanager.py @@ -84,17 +84,15 @@ class OfficialClientManager(fuel_health.manager.Manager): self.identity_client = self._get_identity_client() self.identity_v3_client = self._get_identity_client(version=3) self.clients_initialized = True + except (keystoneclient.exceptions.AuthorizationFailure, + keystoneclient.exceptions.Unauthorized): + self.keystone_error_message = \ + exceptions.InvalidCredentials.message except Exception as e: - if e.__class__.__name__ == 'Unauthorized': - self.keystone_error_message = ('Unable to run test: OpenStack' - ' Authorization Failure. ' - 'If login or ' - 'password was changed, ' - 'please update ' - 'environment settings. ' - 'Please refer to Mirantis ' - 'OpenStack documentation ' - 'for more details.') + LOG.error( + "Unexpected error durring intialize keystoneclient: {0}" + .format(e) + ) LOG.debug(traceback.format_exc()) self.traceback = traceback.format_exc()