summaryrefslogtreecommitdiff
path: root/glanceclient/common/https.py
diff options
context:
space:
mode:
authorDarja Shakhray <dshakhray@mirantis.com>2015-07-20 17:29:49 +0300
committerDarja Shakhray <dshakhray@mirantis.com>2015-07-21 17:08:27 +0300
commitec0f2dfd8500d230895e286462aaf69c43777038 (patch)
treed3ef94392fe49f222f07a7e33cb2a371185f95f5 /glanceclient/common/https.py
parentd9d586942bf3f78ba174eb5832f60d80a7c839ca (diff)
downloadpython-glanceclient-ec0f2dfd8500d230895e286462aaf69c43777038.tar.gz
Enable flake8 checks
This commit enables new flake8 checks: * E265 block comment should start with '# ' * H405 multi line docstring summary not separated with an empty line * E123 closing bracket does not match indentation of opening bracket's line * H238 old style class declaration, use new style (inherit from `object`) * E128 continuation line under-indented for visual indent and makes related changes in the code. Change-Id: Ie993afc930f6b74d7a990bcaa9fc0e9f5ba1585c
Diffstat (limited to 'glanceclient/common/https.py')
-rw-r--r--glanceclient/common/https.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/glanceclient/common/https.py b/glanceclient/common/https.py
index 30896e0..79f6d6d 100644
--- a/glanceclient/common/https.py
+++ b/glanceclient/common/https.py
@@ -58,6 +58,7 @@ from glanceclient import exc
def verify_callback(host=None):
"""
+
We use a partial around the 'real' verify_callback function
so that we can stash the host value without holding a
reference on the VerifiedHTTPSConnection.
@@ -71,8 +72,7 @@ def verify_callback(host=None):
def do_verify_callback(connection, x509, errnum,
depth, preverify_ok, host=None):
- """
- Verify the server's SSL certificate.
+ """Verify the server's SSL certificate.
This is a standalone function rather than a method to avoid
issues around closing sockets if a reference is held on
@@ -93,6 +93,7 @@ def do_verify_callback(connection, x509, errnum,
def host_matches_cert(host, x509):
"""
+
Verify that the x509 certificate we have received
from 'host' correctly identifies the server we are
connecting to, ie that the certificate's Common Name
@@ -140,13 +141,10 @@ def to_bytes(s):
class HTTPSAdapter(adapters.HTTPAdapter):
- """
- This adapter will be used just when
- ssl compression should be disabled.
+ """This adapter will be used just when ssl compression should be disabled.
- The init method overwrites the default
- https pool by setting glanceclient's
- one.
+ The init method overwrites the default https pool by setting
+ glanceclient's one.
"""
def __init__(self, *args, **kwargs):
classes_by_scheme = poolmanager.pool_classes_by_scheme
@@ -194,8 +192,9 @@ class HTTPSAdapter(adapters.HTTPAdapter):
class HTTPSConnectionPool(connectionpool.HTTPSConnectionPool):
"""
+
HTTPSConnectionPool will be instantiated when a new
- connection is requested to the HTTPSAdapter.This
+ connection is requested to the HTTPSAdapter. This
implementation overwrites the _new_conn method and
returns an instances of glanceclient's VerifiedHTTPSConnection
which handles no compression.
@@ -218,8 +217,7 @@ class HTTPSConnectionPool(connectionpool.HTTPSConnectionPool):
class OpenSSLConnectionDelegator(object):
- """
- An OpenSSL.SSL.Connection delegator.
+ """An OpenSSL.SSL.Connection delegator.
Supplies an additional 'makefile' method which httplib requires
and is not present in OpenSSL.SSL.Connection.
@@ -239,6 +237,7 @@ class OpenSSLConnectionDelegator(object):
class VerifiedHTTPSConnection(HTTPSConnection):
"""
+
Extended HTTPSConnection which uses the OpenSSL library
for enhanced SSL support.
Note: Much of this functionality can eventually be replaced
@@ -284,9 +283,7 @@ class VerifiedHTTPSConnection(HTTPSConnection):
raise exc.SSLConfigurationError(str(e))
def set_context(self):
- """
- Set up the OpenSSL context.
- """
+ """Set up the OpenSSL context."""
self.context = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
self.context.set_cipher_list(self.CIPHERS)
@@ -333,8 +330,9 @@ class VerifiedHTTPSConnection(HTTPSConnection):
def connect(self):
"""
- Connect to an SSL port using the OpenSSL library and apply
- per-connection parameters.
+
+ Connect to an SSL port using the OpenSSL library
+ and apply per-connection parameters.
"""
result = socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM)