aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
authorJeff Peeler <jpeeler@redhat.com>2016-05-04 23:25:53 -0400
committerJeff Peeler <jpeeler@redhat.com>2016-05-05 00:03:31 -0400
commit696f0b9a06e415d8ef320bd8279c4911edbaca7f (patch)
tree3ea3a757df7cf4a1c728e9044b4f8c2ebb543c21 /kolla
parent233158f7544d783442cf4dc9346427fb04f36254 (diff)
downloadkolla-696f0b9a06e415d8ef320bd8279c4911edbaca7f.tar.gz
kolla-696f0b9a06e415d8ef320bd8279c4911edbaca7f.zip
Generate image dependencies on CLI
Using the new --list-dependencies flag, one can query dependencies for a given filter. For example: ./build.py --list-dependencies heat swift {'base': [{'openstack-base': [{'heat-base': ['heat-engine', 'heat-api-cfn', 'heat-api']}, {'swift-base': ['swift-object', 'swift-proxy-server', 'swift-container', 'swift-rsyncd', 'swift-account']}]}]} Also added --list-images to list all available images. Change-Id: I1797e32e32705182a763f53329eeb5c4a361abec Implements: blueprint images-dependency-tree-cli
Diffstat (limited to 'kolla')
-rwxr-xr-xkolla/cmd/build.py40
-rw-r--r--kolla/common/config.py4
2 files changed, 44 insertions, 0 deletions
diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py
index 5a00b1d80..b305ffd7b 100755
--- a/kolla/cmd/build.py
+++ b/kolla/cmd/build.py
@@ -13,6 +13,7 @@
# limitations under the License.
# TODO(jpeeler): Add clean up handler for SIGINT
+from __future__ import print_function
import datetime
import errno
@@ -20,6 +21,7 @@ import graphviz
import json
import logging
import os
+import pprint
import re
import requests
import shutil
@@ -662,6 +664,38 @@ class KollaWorker(object):
with open(to_file, 'w') as f:
f.write(dot.source)
+ def list_images(self):
+ for count, image in enumerate(self.images):
+ print(count + 1, ':', image['name'])
+
+ def list_dependencies(self):
+ match = False
+ for image in self.images:
+ if image['status'] in ['matched']:
+ match = True
+ if image['parent'] is None:
+ base = image
+ if not match:
+ print('Nothing matched!')
+ return
+
+ def list_children(images, ancestry):
+ children = ancestry.values()[0]
+ for item in images:
+ if item['status'] not in ['matched']:
+ continue
+
+ if not item['children']:
+ children.append(item['name'])
+ else:
+ newparent = {item['name']: []}
+ children.append(newparent)
+ list_children(item['children'], newparent)
+
+ ancestry = {base['name']: []}
+ list_children(base['children'], ancestry)
+ pprint.pprint(ancestry)
+
def find_parents(self):
"""Associate all images with parents and children"""
sort_images = dict()
@@ -723,6 +757,12 @@ def main():
LOG.info('Docker images dependency is saved in %s',
conf.save_dependency)
return
+ if conf.list_images:
+ kolla.list_images()
+ return
+ if conf.list_dependencies:
+ kolla.list_dependencies()
+ return
for x in six.moves.range(conf.threads):
worker = WorkerThread(queue, push_queue, conf)
diff --git a/kolla/common/config.py b/kolla/common/config.py
index 6ccbdf780..31836c4ba 100644
--- a/kolla/common/config.py
+++ b/kolla/common/config.py
@@ -76,6 +76,10 @@ _CLI_OPTS = [
cfg.BoolOpt('keep', default=False,
deprecated_group='kolla-build',
help='Keep failed intermediate containers'),
+ cfg.BoolOpt('list-dependencies', short='l',
+ help='Show image dependencies (filtering supported)'),
+ cfg.BoolOpt('list-images',
+ help='Show all available images'),
cfg.StrOpt('namespace', short='n', default='kollaglue',
deprecated_group='kolla-build',
help='The Docker namespace name'),