diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-03-07 19:46:26 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-03-07 19:46:26 +0000 |
commit | 76a1c6f2d0e47c71086fb9e338467fbbde7cca94 (patch) | |
tree | 249a8729d4d80c83fe4b66cf6dc29c89141ac43f | |
parent | 63c9efaa630e8e3aace3d1e85de3e8609dfb1bfd (diff) | |
download | bcfg2-76a1c6f2d0e47c71086fb9e338467fbbde7cca94.tar.gz bcfg2-76a1c6f2d0e47c71086fb9e338467fbbde7cca94.tar.bz2 bcfg2-76a1c6f2d0e47c71086fb9e338467fbbde7cca94.zip |
Add new group diagram tool
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1796 ce84e21b-d406-0410-9b95-82705330c041
-rwxr-xr-x | tools/groups-to-dot.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/groups-to-dot.py b/tools/groups-to-dot.py new file mode 100755 index 000000000..5145fa4ff --- /dev/null +++ b/tools/groups-to-dot.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +'''This script generates graphviz diagrams using bcfg2 metadata''' +__revision__ = '$Revision $' + +import lxml.etree, sys + +colors = ['aquamarine', 'chartreuse', 'gold', 'magenta', 'indianred1', 'limegreen', 'midnightblue', + 'lightblue', 'limegreen'] + +if __name__ == '__main__': + if len(sys.argv) < 2: + print "Usage groups-to-dot.py <groupsfile>" + raise SystemExit, 1 + groups = lxml.etree.parse(sys.argv[1]).getroot() + categories = {'default':'grey83'} + 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 {" + 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) + else: + print '\tnode [style="filled", fillcolor=%s];' % (color) + print '\t"%s";' % (group.get('name')) + + for group in groups.findall('Group'): + for parent in group.findall('Group'): + print '\t"%s" -> "%s" ;' % (group.get('name'), parent.get('name')) + print "}" + |