Fix failure to create glance https connection pool

Due to a typo in an attribute named, an Attribute error is raised
causing failure in connection to glance through HTTPS

Urllib3 PoolManager class has a connection_pool_kw attribute
but not connection_kw

Closes-Bug: #1479020
Change-Id: Id4d6a5bdcf971d09e80043fd2ab399e208fd931c
This commit is contained in:
Haikel Guemar
2015-07-22 11:41:42 +02:00
parent d9d586942b
commit c41dcc9f43
2 changed files with 20 additions and 3 deletions
+4 -3
View File
@@ -162,15 +162,16 @@ class HTTPSAdapter(adapters.HTTPAdapter):
return url
def _create_glance_httpsconnectionpool(self, url):
kw = self.poolmanager.connection_kw
kw = self.poolmanager.connection_pool_kw
# Parse the url to get the scheme, host, and port
parsed = compat.urlparse(url)
# If there is no port specified, we should use the standard HTTPS port
port = parsed.port or 443
pool = HTTPSConnectionPool(parsed.host, port, **kw)
host = parsed.netloc.rsplit(':', 1)[0]
pool = HTTPSConnectionPool(host, port, **kw)
with self.poolmanager.pools.lock:
self.poolmanager.pools[(parsed.scheme, parsed.host, port)] = pool
self.poolmanager.pools[(parsed.scheme, host, port)] = pool
return pool
+16
View File
@@ -451,3 +451,19 @@ class TestRequestsIntegration(testtools.TestCase):
adapter = client.session.adapters.get("glance+https://")
self.assertTrue(isinstance(adapter, https.HTTPSAdapter))
class TestHTTPSAdapter(testtools.TestCase):
def test__create_glance_httpsconnectionpool(self):
"""Regression test
Check that glanceclient's https pool is properly
configured without any weird exception.
"""
url = 'https://127.0.0.1:8000'
adapter = https.HTTPSAdapter()
try:
adapter._create_glance_httpsconnectionpool(url)
except Exception:
self.fail('Unexpected exception has been raised')