Commit 24314811 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[scripts][worker] Add support for setting the docker network to use

parent 0f4e2ae4
......@@ -30,7 +30,7 @@
Usage:
%(prog)s [-v ... | --verbose ...] [ --name=<name>] [--prefix=<path>]
[--cache=<path>] [--docker] <address>
[--cache=<path>] [--docker] [--docker-network=<name>] <address>
%(prog)s (--help | -h)
%(prog)s (--version | -V)
......@@ -44,6 +44,7 @@ Options:
but not necessarily [default: %(hostname)s]
-p, --prefix=<path> Comma-separated list of the prefix(es) of your local data [default: .]
-c, --cache=<path> Cache prefix, otherwise defaults to '<prefix>/cache'
--docker-network=<name> Name of the docker network to use
"""
......@@ -273,11 +274,15 @@ def main(user_input=None):
# (If necessary) Docker-related initialisations
docker_images_cache = None
docker_network_name = None
if args['--docker']:
docker_images_cache = os.path.join(tempfile.gettempdir(), 'beat-docker-images.json')
logger.info("Using docker images cache: '%s'", docker_images_cache)
host = Host(images_cache=docker_images_cache, raise_on_errors=False)
docker_network_name = args.get('--docker-network', None)
if docker_network_name:
logger.info("Using docker network: '%s'", docker_network_name)
# Establish a connection with the scheduler
(context, socket, poller) = connect_to_scheduler(args['<address>'], args['--name'])
......@@ -369,6 +374,8 @@ def main(user_input=None):
if command == WorkerController.EXECUTE:
job_id = parts[1]
data = simplejson.loads(parts[2])
if docker_network_name:
data['network_name'] = docker_network_name
# Start the execution
logger.info("Running '%s' with job id #%s", data['algorithm'], job_id)
......
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