add framework to generate network graphs using graphviz

This commit is contained in:
Dietmar Maurer 2018-08-13 10:45:25 +02:00
parent 76b6e85702
commit bef01a6104
3 changed files with 166 additions and 0 deletions

12
images/Makefile Normal file
View File

@ -0,0 +1,12 @@
all:
%.tmp.dot: %.tt pve_network_templates.tt
tpage $*.tt >$*.tmp.dot
%.svg: %.tmp.dot
dot $*.tmp.dot -T svg -o $*.svg
clean:
rm -f *.tmp.dot

View File

@ -0,0 +1,56 @@
[% BLOCK switch_ports %]
<table border='0' cellspacing='0' cellpadding='0' cellborder='0'>
<tr>
<td fixedsize='TRUE' width='15' height='10'></td>
[% FOREACH p IN draw_ports %]
<td port='[% p %]' fixedsize='TRUE' width='[% p.length*5+5 %]' height='10' BGCOLOR="#666666"><font face='monospace' point-size='8' color='white'>[% p %]</font></td>
<td fixedsize='TRUE' width='1' height='10'></td>
[% END %]
<td fixedsize='TRUE' width='15' height='10'></td>
</tr>
</table>
[% END %]
[% MACRO switch BLOCK %]
[% id %] [
shape=plaintext
label=<
<table border='0' cellspacing='0' cellpadding='0' cellborder='0'>
[% IF top_ports %]
<tr><td>[% PROCESS switch_ports draw_ports=top_ports %]</td></tr>
[% END %]
<tr><td><table color='green' BGCOLOR="lightgreen" border='2' cellspacing='2' cellpadding='0' cellborder='0' style='rounded'>
<tr><td width='10'></td><td>[% title %]</td><td width='10'></td></tr>
[% IF subtitle %]
<tr><td width='10'></td><td><font face='monospace' point-size='12'>[% subtitle %]</font></td><td width='10'></td></tr>
[% END %]
</table></td></tr>
[% IF ports %]
<tr><td>[% PROCESS switch_ports draw_ports=ports %]</td></tr>
[% END %]
</table>>
]
[% END %]
[% MACRO server BLOCK %]
[% id %] [
shape=plaintext
label=<
<table border='0' cellspacing='0' cellpadding='0' cellborder='0'>
[% IF top_ports %]
<tr><td>[% PROCESS switch_ports draw_ports=top_ports %]</td></tr>
[% END %]
<tr><td><table color='#666666' BGCOLOR="#888888" border='2' cellspacing='2' cellpadding='0' cellborder='0'>
<tr><td><font color='white'>[% title %]</font></td></tr>
[% IF subtitle %]
<tr><td><font face='monospace' color='white' point-size='12'>[% subtitle %]</font></td></tr>
[% END %]
</table></td></tr>
[% IF ports %]
<tr><td>[% PROCESS switch_ports draw_ports=ports %]</td></tr>
[% END %]
</table>>
]
[% END %]

View File

@ -0,0 +1,98 @@
[% PROCESS pve_network_templates.tt %]
graph clos_network {
splines=line
node [shape=record];
edge [];
[% switch(
id="spine01",
title="Spine01 <font color='orange'>65021</font>",
subtitle="10.0.0.21/32",
top_ports='',
ports=[1,2,3,4])
%]
[% switch(
id="spine02"
title="Spine02 <font color='orange'>65022</font>"
subtitle="10.0.0.22/32"
top_ports=''
ports=[1,2,3,4])
%]
[% switch(
id="leaf01"
title="Leaf01 <font color='orange'>65011</font>"
subtitle="10.0.0.11/32"
top_ports=[51,52]
ports=[1])
%]
[% switch(
id="leaf02"
title="Leaf02 <font color='orange'>65012</font>"
subtitle="10.0.0.12/32"
top_ports=[51,52]
ports=[1])
%]
[% switch(
id="leaf03"
title="Leaf03 <font color='orange'>65013</font>"
subtitle="10.0.0.13/32"
top_ports=[51,52]
ports=[1])
%]
[% switch(
id="leaf04"
title="Leaf04 <font color='orange'>65014</font>"
subtitle="10.0.0.14/32"
top_ports=[51,52]
ports=[1])
%]
spine01:1 -- leaf01:51
spine01:2 -- leaf02:51
spine01:3 -- leaf03:51
spine01:4 -- leaf04:51
spine02:1 -- leaf01:52
spine02:2 -- leaf02:52
spine02:3 -- leaf03:52
spine02:4 -- leaf04:52
[% server(
id="server01"
title="server01"
top_ports='eth1'
ports='')
%]
[% server(
id="server02"
title="server02"
top_ports='eth1'
ports='')
%]
[% server(
id="server03"
title="server03"
top_ports='eth1'
ports='')
%]
[% server(
id="server04"
title="server04"
top_ports='eth1'
ports='')
%]
leaf01:1 -- server01:eth1
leaf02:1 -- server02:eth1
leaf03:1 -- server03:eth1
leaf04:1 -- server04:eth1
}