[ovs-dev,v3,1/2] ovs-ctl: Add option to delete transient ports only on boot.

Message ID 50d80072abf613afacb816c8bffa003d7491044d.1502466863.git.tredaelli@redhat.com
State New
Headers show

Commit Message

Timothy M. Redaelli Aug. 11, 2017, 4:06 p.m.
The first time after boot, when openvswitch is started by using
--delete-transient-ports-on-boot ovs-ctl option, all transient ports will be
removed.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 utilities/ovs-ctl.8  | 13 ++++++++++++-
 utilities/ovs-ctl.in |  6 ++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

Patch

diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
index 84fa33fff..a15d72992 100644
--- a/utilities/ovs-ctl.8
+++ b/utilities/ovs-ctl.8
@@ -95,11 +95,16 @@  bridges from the database.
 If the \fB\-\-delete\-transient\-ports\fR option was used, deletes all ports
 that have \fBother_config:transient\fR set to true.
 .
+.IP 7.
+If the \fB\-\-delete\-transient\-ports\-on\-boot\fR option was used, deletes
+all ports that have \fBother_config:transient\fR set to true, but only the
+first time after a boot.
+.
 .PP
 The \fBstart\fR command skips the following step if
 \fBovs\-vswitchd\fR is already running, or if the \fB\-\-no\-ovs\-vswitchd\fR
 command option is given:
-.IP 7.
+.IP 8.
 Starts \fBovs\-vswitchd\fR.
 .
 .SS "Options"
@@ -159,6 +164,12 @@  Deletes all ports that have the other_config:transient value set to true. This
 is important on certain environments where some ports are going to be recreated
 after reboot, but other ports need to be persisted in the database.
 .
+.IP "\fB\-\-delete\-transient\-ports\-on\-boot\fR"
+The first time after a boot, deletes all ports that have the
+other_config:transient value set to true. This is important on certain
+environments where some ports are going to be recreated after reboot,
+but other ports need to be persisted in the database.
+.
 .IP "\fB\-\-ovs\-user=user[:group]\fR"
 Ordinarily Open vSwitch daemons are started as the user invoking the ovs-ctl
 command.  Some system administrators would prefer to have the various daemons
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index dc1d02c9c..6fd72f759 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -189,6 +189,11 @@  do_start_ovsdb () {
         if test X"$DELETE_TRANSIENT_PORTS" = Xyes; then
             del_transient_ports
         fi
+        if test X"$DELETE_TRANSIENT_PORTS_ON_BOOT" = Xyes && \
+            ! test -f "$rundir/deleted_transient_ports"; then
+            del_transient_ports
+            : > "$rundir/deleted_transient_ports"
+        fi
     fi
 }
 
@@ -500,6 +505,7 @@  set_defaults () {
 
     DELETE_BRIDGES=no
     DELETE_TRANSIENT_PORTS=no
+    DELETE_TRANSIENT_PORTS_ON_BOOT=no
 
     DAEMON_CWD=/
     FORCE_COREFILES=yes