Skip to content

Commit

Permalink
ovs-ctl: Allow selective start for db and switch
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
apconole authored and blp committed Mar 25, 2016
1 parent 2eb5dee commit 7fc28c5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 14 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 26 additions & 6 deletions utilities/ovs-ctl.8
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ 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\-ovsdb\-server\fR command
option is given.
.
.IP 4.
Initializes a few values inside the database.
Expand All @@ -96,7 +97,8 @@ 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\-ovs\-vswitchd\fR
command option is given:
.IP 7.
Starts \fBovs\-vswitchd\fR.
.
Expand Down Expand Up @@ -238,7 +240,9 @@ taken as relative to \fIdbdir\fR.
.
.PP
The \fBstop\fR command does not unload the Open vSwitch kernel
modules.
modules. It can take the same \fB\-\-no\-ovsdb\-server\fR and
\fB\-\-no\-ovs\-vswitchd\fR options as that of the \fBstart\fR
command.
.
.PP
This command does nothing and finishes successfully if the OVS daemons
Expand Down Expand Up @@ -314,7 +318,8 @@ particular distribution and installation.)
.
.PP
\fBforce\-kmod\-reload\fR internally stops and starts OVS, so it
accepts all of the options accepted by the \fBstart\fR command.
accepts all of the options accepted by the \fBstart\fR command except
for the \fB\-\-no\-ovs\-vswitchd\fR option.
.
.SH "The ``load\-kmod'' command"
.
Expand Down Expand Up @@ -377,8 +382,23 @@ Prints a usage message and exits successfully.
.
.SH "OPTIONS"
.PP
In addition to the options listed for each command above, this option
controls the behavior of several of \fBovs\-ctl\fR's commands.
In addition to the options listed for each command above, these options
control the behavior of several of \fBovs\-ctl\fR's commands.
.
.PP
By default, \fBovs\-ctl\fR will control the \fBovsdb\-server\fR, and
the \fBovs\-vswitchd\fR daemons. The following options restrict that control
to exclude one or the other:
.
.IP "\fB\-\-no\-ovsdb-server\fR"
Specifies that the \fBovs\-ctl\fR commands \fBstart\fR, \fBstop\fR, and
\fBrestart\fR should not modify the running status of \fBovsdb\-server\fR.
.
.IP "\fB\-\-no\-ovs\-vswitchd\fR"
Specifies that the \fBovs\-ctl\fR commands \fBstart\fR, \fBstop\fR, and
\fBrestart\fR should not modify the running status of \fBovs\-vswitchd\fR.
It is an error to include this option with the \fBforce\-reload\-kmod\fR
command.
.
.SH "EXIT STATUS"
.
Expand Down
46 changes: 38 additions & 8 deletions utilities/ovs-ctl.in
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ del_transient_ports () {
done
}

start_ovsdb () {
do_start_ovsdb () {
check_force_cores

if daemon_is_running ovsdb-server; then
Expand Down Expand Up @@ -185,6 +185,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
Expand All @@ -198,7 +204,7 @@ add_managers () {
db:Open_vSwitch,Open_vSwitch,manager_options
}

start_forwarding () {
do_start_forwarding () {
check_force_cores

insert_mod_if_required || return 1
Expand All @@ -225,16 +231,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
}

## ----------------- ##
Expand Down Expand Up @@ -284,12 +300,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 () {
Expand Down Expand Up @@ -318,6 +338,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

Expand Down Expand Up @@ -377,7 +403,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
Expand Down Expand Up @@ -459,6 +487,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=
Expand Down

0 comments on commit 7fc28c5

Please sign in to comment.