[ovs-dev] [PATCH] docs: Only regenerate vswitch.pic when the schema really changes.

Ben Pfaff blp at nicira.com
Thu Dec 2 01:08:16 UTC 2010


Until now, vswitch.pic has been rebuilt whenever the schema changed.  This
is OK when the E-R diagram would really change, but many changes to the
schema don't change the E-R diagram, and it surprises people when
vswitch.pic changes in such a situation.  This commit fixes the problem.

Requested-by: Justin Pettit <jpettit at nicira.com>
---
 configure.ac         |    2 +-
 m4/openvswitch.m4    |   15 +-------
 vswitchd/automake.mk |   37 ++++++++++++++-----
 vswitchd/vswitch.gv  |   94 ++++++++++++++++++++++++++++++++++++++++++++++++++
 vswitchd/vswitch.pic |    1 +
 5 files changed, 124 insertions(+), 25 deletions(-)
 create mode 100644 vswitchd/vswitch.gv

diff --git a/configure.ac b/configure.ac
index 8a5dc5c..adeb956 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,7 +50,7 @@ OVS_CHECK_LOGDIR
 OVS_CHECK_PYTHON
 OVS_CHECK_PYUIC4
 OVS_CHECK_OVSDBMONITOR
-OVS_CHECK_ER_DIAGRAMS
+OVS_CHECK_DOT
 OVS_CHECK_IF_PACKET
 OVS_CHECK_STRTOK_R
 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec],
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 6dda350..077c29b 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -202,21 +202,8 @@ AC_DEFUN([OVS_CHECK_DOT],
        ovs_cv_dot=yes
      else
        ovs_cv_dot=no
-     fi])])
-
-dnl Check whether to build E-R diagrams.
-AC_DEFUN([OVS_CHECK_ER_DIAGRAMS],
-  [AC_REQUIRE([OVS_CHECK_DOT])
-   AC_REQUIRE([OVS_CHECK_PYTHON])
-   AC_CACHE_CHECK(
-    [whether to build E-R diagrams for database],
-    [ovs_cv_er_diagrams],
-    [if test $ovs_cv_dot != no && test $ovs_cv_python != no; then
-       ovs_cv_er_diagrams=yes
-     else
-       ovs_cv_er_diagrams=no
      fi])
-   AM_CONDITIONAL([BUILD_ER_DIAGRAMS], [test $ovs_cv_er_diagrams = yes])])
+   AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])])
 
 dnl Checks for pyuic4.
 AC_DEFUN([OVS_CHECK_PYUIC4],
diff --git a/vswitchd/automake.mk b/vswitchd/automake.mk
index 6ef7763..7e01ac7 100644
--- a/vswitchd/automake.mk
+++ b/vswitchd/automake.mk
@@ -49,19 +49,36 @@ vswitchd/vswitch-idl.ovsidl: $(VSWITCH_IDL_FILES)
 	mv $@.tmp $@
 
 # vswitch E-R diagram
-if BUILD_ER_DIAGRAMS
-$(srcdir)/vswitchd/vswitch.pic: ovsdb/ovsdb-dot.in ovsdb/dot2pic \
-                                vswitchd/vswitch.ovsschema
-	$(OVSDB_DOT) $(srcdir)/vswitchd/vswitch.ovsschema \
-		| dot -T plain \
-		| $(srcdir)/ovsdb/dot2pic \
-		> $@.tmp
-	mv $@.tmp $@
+#
+# There are two complications here.  First, if "python" or "dot" is not
+# available, then we have to just use the existing diagram.  Second, different
+# "dot" versions produce slightly different output for the same input, but we
+# don't want to gratuitously change vswitch.pic if someone tweaks the schema
+# in some minor way that doesn't affect the table structure.  To avoid that
+# we store the md5sum of vswitch.gv in vswitch.pic and only regenerate
+# vswitch.pic if vswitch.gv actually changes.
+$(srcdir)/vswitchd/vswitch.gv: ovsdb/ovsdb-dot.in vswitchd/vswitch.ovsschema
+if HAVE_PYTHON
+	$(OVSDB_DOT) $(srcdir)/vswitchd/vswitch.ovsschema > $@
+else
+	touch $@
+endif
+$(srcdir)/vswitchd/vswitch.pic: $(srcdir)/vswitchd/vswitch.gv ovsdb/dot2pic
+if HAVE_DOT
+	sum=`md5sum $(srcdir)/vswitchd/vswitch.gv | awk '{print $$1}'`;	\
+	if grep $$sum $@ >/dev/null 2>&1; then				\
+	  echo "vswitch.gv unchanged, not regenerating vswitch.pic";	\
+	  touch $@;							\
+	else								\
+	  echo "regenerating vswitch.pic";				\
+	  (echo ".\\\" Generated from vswitch.gv with md5sum $$sum";	\
+	   dot -T plain < $(srcdir)/vswitchd/vswitch.gv			\
+	    | $(srcdir)/ovsdb/dot2pic) > $@;				\
+	fi
 else
-$(srcdir)/vswitchd/vswitch.pic: ovsdb/ovsdb-dot.in vswitchd/vswitch.ovsschema
 	touch $@
 endif
-EXTRA_DIST += vswitchd/vswitch.pic
+EXTRA_DIST += vswitchd/vswitch.gv vswitchd/vswitch.pic
 
 # vswitch schema documentation
 EXTRA_DIST += vswitchd/vswitch.xml
diff --git a/vswitchd/vswitch.gv b/vswitchd/vswitch.gv
new file mode 100644
index 0000000..1ab56e6
--- /dev/null
+++ b/vswitchd/vswitch.gv
@@ -0,0 +1,94 @@
+digraph Open_vSwitch {
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Bridge;
+	Bridge -> sFlow [label="sflow"];
+	Bridge -> Mirror [label="mirrors"];
+	Bridge -> Port [label="ports"];
+	Bridge -> Controller [label="controller"];
+	Bridge -> NetFlow [label="netflow"];
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	QoS;
+	QoS -> Queue [label="queues value"];
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Monitor;
+	Monitor -> Maintenance_Point [label="remote_mps"];
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	sFlow;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Open_vSwitch;
+	Open_vSwitch -> Bridge [label="bridges"];
+	Open_vSwitch -> Capability [label="capabilities value"];
+	Open_vSwitch -> SSL [label="ssl"];
+	Open_vSwitch -> Manager [label="manager_options"];
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Controller;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Queue;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	SSL;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Manager;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Capability;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Mirror;
+	Mirror -> Port [constraint=false, label="select_src_port"];
+	Mirror -> Port [constraint=false, label="output_port"];
+	Mirror -> Port [constraint=false, label="select_dst_port"];
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Interface;
+	Interface -> Monitor [label="monitor"];
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	NetFlow;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Maintenance_Point;
+	size="6.5,4";
+	margin="0";
+	node [shape=box];
+	edge [dir=none, arrowhead=none, arrowtail=none];
+	Port;
+	Port -> QoS [label="qos"];
+	Port -> Interface [label="interfaces"];
+}
diff --git a/vswitchd/vswitch.pic b/vswitchd/vswitch.pic
index 507a89b..698bb1d 100644
--- a/vswitchd/vswitch.pic
+++ b/vswitchd/vswitch.pic
@@ -1,3 +1,4 @@
+.\" Generated from vswitch.gv with md5sum 45fb752f21dcad52f81c0be9c997333a
 .PS
 linethick = 1;
 box at 2.320997253,3.1110975 wid 0.5020540998 height 0.296295 "Bridge"
-- 
1.7.1





More information about the dev mailing list