From 599f97b63e66985e92e4c410b4252cc7fa03e30c Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 16 Mar 2006 21:55:04 +0000 Subject: Documentation updates Add bundle and client support to groups-to-dot.py git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1801 ce84e21b-d406-0410-9b95-82705330c041 --- tools/groups-to-dot.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'tools/groups-to-dot.py') diff --git a/tools/groups-to-dot.py b/tools/groups-to-dot.py index 91230c5dd..164d5599d 100755 --- a/tools/groups-to-dot.py +++ b/tools/groups-to-dot.py @@ -10,24 +10,48 @@ colors = ['aquamarine', 'chartreuse', 'gold', 'magenta', 'indianred1', 'limegree if __name__ == '__main__': if len(sys.argv) < 2: - print "Usage groups-to-dot.py " + print "Usage groups-to-dot.py [-h] " raise SystemExit, 1 - groups = lxml.etree.parse(sys.argv[1]).getroot() + groups = lxml.etree.parse(sys.argv[-1] + '/groups.xml').getroot() + clients= lxml.etree.parse(sys.argv[-1] + '/clients.xml').getroot() categories = {'default':'grey83'} + instances = {} for group in groups.findall('Group'): if group.get('category', False): if not categories.has_key(group.get('category')): categories[group.get('category')] = colors.pop() print "digraph groups {" + if '-h' in sys.argv: + print '\trankdir="LR";' + for client in clients.findall('Client'): + if instances.has_key(client.get('profile')): + instances[client.get('profile')].append(client.get('name')) + else: + instances[client.get('profile')] = [client.get('name')] + for profile, clist in instances.iteritems(): + clist.sort() + print '''\t"%s-instances" [ label="%s", shape="record" ];''' % (profile, '|'.join(clist)) + print '''\t"%s-instances" -> "%s";''' % (profile, profile) + + if '-b' in sys.argv: + bundles = [] + [bundles.append(bund.get('name')) for bund in groups.findall('.//Bundle') + if bund.get('name') not in bundles] + bundles.sort() + for bundle in bundles: + print '''\t"%s" [ shape="rect"];''' % (bundle) + for group in groups.findall('Group'): color = categories[group.get('category', 'default')] if group.get('profile', 'false') == 'true': - print '\tnode [style="filled,bold", fillcolor=%s];' % (color) + print '\t"%s" [style="filled,bold", fillcolor=%s];' % (group.get('name'), color) else: - print '\tnode [style="filled", fillcolor=%s];' % (color) - print '\t"%s";' % (group.get('name')) - + print '\t"%s" [style="filled", fillcolor=%s];' % (group.get('name'), color) + if '-b' in sys.argv: + for bundle in group.findall('Bundle'): + print '\t"%s" -> "%s";' % (group.get('name'), bundle.get('name')) + for group in groups.findall('Group'): for parent in group.findall('Group'): print '\t"%s" -> "%s" ;' % (group.get('name'), parent.get('name')) -- cgit v1.2.3-1-g7c22