Adds push to build script
This works as is, but could use some cleaning up and threading needs to be confirmed broken. If it isn't broken, it should be implemented. Co-Authored-By: Swapnil Kulkarni <me@coolsvap.net> Change-Id: I708406dcff8aa9b2f4064f03bda07873ce97d994 Paritally-Implements: blueprint build-script
This commit is contained in:
parent
3097d3e48d
commit
fca1e0658a
@ -111,7 +111,11 @@ def argParser():
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
default=False)
|
default=False)
|
||||||
parser.add_argument('--keep',
|
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',
|
action='store_true',
|
||||||
default=False)
|
default=False)
|
||||||
parser.add_argument('-T', '--threads',
|
parser.add_argument('-T', '--threads',
|
||||||
@ -248,20 +252,45 @@ class KollaWorker(object):
|
|||||||
return pools
|
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():
|
def main():
|
||||||
args = argParser()
|
args = argParser()
|
||||||
|
|
||||||
kolla = KollaWorker(args)
|
kolla = KollaWorker(args)
|
||||||
kolla.setupWorkingDir()
|
kolla.setupWorkingDir()
|
||||||
kolla.findDockerfiles()
|
kolla.findDockerfiles()
|
||||||
|
pools = kolla.buildQueues()
|
||||||
|
|
||||||
# Returns a list of Queues for us to loop through
|
# 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']):
|
for x in xrange(args['threads']):
|
||||||
WorkerThread(pool, args['no_cache'], args['keep']).start()
|
WorkerThread(pool, args['no_cache'], args['keep']).start()
|
||||||
# block until queue is empty
|
# block until queue is empty
|
||||||
pool.join()
|
pool.join()
|
||||||
|
|
||||||
|
if args['push']:
|
||||||
|
for tier in kolla.tiers:
|
||||||
|
for image in tier:
|
||||||
|
if image['status'] == "built":
|
||||||
|
push_image(image)
|
||||||
|
|
||||||
kolla.summary()
|
kolla.summary()
|
||||||
kolla.cleanup()
|
kolla.cleanup()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user