Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fix handling Unauthorized exception
Browse files Browse the repository at this point in the history
Added class of exceptions - InvalidCredentials

Change-Id: Ic8250b138210e544b6194f59accdfe653f36667e
Closes-bug: #1428129
  • Loading branch information
bgaifullin authored and TatyankaLeontovich committed Nov 11, 2015
1 parent f771e23 commit 86225d7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
8 changes: 6 additions & 2 deletions fuel_health/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,13 @@ def find_proxy(self, ip):
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):
Expand Down
8 changes: 8 additions & 0 deletions fuel_health/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
18 changes: 8 additions & 10 deletions fuel_health/nmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,15 @@ def __init__(self):
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()

Expand Down

0 comments on commit 86225d7

Please sign in to comment.