Debug LXDContainerDriver
@@ -99,9 +99,9 @@ class LXDtlsConnection(KeyCertificateConnection):
responseCls = LXDResponse
- def __init__(self, secure=True,
+ def __init__(self, key, secret, secure=True,
host='localhost',
- port=8443, key_file='', cert_file=''):
+ port=8443, ca_cert='', key_file='', cert_file='', **kwargs):
super(LXDtlsConnection, self).__init__(key_file=key_file,
cert_file=cert_file,
@@ -110,6 +110,29 @@ class LXDtlsConnection(KeyCertificateConnection):
proxy_url=None,
timeout=None, backoff=None,
retry_delay=None)
+ if key_file:
+ keypath = os.path.expanduser(key_file)
+ is_file_path = os.path.exists(keypath) and os.path.isfile(keypath)
+ if not is_file_path:
+ raise InvalidCredsError(
+ 'You need an key PEM file to authenticate with '
+ 'Docker tls. This can be found in the server.'
+ )
+ self.key_file = key_file
+
+ certpath = os.path.expanduser(cert_file)
+ is_file_path = os.path.exists(
+ certpath) and os.path.isfile(certpath)
+ if not is_file_path:
+ raise InvalidCredsError(
+ 'You need an certificate PEM file to authenticate with '
+ 'Docker tls. This can be found in the server.'
+ )
+ self.cert_file = cert_file
+
+ def add_default_headers(self, headers):
+ headers['Content-Type'] = 'application/json'
+ return headers
class LXDContainerDriver(ContainerDriver):
@@ -128,7 +151,6 @@ class LXDContainerDriver(ContainerDriver):
secure=False, host='localhost',
port=8443, key_file=None,
cert_file=None, ca_cert=None, **kwargs):
-
if key_file:
self.connectionCls = LXDtlsConnection
self.key_file = key_file
@@ -282,6 +304,7 @@ class LXDContainerDriver(ContainerDriver):
:rtype: ``list`` of :class:`.Container`
"""
+
result = self.connection.request(action='/%s/containers/'
%(self.version))
containers = [self._to_container(value) for value in result]
