Add URL of the resource in exception message

When the OneView resource is not found in the driver validation,
the exception message just says "resource not found in oneview".
This patch adds the URL of the resource not found to the OneView
exception message.

Change-Id: Iaab4d50d42a361719f11a968b2423456eb1ad728
This commit is contained in:
Hugo Nicodemos
2016-09-20 10:32:23 +00:00
parent 0cee89e7b8
commit 971f3e799f

View File

@@ -172,7 +172,7 @@ class BaseClient(object):
response = requests.get( response = requests.get(
url, headers=headers, verify=verify_ssl url, headers=headers, verify=verify_ssl
) )
self._check_request_status(response) self._check_request_status(response, url)
versions = response.json() versions = response.json()
return versions return versions
@@ -214,7 +214,7 @@ class BaseClient(object):
@retrying.retry( @retrying.retry(
stop_max_attempt_number=self.max_polling_attempts, stop_max_attempt_number=self.max_polling_attempts,
retry_on_result=lambda response: self._check_request_status( retry_on_result=lambda response: self._check_request_status(
response response, url
), ),
wait_fixed=WAIT_DO_REQUEST_IN_MILLISECONDS wait_fixed=WAIT_DO_REQUEST_IN_MILLISECONDS
) )
@@ -310,7 +310,7 @@ class BaseClient(object):
finally: finally:
ilo_utils.ilo_logout(host_ip, ilo_token) ilo_utils.ilo_logout(host_ip, ilo_token)
def _check_request_status(self, response): def _check_request_status(self, response, url):
repeat = False repeat = False
status = response.status_code status = response.status_code
@@ -318,7 +318,7 @@ class BaseClient(object):
error_code = response.json().get('errorCode') error_code = response.json().get('errorCode')
raise exceptions.OneViewNotAuthorizedException(error_code) raise exceptions.OneViewNotAuthorizedException(error_code)
elif status == 404: elif status == 404:
raise exceptions.OneViewResourceNotFoundError() raise exceptions.OneViewResourceNotFoundError(url)
elif status in (408, 409,): elif status in (408, 409,):
time.sleep(10) time.sleep(10)
repeat = True repeat = True