Trucs non commités : bcfg2
This commit is contained in:
parent
b29face316
commit
aac0cd8357
3 changed files with 111 additions and 0 deletions
51
bcfg2/bcfg2-graph.py
Executable file
51
bcfg2/bcfg2-graph.py
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function
|
||||
import xml.dom.minidom
|
||||
|
||||
tmp_file = '/tmp/graph.gv'
|
||||
|
||||
out = file(tmp_file,'w')
|
||||
|
||||
from sh import neato
|
||||
from sh import date
|
||||
|
||||
groups = xml.dom.minidom.parse(file('/var/lib/bcfg2/Metadata/groups.xml','r')).documentElement
|
||||
|
||||
print("""digraph G {
|
||||
edge [len=4.50, ratio=fill]
|
||||
""", file=out)
|
||||
|
||||
def childGroups(parent):
|
||||
return [ x for x in parent.childNodes if \
|
||||
x.nodeType == x.ELEMENT_NODE and x.tagName == u'Group']
|
||||
|
||||
# Les clients
|
||||
print("""
|
||||
subgraph cluster_1 {
|
||||
node [style=filled];
|
||||
""", file=out)
|
||||
for elem in childGroups(groups):
|
||||
if elem.hasAttribute('profile'):
|
||||
print('"%s";' % elem.getAttribute('name'), file=out)
|
||||
print("""
|
||||
label = "process #2";
|
||||
color=blue
|
||||
}
|
||||
""", file=out)
|
||||
# Le reste
|
||||
|
||||
for elem in childGroups(groups):
|
||||
print('"%s" -> {%s};' % \
|
||||
( elem.getAttribute('name'),
|
||||
" ".join( [ '"%s"' % x.getAttribute('name')
|
||||
for x in childGroups(elem) ]),
|
||||
), file=out)
|
||||
|
||||
print("""
|
||||
label = "\\n\\nBCFG2 Groups\\nLes Nounous\\n%s";
|
||||
}""" % str(date())[0:-1], file=out)
|
||||
|
||||
out.close()
|
||||
|
||||
neato("-Tsvg", tmp_file, "-o", "/usr/scripts/var/doc/bcfg2/groups.svg")
|
Loading…
Add table
Add a link
Reference in a new issue