Fix handling Unauthorized exception

Added class of exceptions - InvalidCredentials

Change-Id: Ic8250b138210e544b6194f59accdfe653f36667e
Closes-bug: #1428129
This commit is contained in:
Bulat Gaifullin 2015-11-06 20:07:15 +03:00 committed by tatyana-leontovich
parent f771e23c5c
commit 86225d7bee
3 changed files with 22 additions and 12 deletions

View File

@ -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):

View File

@ -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 "

View File

@ -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()