aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-08-06 20:25:41 +0000
committerGerrit Code Review <review@openstack.org>2015-08-06 20:25:41 +0000
commit10164f06d8dff7a98720931b8df5dc2568395c0c (patch)
tree9028ec52e5878b49e5125d8e9e2efdb00c47c8ae
parent6545a66efd16da9e5a98c5a26763527a1e2718d7 (diff)
parentfca1e0658acbc9e09d8ace9ab648bd56601fe24a (diff)
downloadkolla-10164f06d8dff7a98720931b8df5dc2568395c0c.tar.gz
kolla-10164f06d8dff7a98720931b8df5dc2568395c0c.zip
Merge "Adds push to build script"
-rwxr-xr-xtools/build.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/tools/build.py b/tools/build.py
index 11f23f603..ac471960b 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -111,7 +111,11 @@ def argParser():
action='store_true',
default=False)
parser.add_argument('--keep',
- help='Keep failed intermediate containers building',
+ help='Keep failed intermediate containers',
+ action='store_true',
+ default=False)
+ parser.add_argument('--push',
+ help='Push images after building',
action='store_true',
default=False)
parser.add_argument('-T', '--threads',
@@ -248,20 +252,45 @@ class KollaWorker(object):
return pools
+def push_image(image):
+ dc = docker.Client(**docker.utils.kwargs_from_env())
+
+ image['push_logs'] = str()
+ for response in dc.push(image['fullname'],
+ stream=True,
+ insecure_registry=True):
+ stream = json.loads(response)
+
+ if 'stream' in stream:
+ image['push_logs'] = image['logs'] + stream['stream']
+ # This is only single threaded for right now so we can show logs
+ print(stream['stream'])
+ elif 'errorDetail' in stream:
+ image['status'] = "error"
+ raise Exception(stream['errorDetail']['message'])
+
+
def main():
args = argParser()
kolla = KollaWorker(args)
kolla.setupWorkingDir()
kolla.findDockerfiles()
+ pools = kolla.buildQueues()
# Returns a list of Queues for us to loop through
- for pool in kolla.buildQueues():
+ for pool in pools:
for x in xrange(args['threads']):
WorkerThread(pool, args['no_cache'], args['keep']).start()
# block until queue is empty
pool.join()
+ if args['push']:
+ for tier in kolla.tiers:
+ for image in tier:
+ if image['status'] == "built":
+ push_image(image)
+
kolla.summary()
kolla.cleanup()