Currently, ``ovs-ctl start'' will attempt to start both the DB and
vswitchd. This is quite convenient when the database already has all of
the configuration values required, and when using a single services file
for systemd integration. The same goes for the ``ovs-ctl stop'' command.

However, there are some cases which are not easily covered. The case
where we want to set values in the database prior to starting the
forwarding path, as well as the case of supporting multiple service
files, one per daemon (which is how systemd expects services to look).

Signed-off-by: Aaron Conole <acon...@redhat.com>
---
v2:
It's possible that the way I did the save/restore flows is not the way folks
want it, so please let me know. I did only basic testing with this.
- Renamed the options to --ovs-vswitchd/--no-ovs-vswitchd
  and --ovsdb-server/--no-ovsdb-server
- Updated the force_reload_kmod to abort in case of --no-ovs-vswitchd
- Updated the flow save/restore functions to test for --ovs-vswitchd

 NEWS                 |  3 +++
 utilities/ovs-ctl.8  |  4 ++--
 utilities/ovs-ctl.in | 46 ++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/NEWS b/NEWS
index 81489ab..6083110 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,9 @@ Post-v2.5.0
      bitrot.
    - ovs-appctl:
      * New "vlog/close" command.
+   - ovs-ctl:
+     * Added the ability to selectively start the forwarding and database
+       functions (ovs-vswitchd and ovsdb-server, respectively).
    - ovsdb-server:
      * Remove max number of sessions limit, to enable connection scaling
        testing.
diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
index 6a9a544..f98dbe8 100644
--- a/utilities/ovs-ctl.8
+++ b/utilities/ovs-ctl.8
@@ -81,7 +81,7 @@ If the database does exist, but it has an obsolete version, it
 upgrades it to the latest schema.
 .
 .IP 3.
-Starts \fBovsdb-server\fR.
+Starts \fBovsdb-server\fR, unless the \fB\-\-no\-control\-ovsdb\fR argument is 
given.
 .
 .IP 4.
 Initializes a few values inside the database.
@@ -96,7 +96,7 @@ that have \fBother_config:transient\fR set to true.
 .
 .PP
 The \fBstart\fR command skips the following step if
-\fBovs\-vswitchd\fR is already running:
+\fBovs\-vswitchd\fR is already running, or if the 
\fB\-\-no\-control\-forwarding\fR:
 .IP 7.
 Starts \fBovs\-vswitchd\fR.
 .
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 7354a47..838bb8a 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -135,7 +135,7 @@ del_transient_ports () {
     done
 }
 
-start_ovsdb () {
+do_start_ovsdb () {
     check_force_cores
 
     if daemon_is_running ovsdb-server; then
@@ -183,6 +183,12 @@ start_ovsdb () {
     fi
 }
 
+start_ovsdb() {
+    if test X"$OVSDB_SERVER" = Xyes; then
+        do_start_ovsdb
+    fi
+}
+
 add_managers () {
     # Now that ovs-vswitchd has started and completed its initial
     # configuration, tell ovsdb-server to conenct to the remote managers.  We
@@ -196,7 +202,7 @@ add_managers () {
            db:Open_vSwitch,Open_vSwitch,manager_options
 }
 
-start_forwarding () {
+do_start_forwarding () {
     check_force_cores
 
     insert_mod_if_required || return 1
@@ -223,16 +229,26 @@ start_forwarding () {
     fi
 }
 
+start_forwarding () {
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        do_start_forwarding
+    fi
+}
+
 ## ---- ##
 ## stop ##
 ## ---- ##
 
 stop_ovsdb () {
-    stop_daemon ovsdb-server
+    if test X"$OVSDB_SERVER" = Xyes; then
+        stop_daemon ovsdb-server
+    fi
 }
 
 stop_forwarding () {
-    stop_daemon ovs-vswitchd
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        stop_daemon ovs-vswitchd
+    fi
 }
 
 ## ----------------- ##
@@ -282,12 +298,16 @@ save_interfaces () {
 }
 
 flow_restore_wait () {
-    ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
+    fi
 }
 
 flow_restore_complete () {
-    ovs_vsctl --if-exists remove open_vswitch . other_config \
-        flow-restore-wait="true"
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        ovs_vsctl --if-exists remove open_vswitch . other_config \
+                  flow-restore-wait="true"
+    fi
 }
 
 restore_flows () {
@@ -316,6 +336,12 @@ init_restore_scripts () {
 }
 
 force_reload_kmod () {
+
+    if test X"$OVS_VSWITCHD" != Xyes; then
+        log_failure_msg "Reloading of kmod without ovs-vswitchd is an error"
+        exit 1
+    fi
+
     ifaces=`internal_interfaces`
     action "Detected internal interfaces: $ifaces" true
 
@@ -375,7 +401,9 @@ force_reload_kmod () {
 restart () {
     if daemon_is_running ovsdb-server && daemon_is_running ovs-vswitchd; then
         init_restore_scripts
-        save_flows_if_required
+        if test X"$OVS_VSWITCHD" = Xyes; then
+            save_flows_if_required
+        fi
     fi
 
     # Restart the database first, since a large database may take a
@@ -457,6 +485,8 @@ set_defaults () {
     DAEMON_CWD=/
     FORCE_COREFILES=yes
     MLOCKALL=yes
+    OVSDB_SERVER=yes
+    OVS_VSWITCHD=yes
     OVSDB_SERVER_PRIORITY=-10
     OVS_VSWITCHD_PRIORITY=-10
     OVSDB_SERVER_WRAPPER=
-- 
2.8.0.rc2.35.gc2c5f6b.dirty

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to