diff options
| author | Ilya Shakhat <ishakhat@mirantis.com> | 2014-08-28 16:56:34 +0400 |
|---|---|---|
| committer | Ilya Shakhat <ishakhat@mirantis.com> | 2014-08-28 16:56:34 +0400 |
| commit | 9f3ffdf5bcb91425b3947bbf0d1d24c89791859b (patch) | |
| tree | 84f8e5ed9b0d91576ea5d4651979c7987b063cc3 | |
| parent | deb850b7282995d7e3b31210c177a2661578765b (diff) | |
| download | python-neutronclient-9f3ffdf5bcb91425b3947bbf0d1d24c89791859b.tar.gz | |
Remove unnecessary get_status_code wrapper function
Function get_status_code is used to get HTTP status code from
either requests.Response (status_code) or Webob.Response
(status_int). The latter was removed in 2012 and not needed
anymore.
Change-Id: Iacd6bbb83ce0d8ec5b8ec73273bc7bf39c9ccc8d
| -rw-r--r-- | neutronclient/client.py | 17 | ||||
| -rw-r--r-- | neutronclient/v2_0/client.py | 13 |
2 files changed, 3 insertions, 27 deletions
diff --git a/neutronclient/client.py b/neutronclient/client.py index 8720f1f..b9f9812 100644 --- a/neutronclient/client.py +++ b/neutronclient/client.py @@ -46,17 +46,6 @@ class NeutronClientMixin(object): USER_AGENT = 'python-neutronclient' - def get_status_code(self, response): - """Returns the integer status code from the response. - - Either a Webob.Response (used in testing) or requests.Response - is returned. - """ - if hasattr(response, 'status_int'): - return response.status_int - else: - return response.status_code - class HTTPClient(NeutronClientMixin): """Handles the REST calls and responses, include authn.""" @@ -127,8 +116,7 @@ class HTTPClient(NeutronClientMixin): _logger.debug("throwing ConnectionFailed : %s", e) raise exceptions.ConnectionFailed(reason=e) utils.http_log_resp(_logger, resp, body) - status_code = self.get_status_code(resp) - if status_code == 401: + if resp.status_code == 401: raise exceptions.Unauthorized(message=body) return resp, body @@ -222,8 +210,7 @@ class HTTPClient(NeutronClientMixin): body=json.dumps(body), content_type="application/json", allow_redirects=True) - status_code = self.get_status_code(resp) - if status_code != 200: + if resp.status_code != 200: raise exceptions.Unauthorized(message=resp_body) if resp_body: try: diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 49a49f2..e28d699 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -1240,7 +1240,7 @@ class Client(object): body = self.serialize(body) self.httpclient.content_type = self.content_type() resp, replybody = self.httpclient.do_request(action, method, body=body) - status_code = self.get_status_code(resp) + status_code = resp.status_code if status_code in (requests.codes.ok, requests.codes.created, requests.codes.accepted, @@ -1254,17 +1254,6 @@ class Client(object): def get_auth_info(self): return self.httpclient.get_auth_info() - def get_status_code(self, response): - """Returns the integer status code from the response. - - Either a Webob.Response (used in testing) or requests.Response - is returned. - """ - if hasattr(response, 'status_int'): - return response.status_int - else: - return response.status_code - def serialize(self, data): """Serializes a dictionary into either XML or JSON. |
