From 5fd23773641900ad5eebffbeea2e3d96cef138d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Fri, 13 Jan 2017 15:21:49 +0100 Subject: [PATCH] Support filtering output of --list-images In an effort to be more consistent in the behavior of kolla-build, only return matched images in the output of kolla-build --list-images. Change-Id: I583e20f181535fa1879730cbe88dd76276c08a80 Closes-Bug: #1656146 --- kolla/common/config.py | 2 +- kolla/image/build.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kolla/common/config.py b/kolla/common/config.py index cacd20cb33..f31c9e452b 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -160,7 +160,7 @@ _CLI_OPTS = [ cfg.BoolOpt('list-dependencies', short='l', help='Show image dependencies (filtering supported)'), cfg.BoolOpt('list-images', - help='Show all available images'), + help='Show all available images (filtering supported)'), cfg.StrOpt('namespace', short='n', default='kolla', help='The Docker namespace name'), cfg.BoolOpt('cache', default=True, diff --git a/kolla/image/build.py b/kolla/image/build.py index 35029f198b..073c10788e 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -870,7 +870,9 @@ class KollaWorker(object): f.write(dot.source) def list_images(self): - for count, image in enumerate(self.images): + for count, image in enumerate([ + image for image in self.images if image.status == STATUS_MATCHED + ]): print(count + 1, ':', image.name) def list_dependencies(self): @@ -973,6 +975,8 @@ def run_build(): return if conf.list_images: kolla.build_image_list() + kolla.find_parents() + kolla.filter_images() kolla.list_images() return if conf.list_dependencies: