[pve-devel] [PATCH 1/4] add framework to generate network graphs using graphviz

Dietmar Maurer dietmar at proxmox.com
Tue Aug 14 13:56:00 CEST 2018


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 images/Makefile                 | 12 +++++
 images/pve_network_templates.tt | 56 +++++++++++++++++++++++
 images/simple-clos-network.tt   | 98 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 images/Makefile
 create mode 100644 images/pve_network_templates.tt
 create mode 100644 images/simple-clos-network.tt

diff --git a/images/Makefile b/images/Makefile
new file mode 100644
index 0000000..4917eba
--- /dev/null
+++ b/images/Makefile
@@ -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 -r *.tmp.dot
diff --git a/images/pve_network_templates.tt b/images/pve_network_templates.tt
new file mode 100644
index 0000000..bf2ef89
--- /dev/null
+++ b/images/pve_network_templates.tt
@@ -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
index 0000000..5b551bc
--- /dev/null
+++ b/images/simple-clos-network.tt
@@ -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
+}
-- 
2.11.0




More information about the pve-devel mailing list