diff --git a/doc/api/config.rst b/doc/api/config.rst index 2e563cd4..ae36d9f9 100644 --- a/doc/api/config.rst +++ b/doc/api/config.rst @@ -84,6 +84,18 @@ Command Line Options Used to specify the Gearman job server hostname and port. This option can be used multiple times to specify multiple job servers. + .. option:: --gearman_ssl_ca + + The path for the Gearman SSL Certificate Authority + + .. option:: --gearman_ssl_cert + + The path for the Gearman SSL certificate + + .. option:: --gearman_ssl_key + + The path for the Gearman SSL key + .. option:: --keystone_module A colon separated module and class to use as the keystone authentication diff --git a/libra/api/app.py b/libra/api/app.py index be860e06..172117ff 100644 --- a/libra/api/app.py +++ b/libra/api/app.py @@ -62,7 +62,10 @@ def setup_app(pecan_config, args): 'swift_endpoint': args.swift_endpoint } config['gearman'] = { - 'server': args.gearman + 'server': args.gearman, + 'ssl_key': args.gearman_ssl_key, + 'ssl_cert': args.gearman_ssl_cert, + 'ssl_ca': args.gearman_ssl_ca } if args.debug: config['wsme'] = {'debug': True} @@ -145,6 +148,18 @@ def main(): '--gearman', action='append', metavar='HOST:PORT', default=[], help='Gearman job servers' ) + options.parser.add_argument( + '--gearman_ssl_ca', metavar='FILE', + help='Gearman SSL certificate authority' + ) + options.parser.add_argument( + '--gearman_ssl_cert', metavar='FILE', + help='Gearman SSL certificate' + ) + options.parser.add_argument( + '--gearman_ssl_key', metavar='FILE', + help='Gearman SSL key' + ) options.parser.add_argument( '--keystone_module', default='keystoneclient.middleware.auth_token:AuthProtocol', diff --git a/libra/api/library/gearman_client.py b/libra/api/library/gearman_client.py index 7c5a9822..bb47e908 100644 --- a/libra/api/library/gearman_client.py +++ b/libra/api/library/gearman_client.py @@ -54,7 +54,21 @@ class GearmanClientThread(object): self.logger = logger self.host = host self.lbid = lbid - self.gearman_client = JSONGearmanClient(conf.gearman.server) + + if all([conf.gearman.ssl_key, conf.gearman.ssl_cert, + conf.gearman.ssl_ca]): + # Use SSL connections to each Gearman job server. + ssl_server_list = [] + for server in conf.gearman: + ghost, gport = server.split(':') + ssl_server_list.append({'host': ghost, + 'port': gport, + 'keyfile': conf.gearman.ssl_key, + 'certfile': conf.gearman.ssl_cert, + 'ca_certs': conf.gearman.ssl_ca}) + self.gearman_client = JSONGearmanClient(ssl_server_list) + else: + self.gearman_client = JSONGearmanClient(conf.gearman.server) def send_delete(self, data): with db_session() as session: