3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` ;;
19 . "$dir0/ovs-lib" || exit 1
21 for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
33 pidfile_is_running () {
35 test -e "$pidfile" && pid=`cat "$pidfile"` && pid_exists "$pid"
39 if pidfile_is_running $DB_NB_PID; then
40 ovs-appctl -t $rundir/ovnnb_db.ctl exit
43 if pidfile_is_running $DB_SB_PID; then
44 ovs-appctl -t $rundir/ovnsb_db.ctl exit
49 # Check and eventually start ovsdb-server for Northbound DB
50 if ! pidfile_is_running $DB_NB_PID; then
51 upgrade_db "$DB_NB_FILE" "$DB_NB_SCHEMA" 1>/dev/null 2>/dev/null
55 set "$@" --detach $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT --pidfile=$DB_NB_PID --unixctl=ovnnb_db.ctl
60 # Check and eventually start ovsdb-server for Southbound DB
61 if ! pidfile_is_running $DB_SB_PID; then
62 upgrade_db "$DB_SB_FILE" "$DB_SB_SCHEMA" 1>/dev/null 2>/dev/null
66 set "$@" --detach $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT --pidfile=$DB_SB_PID --unixctl=ovnsb_db.ctl
72 if ! pidfile_is_running $DB_NB_PID; then
73 log_success_msg "OVN Northbound DB is not running"
75 log_success_msg "OVN Northbound DB is running"
78 if ! pidfile_is_running $DB_SB_PID; then
79 log_success_msg "OVN Southbound DB is not running"
81 log_success_msg "OVN Southbound DB is running"
86 if test X"$OVN_MANAGE_OVSDB" = Xyes; then
90 if ! pidfile_is_running $DB_NB_PID; then
91 log_failure_msg "OVN Northbound DB is not running"
94 if ! pidfile_is_running $DB_SB_PID; then
95 log_failure_msg "OVN Southbound DB is not running"
99 if daemon_is_running ovn-northd; then
100 log_success_msg "ovn-northd is already running"
103 set "$@" $OVN_NORTHD_LOG --ovnnb-db=unix:$DB_NB_SOCK --ovnsb-db=unix:$DB_SB_SOCK
104 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@"
108 start_controller () {
109 set ovn-controller "unix:$DB_SOCK"
110 set "$@" -vconsole:emer -vsyslog:err -vfile:info
111 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"
119 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-northd
121 if test X"$OVN_MANAGE_OVSDB" = Xyes; then
127 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-controller
139 restart_controller () {
156 DB_NB_SOCK=$rundir/ovnnb_db.sock
157 DB_NB_PID=$rundir/ovnnb_db.pid
158 DB_NB_FILE=$dbdir/ovnnb_db.db
161 DB_SB_SOCK=$rundir/ovnsb_db.sock
162 DB_SB_PID=$rundir/ovnsb_db.pid
163 DB_SB_FILE=$dbdir/ovnsb_db.db
166 DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
167 DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
169 DB_SOCK=$rundir/db.sock
170 DB_CONF_FILE=$dbdir/conf.db
172 OVN_NORTHD_PRIORITY=-10
174 OVN_CONTROLLER_PRIORITY=-10
175 OVN_CONTROLLER_WRAPPER=
177 OVS_RUNDIR=${OVS_RUNDIR:-${rundir}}
178 OVN_RUNDIR=${OVN_RUNDIR:-${OVS_RUNDIR}}
180 OVN_CONTROLLER_LOG="-vconsole:emer -vsyslog:err -vfile:info"
181 OVN_NORTHD_LOG="-vconsole:emer -vsyslog:err -vfile:info"
182 OVN_NB_LOG="-vconsole:off"
183 OVN_SB_LOG="-vconsole:off"
184 OVN_NB_LOGFILE="$logdir/ovsdb-server-nb.log"
185 OVN_SB_LOGFILE="$logdir/ovsdb-server-sb.log"
189 var=`echo "$option" | tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
190 eval set=\${$var+yes}
191 eval old_value=\$$var
192 if test X$set = X || \
193 (test $type = bool && \
194 test X"$old_value" != Xno && test X"$old_value" != Xyes); then
195 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
204 $0: controls Open Virtual Network daemons
205 usage: $0 [OPTIONS] COMMAND
207 This program is intended to be invoked internally by Open Virtual Network
208 startup scripts. System administrators should not normally invoke it directly.
211 start_northd start ovn-northd
212 start_ovsdb start ovn related ovsdb-server processes
213 start_controller start ovn-controller
214 stop_northd stop ovn-northd
215 stop_ovsdb stop ovn related ovsdb-server processes
216 stop_controller stop ovn-controller
217 restart_northd restart ovn-northd
218 restart_ovsdb restart ovn related ovsdb-server processes
219 restart_controller restart ovn-controller
222 --ovn-northd-priority=NICE set ovn-northd's niceness (default: $OVN_NORTHD_PRIORITY)
223 --ovn-northd-wrapper=WRAPPER run with a wrapper like valgrind for debugging
224 --ovn-controller-priority=NICE set ovn-northd's niceness (default: $OVN_CONTROLLER_PRIORITY)
225 --ovn-controller-wrapper=WRAPPER run with a wrapper like valgrind for debugging
226 --ovn-manage-ovsdb=yes|no Whether or not the OVN databases should be
227 automatically started and stopped along
228 with ovn-northd. The default is "yes". If
229 this is set to "no", the "start_ovsdb" and
230 "stop_ovsdb" commands must be used to start
231 and stop the OVN databases.
232 --ovn-controller-log=STRING ovn controller process logging params (default: $OVN_CONTROLLER_LOG)
233 --ovn-northd-log=STRING ovn northd process logging params (default: $OVN_NORTHD_LOG)
234 --ovn-nb-log=STRING ovn NB ovsdb-server processes logging params (default: $OVN_NB_LOG)
235 --ovn-sb-log=STRING ovn SB ovsdb-server processes logging params (default: $OVN_SB_LOG)
236 -h, --help display this help message
238 File location options:
239 --db-sock=SOCKET JSON-RPC socket name (default: $DB_SOCK)
240 --db-nb-file=FILE OVN_Northbound db file (default: $DB_NB_FILE)
241 --db-sb-file=FILE OVN_Southbound db file (default: $DB_SB_FILE)
242 --db-nb-schema=FILE OVN_Northbound db file (default: $DB_NB_SCHEMA)
243 --db-sb-schema=FILE OVN_Southbound db file (default: $DB_SB_SCHEMA)
244 --db-nb-port=PORT OVN Northbound db ptcp port (default: $DB_NB_PORT)
245 --db-sb-port=PORT OVN Southbound db ptcp port (default: $DB_SB_PORT)
246 --ovn-nb-logfile=FILE OVN Northbound log file (default: $OVN_NB_LOGFILE)
247 --ovn-sb-logfile=FILE OVN Southbound log file (default: $OVN_SB_LOGFILE)
249 Default directories with "configure" option and environment variable override:
250 logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
251 pidfiles and sockets: /usr/local/var/run/openvswitch (--with-rundir, OVS_RUNDIR)
252 ovn-nb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
253 ovn-sb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
254 system configuration: /usr/local/etc (--sysconfdir, OVS_SYSCONFDIR)
255 data files: /usr/local/share/openvswitch (--pkgdatadir, OVS_PKGDATADIR)
256 user binaries: /usr/local/bin (--bindir, OVS_BINDIR)
257 system binaries: /usr/local/sbin (--sbindir, OVS_SBINDIR)
270 option=`expr X"$arg" : 'X--\([^=]*\)'`
271 value=`expr X"$arg" : 'X[^=]*=\(.*\)'`
276 option=`expr X"$arg" : 'X--no-\(.*\)'`
282 option=`expr X"$arg" : 'X--\(.*\)'`
288 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
292 if test X"$command" = X; then
295 echo >&2 "$0: exactly one non-option argument required (use --help for help)"
330 daemon_status ovn-northd || exit 1
336 daemon_status ovn-controller || exit 1
342 echo >&2 "$0: preheating ovn to 350 degrees F."
346 echo >&2 "$0: missing command name (use --help for help)"
350 echo >&2 "$0: unknown command \"$command\" (use --help for help)"