]> git.proxmox.com Git - pve-docs.git/commitdiff
add framework to generate network graphs using graphviz
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 13 Aug 2018 08:45:25 +0000 (10:45 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 16 Aug 2018 08:13:16 +0000 (10:13 +0200)
images/Makefile [new file with mode: 0644]
images/pve_network_templates.tt [new file with mode: 0644]
images/simple-clos-network.tt [new file with mode: 0644]

diff --git a/images/Makefile b/images/Makefile
new file mode 100644 (file)
index 0000000..f6e210e
--- /dev/null
@@ -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
diff --git a/images/pve_network_templates.tt b/images/pve_network_templates.tt
new file mode 100644 (file)
index 0000000..bf2ef89
--- /dev/null
@@ -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 %]
diff --git a/images/simple-clos-network.tt b/images/simple-clos-network.tt
new file mode 100644 (file)
index 0000000..5b551bc
--- /dev/null
@@ -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
+}