Commit 1a786b53 authored by Daniele Venzano's avatar Daniele Venzano

Docker TLS support

parent 31e9ea11
......@@ -4,6 +4,7 @@
* Add Jenkinsfile with test pipeline
* Update moment.js third-party library
* Docker TLS support
## Version 0.10.2
......@@ -88,6 +88,10 @@ def load_configuration(test_conf=None):
argparser.add_argument('--scheduler-class', help='Scheduler class to use for scheduling ZApps', default='ZoeSimpleScheduler')
argparser.add_argument('--docker-tls-cert', help='Docker TLS certificate file', default='cert.pem')
argparser.add_argument('--docker-tls-key', help='Docker TLS private key file', default='key.pem')
argparser.add_argument('--docker-tls-ca', help='Docker TLS CA certificate file', default='ca.pem')
opts = argparser.parse_args()
if opts.debug:
......@@ -126,15 +126,19 @@ class SwarmClient:
def __init__(self, opts: Namespace) -> None:
self.opts = opts
url = opts.swarm
tls = False
if 'zk://' in url:
url = url[len('zk://'):]
manager = zookeeper_swarm(url)
elif 'http://' or 'https://' in url:
elif 'http://' in url:
manager = url
elif 'https://' in url:
tls = docker.tls.TLSConfig(client_cert=(opts.docker_tls_cert, opts.docker_tls_key), verify=opts.docker_tls_ca)
manager = url
raise ZoeLibException('Unsupported URL scheme for Swarm')
log.debug('Connecting to Swarm at {}'.format(manager))
self.cli = docker.Client(base_url=manager, version="auto")
# log.debug('Connecting to Swarm at {}'.format(manager))
self.cli = docker.Client(base_url=manager, version="auto", tls=tls)
def info(self) -> SwarmStats:
"""Retrieve Swarm statistics. The Docker API returns a mess difficult to parse."""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment