Gen the image dependency in the Graphviz dot format
By using ./tools/build.py --save-dependency a.dot to gen the Graphviz dot dependency file. Later, you can use the `dot` to draw the picture. dot -Tjpg -o a.jpg a.dot Implements: blueprint images-dependency-tree Depends-On: I8e07a1b69fab5f1c587470bfd2104aaba93f0050 Change-Id: If00f4f3fb9d0b10a07ab2abb7ffb1cd9d64902f2
This commit is contained in:
parent
8123dbdc62
commit
f2bded7f94
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import errno
|
import errno
|
||||||
|
import graphviz
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -558,6 +559,19 @@ class KollaWorker(object):
|
||||||
|
|
||||||
self.images.append(image)
|
self.images.append(image)
|
||||||
|
|
||||||
|
def save_dependency(self, to_file):
|
||||||
|
dot = graphviz.Digraph(comment='Docker Images Dependency')
|
||||||
|
dot.body.extend(['rankdir=LR'])
|
||||||
|
for image in self.images:
|
||||||
|
if image['status'] not in ['matched']:
|
||||||
|
continue
|
||||||
|
dot.node(image['name'])
|
||||||
|
if image['parent'] is not None:
|
||||||
|
dot.edge(image['parent']['name'], image['name'])
|
||||||
|
|
||||||
|
with open(to_file, 'w') as f:
|
||||||
|
f.write(dot.source)
|
||||||
|
|
||||||
def find_parents(self):
|
def find_parents(self):
|
||||||
"""Associate all images with parents and children"""
|
"""Associate all images with parents and children"""
|
||||||
sort_images = dict()
|
sort_images = dict()
|
||||||
|
@ -614,6 +628,12 @@ def main():
|
||||||
queue = kolla.build_queue()
|
queue = kolla.build_queue()
|
||||||
push_queue = six.moves.queue.Queue()
|
push_queue = six.moves.queue.Queue()
|
||||||
|
|
||||||
|
if conf.save_dependency:
|
||||||
|
kolla.save_dependency(conf.save_dependency)
|
||||||
|
LOG.info('Docker images dependency is saved in %s',
|
||||||
|
conf.save_dependency)
|
||||||
|
return
|
||||||
|
|
||||||
for x in range(conf.threads):
|
for x in range(conf.threads):
|
||||||
worker = WorkerThread(queue, push_queue, conf)
|
worker = WorkerThread(queue, push_queue, conf)
|
||||||
worker.setDaemon(True)
|
worker.setDaemon(True)
|
||||||
|
|
|
@ -107,6 +107,9 @@ _CLI_OPTS = [
|
||||||
cfg.StrOpt('registry', deprecated_group='kolla-build',
|
cfg.StrOpt('registry', deprecated_group='kolla-build',
|
||||||
help=('The docker registry host. The default registry host'
|
help=('The docker registry host. The default registry host'
|
||||||
' is Docker Hub')),
|
' is Docker Hub')),
|
||||||
|
cfg.StrOpt('save-dependency',
|
||||||
|
help=('Path to the file to store the docker image'
|
||||||
|
' dependency in Graphviz dot format')),
|
||||||
cfg.StrOpt('type', short='t', default='binary',
|
cfg.StrOpt('type', short='t', default='binary',
|
||||||
choices=INSTALL_TYPE_CHOICES,
|
choices=INSTALL_TYPE_CHOICES,
|
||||||
dest='install_type', deprecated_group='kolla-build',
|
dest='install_type', deprecated_group='kolla-build',
|
||||||
|
|
|
@ -8,3 +8,4 @@ gitdb>=0.6.4 # BSD License (3 clause)
|
||||||
GitPython>=1.0.1 # BSD License (3 clause)
|
GitPython>=1.0.1 # BSD License (3 clause)
|
||||||
six>=1.9.0
|
six>=1.9.0
|
||||||
oslo.config>=2.7.0 # Apache-2.0
|
oslo.config>=2.7.0 # Apache-2.0
|
||||||
|
graphviz>=0.4.0 # MIT License
|
||||||
|
|
Loading…
Reference in New Issue