diff options
Diffstat (limited to 'kolla/image')
| -rw-r--r-- | kolla/image/build.py | 5 | ||||
| -rw-r--r-- | kolla/image/kolla_worker.py | 20 |
2 files changed, 21 insertions, 4 deletions
diff --git a/kolla/image/build.py b/kolla/image/build.py index fdf1635c8..86f0d8a71 100644 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -11,7 +11,6 @@ # limitations under the License. import contextlib -import json import logging import queue import shutil @@ -195,8 +194,6 @@ def run_build(): raise if conf.summary: - results = kolla.summary() - if conf.format == 'json': - print(json.dumps(results)) + kolla.summary() kolla.cleanup() return kolla.get_image_statuses() diff --git a/kolla/image/kolla_worker.py b/kolla/image/kolla_worker.py index 1a665ddd4..e7ee35574 100644 --- a/kolla/image/kolla_worker.py +++ b/kolla/image/kolla_worker.py @@ -564,6 +564,26 @@ class KollaWorker(object): 'name': name, }) + if self.conf.format == 'json': + + def json_summary(f, **kwargs): + json.dump(results, f, **kwargs) + + if self.conf.summary_json_file: + try: + with open(self.conf.summary_json_file, "w") as f: + json_summary(f, indent=4) + except OSError as e: + LOG.error(f'Failed to write JSON build summary to ' + '{self.conf.summary_json_file}') + LOG.error(f'Exception caught: {e}') + sys.exit(1) + + else: + # NOTE(mgoddard): Keep single line output for + # backwards-compatibility. + json_summary(sys.stdout) + return results def get_image_statuses(self): |
