]> git.proxmox.com Git - mirror_ovs.git/blame - ovn/utilities/ovn-ctl
ovn: Modify restart_controller in ovn-ctl to use --restart
[mirror_ovs.git] / ovn / utilities / ovn-ctl
CommitLineData
43d3e694
RB
1#!/bin/sh
2#
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:
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
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.
14
15case $0 in
16 */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` ;;
17 *) dir0=./ ;;
18esac
19. "$dir0/ovs-lib" || exit 1
20
21for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
22 case :$PATH: in
23 *:$dir:*) ;;
24 *) PATH=$PATH:$dir ;;
25 esac
26done
27
28
556584f9
BS
29ovnnb_active_conf_file="$etcdir/ovnnb-active.conf"
30ovnsb_active_conf_file="$etcdir/ovnsb-active.conf"
31ovn_northd_db_conf_file="$etcdir/ovn-northd-db-params.conf"
43d3e694
RB
32## ----- ##
33## start ##
34## ----- ##
35
60bdd011
RM
36pidfile_is_running () {
37 pidfile=$1
38 test -e "$pidfile" && pid=`cat "$pidfile"` && pid_exists "$pid"
39} >/dev/null 2>&1
40
4b5fa1e7 41stop_nb_ovsdb() {
60bdd011 42 if pidfile_is_running $DB_NB_PID; then
7915b9cc 43 ovs-appctl -t $rundir/ovnnb_db.ctl exit
60bdd011 44 fi
4b5fa1e7 45}
60bdd011 46
4b5fa1e7 47stop_sb_ovsdb() {
60bdd011 48 if pidfile_is_running $DB_SB_PID; then
7915b9cc 49 ovs-appctl -t $rundir/ovnsb_db.ctl exit
60bdd011
RM
50 fi
51}
52
4b5fa1e7
NS
53stop_ovsdb () {
54 stop_nb_ovsdb
55 stop_sb_ovsdb
56}
57
556584f9
BS
58demote_ovnnb() {
59 if test ! -z "$DB_NB_SYNC_FROM_ADDR"; then
84d0ca5d 60 echo "$DB_NB_SYNC_FROM_PROTO:$DB_NB_SYNC_FROM_ADDR:$DB_NB_SYNC_FROM_PORT" > $ovnnb_active_conf_file
556584f9
BS
61 fi
62
63 if test -e $ovnnb_active_conf_file; then
64 ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/set-active-ovsdb-server `cat $ovnnb_active_conf_file`
65 ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/connect-active-ovsdb-server
66 else
67 echo >&2 "$0: active server details not set"
68 exit 1
69 fi
70}
71
72demote_ovnsb() {
73 if test ! -z "$DB_SB_SYNC_FROM_ADDR"; then
84d0ca5d 74 echo "$DB_SB_SYNC_FROM_PROTO:$DB_SB_SYNC_FROM_ADDR:$DB_SB_SYNC_FROM_PORT" > $ovnsb_active_conf_file
556584f9
BS
75 fi
76
77 if test -e $ovnsb_active_conf_file; then
78 ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/set-active-ovsdb-server `cat $ovnsb_active_conf_file`
79 ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/connect-active-ovsdb-server
80 else
81 echo >&2 "$0: active server details not set"
82 exit 1
83 fi
84}
85
86promote_ovnnb() {
87 rm -f $ovnnb_active_conf_file
88 ovs-appctl -t $rundir/ovnnb_db.ctl ovsdb-server/disconnect-active-ovsdb-server
89}
90
91promote_ovnsb() {
92 rm -f $ovnsb_active_conf_file
93 ovs-appctl -t $rundir/ovnsb_db.ctl ovsdb-server/disconnect-active-ovsdb-server
94}
95
79c7961b
NS
96start_ovsdb__() {
97 local DB=$1 db=$2 schema_name=$3 table_name=$4
b2dd8163 98 local pid
99 local cluster_local_addr
100 local cluster_local_port
101 local cluster_local_proto
102 local cluster_remote_addr
103 local cluster_remote_port
104 local cluster_remote_proto
105 local sync_from_proto
106 local sync_from_addr
107 local sync_from_port
108 local file
109 local schema
110 local logfile
111 local log
112 local sock
113 local detach
114 local create_insecure_remote
115 local port
116 local addr
117 local active_conf_file
9885e3b6 118 local use_remote_in_db
b2dd8163 119 eval pid=\$DB_${DB}_PID
120 eval cluster_local_addr=\$DB_${DB}_CLUSTER_LOCAL_ADDR
121 eval cluster_local_port=\$DB_${DB}_CLUSTER_LOCAL_PORT
122 eval cluster_local_proto=\$DB_${DB}_CLUSTER_LOCAL_PROTO
123 eval cluster_remote_addr=\$DB_${DB}_CLUSTER_REMOTE_ADDR
124 eval cluster_remote_port=\$DB_${DB}_CLUSTER_REMOTE_PORT
125 eval cluster_remote_proto=\$DB_${DB}_CLUSTER_REMOTE_PROTO
126 eval sync_from_proto=\$DB_${DB}_SYNC_FROM_PROTO
127 eval sync_from_addr=\$DB_${DB}_SYNC_FROM_ADDR
128 eval sync_from_port=\$DB_${DB}_SYNC_FROM_PORT
129 eval file=\$DB_${DB}_FILE
130 eval schema=\$DB_${DB}_SCHEMA
131 eval logfile=\$OVN_${DB}_LOGFILE
132 eval log=\$OVN_${DB}_LOG
133 eval sock=\$DB_${DB}_SOCK
134 eval detach=\$DB_${DB}_DETACH
135 eval create_insecure_remote=\$DB_${DB}_CREATE_INSECURE_REMOTE
136 eval port=\$DB_${DB}_PORT
137 eval addr=\$DB_${DB}_ADDR
138 eval active_conf_file=\$ovn${db}_active_conf_file
9885e3b6 139 eval use_remote_in_db=\$DB_${DB}_USE_REMOTE_IN_DB
79c7961b
NS
140
141 # Check and eventually start ovsdb-server for DB
142 if pidfile_is_running $pid; then
143 return
144 fi
60bdd011 145
79c7961b
NS
146 if test ! -z "$cluster_local_addr"; then
147 mode=cluster
148 elif test ! -z "$sync_from_addr"; then
149 mode=active_passive
150 echo "$sync_from_proto:$sync_from_addr:\
151$sync_from_port" > $active_conf_file
152 else
153 mode=standalone
154 fi
60bdd011 155
79c7961b
NS
156 if test $mode = cluster; then
157 local local=$cluster_local_proto:$cluster_local_addr:\
158$cluster_local_port
159 local remote=$cluster_remote_proto:$cluster_remote_addr:\
160$cluster_remote_port
161 if test -n "$cluster_remote_addr"; then
162 join_cluster "$file" "$schema_name" "$local" "$remote"
74103dc2 163 else
79c7961b 164 create_cluster "$file" "$schema" "$local"
74103dc2 165 fi
79c7961b
NS
166 else
167 upgrade_db "$file" "$schema"
168 fi
74103dc2 169
79c7961b
NS
170 set ovsdb-server
171 set "$@" $log --log-file=$logfile
172 set "$@" --remote=punix:$sock --pidfile=$pid
173 set "$@" --unixctl=ovn${db}_db.ctl
556584f9 174
79c7961b
NS
175 if test X"$detach" != Xno; then
176 set "$@" --detach --monitor
177 else
178 set exec "$@"
179 fi
556584f9 180
9885e3b6 181 if test X"$use_remote_in_db" != Xno; then
182 set "$@" --remote=db:$schema_name,$table_name,connections
183 fi
79c7961b
NS
184 set "$@" --private-key=db:$schema_name,SSL,private_key
185 set "$@" --certificate=db:$schema_name,SSL,certificate
186 set "$@" --ca-cert=db:$schema_name,SSL,ca_cert
187 set "$@" --ssl-protocols=db:$schema_name,SSL,ssl_protocols
188 set "$@" --ssl-ciphers=db:$schema_name,SSL,ssl_ciphers
60bdd011 189
79c7961b
NS
190 if test X"$create_insecure_remote" = Xyes; then
191 set "$@" --remote=ptcp:$port:$addr
60bdd011
RM
192 fi
193
79c7961b
NS
194 if test $mode = active_passive; then
195 set "$@" --sync-from=`cat $active_conf_file`
196 fi
60bdd011 197
79c7961b 198 "$@" "$file"
74103dc2 199
79c7961b
NS
200 # Initialize the database if it's running standalone,
201 # active-passive, or is the first server in a cluster.
202 if test -z "$cluster_remote_addr"; then
203 ovn-nbctl init
204 fi
556584f9 205
79c7961b
NS
206 if test $mode = cluster; then
207 upgrade_cluster "$schema" "unix:$sock"
208 fi
209}
556584f9 210
79c7961b
NS
211start_nb_ovsdb() {
212 start_ovsdb__ NB nb OVN_Northbound NB_Global
213}
556584f9 214
79c7961b
NS
215start_sb_ovsdb() {
216 start_ovsdb__ SB sb OVN_Southbound SB_Global
60bdd011
RM
217}
218
4b5fa1e7
NS
219start_ovsdb () {
220 start_nb_ovsdb
221 start_sb_ovsdb
222}
223
556584f9
BS
224sync_status() {
225 ovs-appctl -t $rundir/ovn${1}_db.ctl ovsdb-server/sync-status | awk '{if(NR==1) print $2}'
226}
227
228status_ovnnb() {
229 if ! pidfile_is_running $DB_NB_PID; then
230 echo "not-running"
231 else
232 echo "running/$(sync_status nb)"
233 fi
234}
235
236status_ovnsb() {
237 if ! pidfile_is_running $DB_SB_PID; then
238 echo "not-running"
239 else
240 echo "running/$(sync_status sb)"
241 fi
242}
243
60bdd011
RM
244status_ovsdb () {
245 if ! pidfile_is_running $DB_NB_PID; then
246 log_success_msg "OVN Northbound DB is not running"
247 else
248 log_success_msg "OVN Northbound DB is running"
249 fi
250
251 if ! pidfile_is_running $DB_SB_PID; then
252 log_success_msg "OVN Southbound DB is not running"
253 else
254 log_success_msg "OVN Southbound DB is running"
255 fi
43d3e694
RB
256}
257
74103dc2
NS
258run_nb_ovsdb() {
259 DB_NB_DETACH=no
260 start_nb_ovsdb
261}
262
263run_sb_ovsdb() {
264 DB_SB_DETACH=no
265 start_sb_ovsdb
266}
267
43d3e694 268start_northd () {
556584f9
BS
269 if [ ! -e $ovn_northd_db_conf_file ]; then
270 if test X"$OVN_MANAGE_OVSDB" = Xyes; then
271 start_ovsdb
556584f9 272
126fb3e8
NS
273 if ! pidfile_is_running $DB_NB_PID; then
274 log_failure_msg "OVN Northbound DB is not running"
275 exit
276 fi
277 if ! pidfile_is_running $DB_SB_PID; then
278 log_failure_msg "OVN Southbound DB is not running"
279 exit
280 fi
556584f9 281 fi
79c7961b
NS
282 ovn_northd_params="--ovnnb-db=$OVN_NORTHD_NB_DB \
283 --ovnsb-db=$OVN_NORTHD_SB_DB"
556584f9
BS
284 else
285 ovn_northd_params="`cat $ovn_northd_db_conf_file`"
286 fi
43d3e694 287
556584f9
BS
288 if daemon_is_running ovn-northd; then
289 log_success_msg "ovn-northd is already running"
290 else
291 set ovn-northd
292 if test X"$OVN_NORTHD_LOGFILE" != X; then
293 set "$@" --log-file=$OVN_NORTHD_LOGFILE
294 fi
60bdd011 295
556584f9
BS
296 set "$@" $OVN_NORTHD_LOG $ovn_northd_params
297
298 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@"
299 fi
43d3e694
RB
300}
301
302start_controller () {
303 set ovn-controller "unix:$DB_SOCK"
3bc54be7 304 set "$@" $OVN_CONTROLLER_LOG
ea2d950a 305 if test X"$OVN_CONTROLLER_SSL_KEY" != X; then
84d0ca5d 306 set "$@" --private-key=$OVN_CONTROLLER_SSL_KEY
ea2d950a
GS
307 fi
308 if test X"$OVN_CONTROLLER_SSL_CERT" != X; then
84d0ca5d 309 set "$@" --certificate=$OVN_CONTROLLER_SSL_CERT
ea2d950a
GS
310 fi
311 if test X"$OVN_CONTROLLER_SSL_CA_CERT" != X; then
84d0ca5d
LR
312 set "$@" --ca-cert=$OVN_CONTROLLER_SSL_CA_CERT
313 fi
ea2d950a
GS
314 if test X"$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT" != X; then
315 set "$@" --bootstrap-ca-cert=$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT
316 fi
43d3e694
RB
317 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"
318}
319
f4a4ce58
RM
320start_controller_vtep () {
321 set ovn-controller-vtep "unix:$DB_SOCK"
322 set "$@" -vconsole:emer -vsyslog:err -vfile:info
ea2d950a 323 if test X"$OVN_CONTROLLER_SSL_KEY" != X; then
84d0ca5d 324 set "$@" --private-key=$OVN_CONTROLLER_SSL_KEY
ea2d950a
GS
325 fi
326 if test X"$OVN_CONTROLLER_SSL_CERT" != X; then
84d0ca5d 327 set "$@" --certificate=$OVN_CONTROLLER_SSL_CERT
ea2d950a
GS
328 fi
329 if test X"$OVN_CONTROLLER_SSL_CA_CERT" != X; then
84d0ca5d
LR
330 set "$@" --ca-cert=$OVN_CONTROLLER_SSL_CA_CERT
331 fi
ea2d950a
GS
332 if test X"$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT" != X; then
333 set "$@" --bootstrap-ca-cert=$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT
334 fi
f4a4ce58
RM
335 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"
336}
337
43d3e694
RB
338## ---- ##
339## stop ##
340## ---- ##
341
342stop_northd () {
343 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-northd
60bdd011 344
556584f9
BS
345 if [ ! -e $ovn_northd_db_conf_file ]; then
346 if test X"$OVN_MANAGE_OVSDB" = Xyes; then
347 stop_ovsdb
348 fi
60bdd011 349 fi
43d3e694
RB
350}
351
352stop_controller () {
7491caa3 353 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-controller "$@"
43d3e694
RB
354}
355
f4a4ce58
RM
356stop_controller_vtep () {
357 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-controller-vtep
358}
359
43d3e694
RB
360## ------- ##
361## restart ##
362## ------- ##
363
364restart_northd () {
365 stop_northd
366 start_northd
367}
368
369restart_controller () {
7491caa3 370 stop_controller --restart
43d3e694
RB
371 start_controller
372}
373
f4a4ce58
RM
374restart_controller_vtep () {
375 stop_controller_vtep
376 start_controller_vtep
377}
378
60bdd011
RM
379restart_ovsdb () {
380 stop_ovsdb
381 start_ovsdb
382}
383
4b5fa1e7
NS
384restart_nb_ovsdb () {
385 stop_nb_ovsdb
386 start_nb_ovsdb
387}
388
389restart_sb_ovsdb () {
390 stop_sb_ovsdb
391 start_sb_ovsdb
392}
393
43d3e694
RB
394## ---- ##
395## main ##
396## ---- ##
397
398set_defaults () {
60bdd011
RM
399 OVN_MANAGE_OVSDB=yes
400
7915b9cc
RB
401 DB_NB_SOCK=$rundir/ovnnb_db.sock
402 DB_NB_PID=$rundir/ovnnb_db.pid
403 DB_NB_FILE=$dbdir/ovnnb_db.db
31491a53 404 DB_NB_ADDR=0.0.0.0
60bdd011 405 DB_NB_PORT=6641
84d0ca5d 406 DB_NB_SYNC_FROM_PROTO=tcp
556584f9
BS
407 DB_NB_SYNC_FROM_ADDR=
408 DB_NB_SYNC_FROM_PORT=6641
60bdd011 409
7915b9cc
RB
410 DB_SB_SOCK=$rundir/ovnsb_db.sock
411 DB_SB_PID=$rundir/ovnsb_db.pid
412 DB_SB_FILE=$dbdir/ovnsb_db.db
31491a53 413 DB_SB_ADDR=0.0.0.0
60bdd011 414 DB_SB_PORT=6642
84d0ca5d 415 DB_SB_SYNC_FROM_PROTO=tcp
556584f9
BS
416 DB_SB_SYNC_FROM_ADDR=
417 DB_SB_SYNC_FROM_PORT=6642
60bdd011 418
43d3e694
RB
419 DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
420 DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
421
60bdd011
RM
422 DB_SOCK=$rundir/db.sock
423 DB_CONF_FILE=$dbdir/conf.db
424
43d3e694
RB
425 OVN_NORTHD_PRIORITY=-10
426 OVN_NORTHD_WRAPPER=
427 OVN_CONTROLLER_PRIORITY=-10
428 OVN_CONTROLLER_WRAPPER=
429
430 OVS_RUNDIR=${OVS_RUNDIR:-${rundir}}
431 OVN_RUNDIR=${OVN_RUNDIR:-${OVS_RUNDIR}}
60bdd011
RM
432
433 OVN_CONTROLLER_LOG="-vconsole:emer -vsyslog:err -vfile:info"
434 OVN_NORTHD_LOG="-vconsole:emer -vsyslog:err -vfile:info"
31491a53 435 OVN_NORTHD_LOGFILE=""
8c8a8209
NS
436 OVN_NB_LOG="-vconsole:off -vfile:info"
437 OVN_SB_LOG="-vconsole:off -vfile:info"
7915b9cc
RB
438 OVN_NB_LOGFILE="$logdir/ovsdb-server-nb.log"
439 OVN_SB_LOGFILE="$logdir/ovsdb-server-sb.log"
84d0ca5d
LR
440
441 OVN_CONTROLLER_SSL_KEY=""
442 OVN_CONTROLLER_SSL_CERT=""
443 OVN_CONTROLLER_SSL_CA_CERT=""
ea2d950a 444 OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT=""
84d0ca5d
LR
445
446 DB_SB_CREATE_INSECURE_REMOTE="no"
447 DB_NB_CREATE_INSECURE_REMOTE="no"
94896b2e
MM
448
449 MONITOR="yes"
74103dc2
NS
450
451 DB_NB_DETACH="yes"
452 DB_SB_DETACH="yes"
79c7961b
NS
453
454 DB_NB_CLUSTER_LOCAL_ADDR=""
455 DB_NB_CLUSTER_LOCAL_PROTO="tcp"
456 DB_NB_CLUSTER_LOCAL_PORT=6643
457 DB_NB_CLUSTER_REMOTE_ADDR=""
458 DB_NB_CLUSTER_REMOTE_PROTO="tcp"
459 DB_NB_CLUSTER_REMOTE_PORT=6643
460
461 DB_SB_CLUSTER_LOCAL_ADDR=""
462 DB_SB_CLUSTER_LOCAL_PROTO="tcp"
463 DB_SB_CLUSTER_LOCAL_PORT=6644
464 DB_SB_CLUSTER_REMOTE_ADDR=""
465 DB_SB_CLUSTER_REMOTE_PROTO="tcp"
466 DB_SB_CLUSTER_REMOTE_PORT=6644
467
468 OVN_NORTHD_NB_DB="unix:$DB_NB_SOCK"
469 OVN_NORTHD_SB_DB="unix:$DB_SB_SOCK"
9885e3b6 470 DB_NB_USE_REMOTE_IN_DB="yes"
471 DB_SB_USE_REMOTE_IN_DB="yes"
43d3e694
RB
472}
473
474set_option () {
475 var=`echo "$option" | tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
476 eval set=\${$var+yes}
477 eval old_value=\$$var
478 if test X$set = X || \
479 (test $type = bool && \
480 test X"$old_value" != Xno && test X"$old_value" != Xyes); then
481 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
482 return
483 fi
484 eval $var=\$value
485}
486
487usage () {
488 set_defaults
489 cat << EOF
490$0: controls Open Virtual Network daemons
491usage: $0 [OPTIONS] COMMAND
492
493This program is intended to be invoked internally by Open Virtual Network
494startup scripts. System administrators should not normally invoke it directly.
495
496Commands:
f4a4ce58
RM
497 start_northd start ovn-northd
498 start_ovsdb start ovn related ovsdb-server processes
4b5fa1e7
NS
499 start_nb_ovsdb start ovn northbound db ovsdb-server process
500 start_sb_ovsdb start ovn southbound db ovsdb-server process
f4a4ce58
RM
501 start_controller start ovn-controller
502 start_controller_vtep start ovn-controller-vtep
503 stop_northd stop ovn-northd
504 stop_ovsdb stop ovn related ovsdb-server processes
4b5fa1e7
NS
505 stop_nb_ovsdb stop ovn northbound db ovsdb-server process
506 stop_sb_ovsdb stop ovn southbound db ovsdb-server process
f4a4ce58
RM
507 stop_controller stop ovn-controller
508 stop_controller_vtep stop ovn-controller-vtep
509 restart_northd restart ovn-northd
510 restart_ovsdb restart ovn related ovsdb-server processes
4b5fa1e7
NS
511 restart_nb_ovsdb restart ovn northbound db ovsdb-server process
512 restart_sb_ovsdb restart ovn southbound db ovsdb-server process
f4a4ce58
RM
513 restart_controller restart ovn-controller
514 restart_controller_vtep restart ovn-controller-vtep
74103dc2
NS
515 run_nb_ovsdb run ovn northbound db ovsdb-server process
516 run_sb_ovsdb run ovn southbound db ovsdb-server process
43d3e694
RB
517
518Options:
519 --ovn-northd-priority=NICE set ovn-northd's niceness (default: $OVN_NORTHD_PRIORITY)
520 --ovn-northd-wrapper=WRAPPER run with a wrapper like valgrind for debugging
c368a462 521 --ovn-controller-priority=NICE set ovn-controller's niceness (default: $OVN_CONTROLLER_PRIORITY)
43d3e694 522 --ovn-controller-wrapper=WRAPPER run with a wrapper like valgrind for debugging
84d0ca5d
LR
523 --ovn-controller-ssl-key=KEY OVN Southbound SSL private key file
524 --ovn-controller-ssl-cert=CERT OVN Southbound SSL certificate file
525 --ovn-controller-ssl-ca-cert=CERT OVN Southbound SSL CA certificate file
ea2d950a 526 --ovn-controller-ssl-bootstrap-ca-cert=CERT Bootstrapped OVN Southbound SSL CA certificate file
60bdd011
RM
527 --ovn-manage-ovsdb=yes|no Whether or not the OVN databases should be
528 automatically started and stopped along
529 with ovn-northd. The default is "yes". If
530 this is set to "no", the "start_ovsdb" and
531 "stop_ovsdb" commands must be used to start
532 and stop the OVN databases.
533 --ovn-controller-log=STRING ovn controller process logging params (default: $OVN_CONTROLLER_LOG)
534 --ovn-northd-log=STRING ovn northd process logging params (default: $OVN_NORTHD_LOG)
31491a53 535 --ovn-northd-logfile=STRING ovn northd process log file (default: $OVN_NORTHD_LOGFILE)
60bdd011
RM
536 --ovn-nb-log=STRING ovn NB ovsdb-server processes logging params (default: $OVN_NB_LOG)
537 --ovn-sb-log=STRING ovn SB ovsdb-server processes logging params (default: $OVN_SB_LOG)
43d3e694
RB
538 -h, --help display this help message
539
540File location options:
541 --db-sock=SOCKET JSON-RPC socket name (default: $DB_SOCK)
542 --db-nb-file=FILE OVN_Northbound db file (default: $DB_NB_FILE)
543 --db-sb-file=FILE OVN_Southbound db file (default: $DB_SB_FILE)
544 --db-nb-schema=FILE OVN_Northbound db file (default: $DB_NB_SCHEMA)
545 --db-sb-schema=FILE OVN_Southbound db file (default: $DB_SB_SCHEMA)
31491a53 546 --db-nb-addr=ADDR OVN Northbound db ptcp address (default: $DB_NB_ADDR)
60bdd011 547 --db-nb-port=PORT OVN Northbound db ptcp port (default: $DB_NB_PORT)
31491a53 548 --db-sb-addr=ADDR OVN Southbound db ptcp address (default: $DB_SB_ADDR)
60bdd011 549 --db-sb-port=PORT OVN Southbound db ptcp port (default: $DB_SB_PORT)
7915b9cc
RB
550 --ovn-nb-logfile=FILE OVN Northbound log file (default: $OVN_NB_LOGFILE)
551 --ovn-sb-logfile=FILE OVN Southbound log file (default: $OVN_SB_LOGFILE)
556584f9 552 --db-nb-sync-from-addr=ADDR OVN Northbound active db tcp address (default: $DB_NB_SYNC_FROM_ADDR)
84d0ca5d
LR
553 --db-nb-sync-from-port=PORT OVN Northbound active db tcp port (default: $DB_NB_SYNC_FROM_PORT)
554 --db-nb-sync-from-proto=PROTO OVN Northbound active db transport (default: $DB_NB_SYNC_FROM_PROTO)
555 --db-nb-create-insecure-remote=yes|no Create ptcp OVN Northbound remote (default: $DB_NB_CREATE_INSECURE_REMOTE)
556584f9
BS
556 --db-sb-sync-from-addr=ADDR OVN Southbound active db tcp address (default: $DB_SB_SYNC_FROM_ADDR)
557 --db-sb-sync-from-port=ADDR OVN Southbound active db tcp port (default: $DB_SB_SYNC_FROM_PORT)
84d0ca5d
LR
558 --db-sb-sync-from-proto=PROTO OVN Southbound active db transport (default: $DB_SB_SYNC_FROM_PROTO)
559 --db-sb-create-insecure-remote=yes|no Create ptcp OVN Southbound remote (default: $DB_SB_CREATE_INSECURE_REMOTE)
79c7961b
NS
560 --db-nb-cluster-local-addr=ADDR OVN_Northbound cluster local address \
561 (default: $DB_NB_CLUSTER_LOCAL_ADDR)
562 --db-nb-cluster-local-port=PORT OVN_Northbound cluster local tcp port \
563 (default: $DB_NB_CLUSTER_LOCAL_PORT)
564 --db-nb-cluster-local-proto=PROTO OVN_Northbound cluster local db transport \
565 (default: $DB_NB_CLUSTER_LOCAL_PROTO)
566 --db-nb-cluster-remote-addr=ADDR OVN_Northbound cluster remote address \
567 (default: $DB_NB_CLUSTER_REMOTE_ADDR)
568 --db-nb-cluster-remote-port=PORT OVN_Northbound cluster remote tcp port \
569 (default: $DB_NB_CLUSTER_REMOTE_PORT)
570 --db-nb-cluster-remote-proto=PROTO OVN_Northbound cluster remote db \
571 transport (default: $DB_NB_CLUSTER_REMOTE_PROTO)
572 --db-sb-cluster-local-addr=ADDR OVN_Southbound cluster local address \
573 (default: $DB_SB_CLUSTER_LOCAL_ADDR)
574 --db-sb-cluster-local-port=PORT OVN_Southbound cluster local tcp port \
575 (default: $DB_SB_CLUSTER_LOCAL_PORT)
576 --db-sb-cluster-local-proto=PROTO OVN_Southbound cluster local db transport \
577 (default: $DB_SB_CLUSTER_LOCAL_PROTO)
578 --db-sb-cluster-remote-addr=ADDR OVN_Southbound cluster remote address \
579 (default: $DB_SB_CLUSTER_REMOTE_ADDR)
580 --db-sb-cluster-remote-port=PORT OVN_Southbound cluster remote tcp port \
581 (default: $DB_SB_CLUSTER_REMOTE_PORT)
582 --db-sb-cluster-remote-proto=PROTO OVN_Southbound cluster remote db \
583 transport (default: $DB_SB_CLUSTER_REMOTE_PROTO)
584 --ovn-northd-nb-db=NB DB address(es) (default: $OVN_NORTHD_NB_DB)
585 --ovn-northd-sb-db=SB DB address(es) (default: $OVN_NORTHD_SB_DB)
9885e3b6 586 --db-nb-use-remote-in-db=yes|no OVN_Northbound db listen on target connection table (default: $DB_NB_USE_REMOTE_IN_DB)
587 --db-sb-use-remote-in-db=yes|no OVN_Southbound db listen on target connection table (default: $DB_SB_USE_REMOTE_IN_DB)
43d3e694
RB
588
589Default directories with "configure" option and environment variable override:
590 logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
591 pidfiles and sockets: /usr/local/var/run/openvswitch (--with-rundir, OVS_RUNDIR)
592 ovn-nb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
593 ovn-sb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
594 system configuration: /usr/local/etc (--sysconfdir, OVS_SYSCONFDIR)
595 data files: /usr/local/share/openvswitch (--pkgdatadir, OVS_PKGDATADIR)
596 user binaries: /usr/local/bin (--bindir, OVS_BINDIR)
597 system binaries: /usr/local/sbin (--sbindir, OVS_SBINDIR)
598EOF
599}
600
601set_defaults
602command=
603for arg
604do
605 case $arg in
606 -h | --help)
607 usage
608 ;;
609 --[a-z]*=*)
610 option=`expr X"$arg" : 'X--\([^=]*\)'`
611 value=`expr X"$arg" : 'X[^=]*=\(.*\)'`
612 type=string
613 set_option
614 ;;
615 --no-[a-z]*)
616 option=`expr X"$arg" : 'X--no-\(.*\)'`
617 value=no
618 type=bool
619 set_option
620 ;;
621 --[a-z]*)
622 option=`expr X"$arg" : 'X--\(.*\)'`
623 value=yes
624 type=bool
625 set_option
626 ;;
627 -*)
628 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
629 exit 1
630 ;;
631 *)
632 if test X"$command" = X; then
633 command=$arg
634 else
635 echo >&2 "$0: exactly one non-option argument required (use --help for help)"
636 exit 1
637 fi
638 ;;
639 esac
640done
641case $command in
642 start_northd)
643 start_northd
644 ;;
60bdd011
RM
645 start_ovsdb)
646 start_ovsdb
647 ;;
4b5fa1e7
NS
648 start_nb_ovsdb)
649 start_nb_ovsdb
650 ;;
651 start_sb_ovsdb)
652 start_sb_ovsdb
653 ;;
43d3e694
RB
654 start_controller)
655 start_controller
656 ;;
f4a4ce58
RM
657 start_controller_vtep)
658 start_controller_vtep
659 ;;
43d3e694
RB
660 stop_northd)
661 stop_northd
662 ;;
60bdd011
RM
663 stop_ovsdb)
664 stop_ovsdb
665 ;;
4b5fa1e7
NS
666 stop_nb_ovsdb)
667 stop_nb_ovsdb
668 ;;
669 stop_sb_ovsdb)
670 stop_sb_ovsdb
671 ;;
43d3e694
RB
672 stop_controller)
673 stop_controller
674 ;;
f4a4ce58
RM
675 stop_controller_vtep)
676 stop_controller_vtep
677 ;;
43d3e694 678 restart_northd)
cbf01675 679 restart_northd
43d3e694 680 ;;
60bdd011
RM
681 restart_ovsdb)
682 restart_ovsdb
683 ;;
4b5fa1e7
NS
684 restart_nb_ovsdb)
685 restart_nb_ovsdb
686 ;;
687 restart_sb_ovsdb)
688 restart_sb_ovsdb
689 ;;
43d3e694
RB
690 restart_controller)
691 restart_controller
692 ;;
f4a4ce58
RM
693 restart_controller_vtep)
694 restart_controller_vtep
695 ;;
e7b438dc
GS
696 status_northd)
697 daemon_status ovn-northd || exit 1
698 ;;
60bdd011
RM
699 status_ovsdb)
700 status_ovsdb
701 ;;
e7b438dc
GS
702 status_controller)
703 daemon_status ovn-controller || exit 1
704 ;;
f4a4ce58
RM
705 status_controller_vtep)
706 daemon_status ovn-controller-vtep || exit 1
707 ;;
556584f9
BS
708 promote_ovnnb)
709 promote_ovnnb
710 ;;
711 promote_ovnsb)
712 promote_ovnsb
713 ;;
714 demote_ovnnb)
715 demote_ovnnb
716 ;;
717 demote_ovnsb)
718 demote_ovnsb
719 ;;
720 status_ovnnb)
721 status_ovnnb
722 ;;
723 status_ovnsb)
724 status_ovnsb
725 ;;
74103dc2
NS
726 run_nb_ovsdb)
727 run_nb_ovsdb
728 ;;
729 run_sb_ovsdb)
730 run_sb_ovsdb
731 ;;
43d3e694
RB
732 help)
733 usage
734 ;;
735 preheat)
736 echo >&2 "$0: preheating ovn to 350 degrees F."
737 exit 1
738 ;;
739 '')
740 echo >&2 "$0: missing command name (use --help for help)"
741 exit 1
742 ;;
743 *)
744 echo >&2 "$0: unknown command \"$command\" (use --help for help)"
745 exit 1
746 ;;
747esac