From 5913f04672672725bfb9a56499ad25e4e7c441c4 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 8 Nov 2016 16:42:45 -0800 Subject: Add ability to output the things built/failed/not build Instead of having users of kolla image building grep the output of kolla (or grep `docker images` before and after kolla is ran) to find what was actually built have kolla be able to write exactly what was built (thus avoiding the whole docker and grep stuff). Closes-Bug: #1640973 Change-Id: I11c031b4ded2ff780fa3ceb809a2ee232b36100c --- kolla/common/config.py | 3 +++ kolla/image/build.py | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/kolla/common/config.py b/kolla/common/config.py index 962f2c537..5ef8a3990 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -110,6 +110,9 @@ _CLI_OPTS = [ cfg.StrOpt('save-dependency', help=('Path to the file to store the docker image' ' dependency in Graphviz dot format')), + cfg.StrOpt('format', short='f', default='json', + choices=['json', 'none'], + help=('Format to write the final results in')), cfg.StrOpt('type', short='t', default='binary', choices=INSTALL_TYPE_CHOICES, dest='install_type', diff --git a/kolla/image/build.py b/kolla/image/build.py index 3816fc8e4..fde63e6a0 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -739,6 +739,11 @@ class KollaWorker(object): LOG.debug("Image %s failed", image.name) self.get_image_statuses() + results = { + 'built': [], + 'failed': [], + 'not_matched': [], + } if self.image_statuses_good: LOG.info("=========================") @@ -746,6 +751,9 @@ class KollaWorker(object): LOG.info("=========================") for name in self.image_statuses_good.keys(): LOG.info(name) + results['built'].append({ + 'name': name, + }) if self.image_statuses_bad: LOG.info("===========================") @@ -753,6 +761,10 @@ class KollaWorker(object): LOG.info("===========================") for name, status in self.image_statuses_bad.items(): LOG.error('%s Failed with status: %s', name, status) + results['failed'].append({ + 'name': name, + 'status': status, + }) if self.image_statuses_unmatched: LOG.debug("=====================================") @@ -760,6 +772,11 @@ class KollaWorker(object): LOG.debug("=====================================") for name in self.image_statuses_unmatched.keys(): LOG.debug(name) + results['not_matched'].append({ + 'name': name, + }) + + return results def get_image_statuses(self): if any([self.image_statuses_bad, @@ -997,7 +1014,8 @@ def run_build(): queue.put(WorkerThread.tombstone) raise - kolla.summary() + results = kolla.summary() kolla.cleanup() - + if conf.format == 'json': + print(json.dumps(results)) return kolla.get_image_statuses() -- cgit v1.2.3