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 ovnnb_db exit
43 if pidfile_is_running $DB_SB_PID; then
44 ovs-appctl -t ovnsb_db 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
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
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 () {
157 DB_NB_SOCK=$OVN_DIR/ovnnb_db.sock
158 DB_NB_PID=$OVN_DIR/ovnnb_db.pid
159 DB_NB_FILE=$OVN_DIR/ovnnb_db.db
162 DB_SB_SOCK=$OVN_DIR/ovnsb_db.sock
163 DB_SB_PID=$OVN_DIR/ovnsb_db.pid
164 DB_SB_FILE=$OVN_DIR/ovnsb_db.db
167 DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
168 DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
170 DB_SOCK=$rundir/db.sock
171 DB_CONF_FILE=$dbdir/conf.db
173 OVN_NORTHD_PRIORITY=-10
175 OVN_CONTROLLER_PRIORITY=-10
176 OVN_CONTROLLER_WRAPPER=
178 OVS_RUNDIR=${OVS_RUNDIR:-${rundir}}
179 OVN_RUNDIR=${OVN_RUNDIR:-${OVS_RUNDIR}}
181 OVN_CONTROLLER_LOG="-vconsole:emer -vsyslog:err -vfile:info"
182 OVN_NORTHD_LOG="-vconsole:emer -vsyslog:err -vfile:info"
183 OVN_NB_LOG="-vconsole:off"
184 OVN_SB_LOG="-vconsole:off"
185 OVN_NB_LOGFILE="$OVS_LOGDIR/ovsdb-server-nb.log"
186 OVN_SB_LOGFILE="$OVS_LOGDIR/ovsdb-server-sb.log"
190 var=`echo "$option" | tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
191 eval set=\${$var+yes}
192 eval old_value=\$$var
193 if test X$set = X || \
194 (test $type = bool && \
195 test X"$old_value" != Xno && test X"$old_value" != Xyes); then
196 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
205 $0: controls Open Virtual Network daemons
206 usage: $0 [OPTIONS] COMMAND
208 This program is intended to be invoked internally by Open Virtual Network
209 startup scripts. System administrators should not normally invoke it directly.
212 start_northd start ovn-northd
213 start_ovsdb start ovn related ovsdb-server processes
214 start_controller start ovn-controller
215 stop_northd stop ovn-northd
216 stop_ovsdb stop ovn related ovsdb-server processes
217 stop_controller stop ovn-controller
218 restart_northd restart ovn-northd
219 restart_ovsdb restart ovn related ovsdb-server processes
220 restart_controller restart ovn-controller
223 --ovn-northd-priority=NICE set ovn-northd's niceness (default: $OVN_NORTHD_PRIORITY)
224 --ovn-northd-wrapper=WRAPPER run with a wrapper like valgrind for debugging
225 --ovn-controller-priority=NICE set ovn-northd's niceness (default: $OVN_CONTROLLER_PRIORITY)
226 --ovn-controller-wrapper=WRAPPER run with a wrapper like valgrind for debugging
227 --ovn-manage-ovsdb=yes|no Whether or not the OVN databases should be
228 automatically started and stopped along
229 with ovn-northd. The default is "yes". If
230 this is set to "no", the "start_ovsdb" and
231 "stop_ovsdb" commands must be used to start
232 and stop the OVN databases.
233 --ovn-controller-log=STRING ovn controller process logging params (default: $OVN_CONTROLLER_LOG)
234 --ovn-northd-log=STRING ovn northd process logging params (default: $OVN_NORTHD_LOG)
235 --ovn-nb-log=STRING ovn NB ovsdb-server processes logging params (default: $OVN_NB_LOG)
236 --ovn-sb-log=STRING ovn SB ovsdb-server processes logging params (default: $OVN_SB_LOG)
237 -h, --help display this help message
239 File location options:
240 --db-sock=SOCKET JSON-RPC socket name (default: $DB_SOCK)
241 --db-nb-file=FILE OVN_Northbound db file (default: $DB_NB_FILE)
242 --db-sb-file=FILE OVN_Southbound db file (default: $DB_SB_FILE)
243 --db-nb-schema=FILE OVN_Northbound db file (default: $DB_NB_SCHEMA)
244 --db-sb-schema=FILE OVN_Southbound db file (default: $DB_SB_SCHEMA)
245 --db-nb-port=PORT OVN Northbound db ptcp port (default: $DB_NB_PORT)
246 --db-sb-port=PORT OVN Southbound db ptcp port (default: $DB_SB_PORT)
247 --ovn-dir=FILE OVN Databases directory (default: $OVN_DIR)
248 --ovn-nb-logfile=FILE OVN Northbound log file (default: $OVS_LOGDIR/ovsdb-server-nb.log)
249 --ovn-sb-logfile=FILE OVN Southbound log file (default: $OVS_LOGDIR/ovsdb-server-sb.log)
251 Default directories with "configure" option and environment variable override:
252 logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
253 pidfiles and sockets: /usr/local/var/run/openvswitch (--with-rundir, OVS_RUNDIR)
254 ovn-nb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
255 ovn-sb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
256 system configuration: /usr/local/etc (--sysconfdir, OVS_SYSCONFDIR)
257 data files: /usr/local/share/openvswitch (--pkgdatadir, OVS_PKGDATADIR)
258 user binaries: /usr/local/bin (--bindir, OVS_BINDIR)
259 system binaries: /usr/local/sbin (--sbindir, OVS_SBINDIR)
272 option=`expr X"$arg" : 'X--\([^=]*\)'`
273 value=`expr X"$arg" : 'X[^=]*=\(.*\)'`
278 option=`expr X"$arg" : 'X--no-\(.*\)'`
284 option=`expr X"$arg" : 'X--\(.*\)'`
290 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
294 if test X"$command" = X; then
297 echo >&2 "$0: exactly one non-option argument required (use --help for help)"
332 daemon_status ovn-northd || exit 1
338 daemon_status ovn-controller || exit 1
344 echo >&2 "$0: preheating ovn to 350 degrees F."
348 echo >&2 "$0: missing command name (use --help for help)"
352 echo >&2 "$0: unknown command \"$command\" (use --help for help)"