summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Koniszewski <pawel.koniszewski@intel.com>2014-09-03 08:58:55 -0400
committerZhi Yan Liu <lzy.dev@gmail.com>2014-09-03 23:44:39 +0800
commit16077d91ddfeebe77a3c6d7fedc7125ddff17bdb (patch)
tree0b5c4ecb9d41d121e1bfda45c9d14dc38e6a6a35
parent6dda6f306f44f68c437176428eb041d4fd862505 (diff)
downloadpython-glanceclient-16077d91ddfeebe77a3c6d7fedc7125ddff17bdb.tar.gz
Catch new urllib3 exception: ProtocolError
The new version of requests (2.4.0) has updated underlying urllib3 to version 1.9. Unfortunately urllib3 introduced new exception ProtocolError. Because of that unit tests in glance are failing: ProtocolError: ('Connection aborted.', gaierror(-2, 'Name or service not known')) To solve this problem new urllib3 exception is caught in the same place that the old one was. Unfortunately both exception are still in use so I couldn't remove the old one. Change-Id: I55eef98e734c59b9b627f182768a633b2b701e43 Closes-Bug: #1364893
-rw-r--r--glanceclient/common/http.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py
index 4023f03..8c7937a 100644
--- a/glanceclient/common/http.py
+++ b/glanceclient/common/http.py
@@ -18,6 +18,10 @@ import logging
import socket
import requests
+try:
+ from requests.packages.urllib3.exceptions import ProtocolError
+except ImportError:
+ ProtocolError = requests.exceptions.ConnectionError
import six
from six.moves.urllib import parse
@@ -198,7 +202,7 @@ class HTTPClient(object):
message = ("Error communicating with %(endpoint)s %(e)s" %
dict(url=conn_url, e=e))
raise exc.InvalidEndpoint(message=message)
- except requests.exceptions.ConnectionError as e:
+ except (requests.exceptions.ConnectionError, ProtocolError) as e:
message = ("Error finding address for %(url)s: %(e)s" %
dict(url=conn_url, e=e))
raise exc.CommunicationError(message=message)