From 2a6437efdd208e92c71157e2613f7a140c9a14a5 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Tue, 14 Jul 2015 07:00:55 +0000 Subject: [PATCH] Improve build.py Fixed docker client to use ENV if exists to support boot2docker. Fixed booleans not working as thought with argParser. Change-Id: I232ed78443199ce20f4b38e12c861c0f97d55c99 Partially-Implements: blueprint build-script --- tools/build.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/build.py b/tools/build.py index cb3b6ce579..11f23f6036 100755 --- a/tools/build.py +++ b/tools/build.py @@ -37,11 +37,11 @@ import docker class WorkerThread(Thread): - def __init__(self, queue, cache, rm): + def __init__(self, queue, nocache, keep): self.queue = queue - self.nocache = not cache - self.forcerm = rm - self.dc = docker.Client() + self.nocache = nocache + self.forcerm = not keep + self.dc = docker.Client(**docker.utils.kwargs_from_env()) Thread.__init__(self) def run(self): @@ -85,7 +85,7 @@ class WorkerThread(Thread): raise Exception(stream['errorDetail']['message']) image['status'] = "built" - print(image['logs'], '\nProcessed:', image['name']) + print(image['logs'], 'Processed:', image['name']) def argParser(): @@ -106,14 +106,14 @@ def argParser(): help='The method of the Openstack install', type=str, default='binary') - parser.add_argument('-c', '--cache', - help='Use Docker cache when building', - type=bool, - default=True) - parser.add_argument('-r', '--rm', - help='Remove intermediate containers while building', - type=bool, - default=True) + parser.add_argument('--no-cache', + help='Do not use the Docker cache when building', + action='store_true', + default=False) + parser.add_argument('--keep', + help='Keep failed intermediate containers building', + action='store_true', + default=False) parser.add_argument('-T', '--threads', help='The number of threads to use while building', type=int, @@ -258,7 +258,7 @@ def main(): # Returns a list of Queues for us to loop through for pool in kolla.buildQueues(): for x in xrange(args['threads']): - WorkerThread(pool, args['cache'], args['rm']).start() + WorkerThread(pool, args['no_cache'], args['keep']).start() # block until queue is empty pool.join()