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
This commit is contained in:
parent
233158f754
commit
696f0b9a06
@ -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)
|
||||
|
@ -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'),
|
||||
|
Loading…
Reference in New Issue
Block a user