forked from ovn-org/ovn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathovn-ctl
executable file
·1493 lines (1342 loc) · 51.2 KB
/
ovn-ctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
case $0 in
*/*) dir0=`echo "$0" | sed 's,/[^/]*$,,'`
ovsdir=`echo "$dir0" | sed 's,/ovn/scripts,,'`
ovsdir=$ovsdir/openvswitch/scripts
;;
*) dir0=./ ;;
esac
. "$ovsdir/ovs-lib" || exit 1
. "$dir0/ovn-lib" || exit 1
for dir in "$sbindir" "$ovn_bindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
case :$PATH: in
*:$dir:*) ;;
*) PATH=$PATH:$dir ;;
esac
done
ovnnb_active_conf_file="$ovn_etcdir/ovnnb-active.conf"
ovnsb_active_conf_file="$ovn_etcdir/ovnsb-active.conf"
ovn_northd_db_conf_file="$ovn_etcdir/ovn-northd-db-params.conf"
ic_nb_active_conf_file="$ovn_etcdir/ic-nb-active.conf"
ic_sb_active_conf_file="$ovn_etcdir/ic-sb-active.conf"
ovn_ic_db_conf_file="$ovn_etcdir/ovn-ic-db-params.conf"
## ----- ##
## start ##
## ----- ##
pidfile_is_running () {
pidfile=$1
cmd=$2
if [ ! -s "$pidfile" ]; then
# file missing or empty
return 1
fi
pid=`cat "$pidfile"`
if ! pid_exists $pid; then
# pid is dead
return 1
fi
if [ -n "$cmd" ]; then
return $(pid_comm_check "$cmd" "$pid")
fi
return 0
}
stop_nb_ovsdb() {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnnb_db $DB_NB_PIDFILE $DB_NB_CTRL_SOCK
}
stop_sb_ovsdb() {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnsb_db $DB_SB_PIDFILE $DB_SB_CTRL_SOCK
}
stop_ovsdb () {
stop_nb_ovsdb
stop_sb_ovsdb
}
stop_ic_nb_ovsdb() {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn_ic_nb_db $DB_IC_NB_PIDFILE $DB_IC_NB_CTRL_SOCK
}
stop_ic_sb_ovsdb() {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn_ic_sb_db $DB_IC_SB_PIDFILE $DB_IC_SB_CTRL_SOCK
}
stop_ic_ovsdb () {
stop_ic_nb_ovsdb
stop_ic_sb_ovsdb
}
stop_sb_relay_ovsdb() {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovnsb_relay $DB_SB_RELAY_PIDFILE $DB_SB_RELAY_CTRL_SOCK
}
demote_xx_ovsdb () {
local sync_from_addr=$1
local sync_from_proto=$2
local sync_from_port=$3
local active_conf_file=$4
local inactive_probe_to_active=$5
local ctl_file=$6
if test ! -z "$sync_from_addr"; then
echo "$sync_from_proto:$sync_from_addr:$sync_from_port" > $active_conf_file
fi
if test -e $active_conf_file; then
ovn-appctl -t $ctl_file ovsdb-server/set-active-ovsdb-server `cat $active_conf_file`
ovn-appctl -t $ctl_file ovsdb-server/connect-active-ovsdb-server
ovn-appctl -t $ctl_file ovsdb-server/set-active-ovsdb-server-probe-interval $inactive_probe_to_active
else
echo >&2 "$0: active server details not set"
exit 1
fi
}
demote_ovnnb() {
demote_xx_ovsdb $DB_NB_SYNC_FROM_ADDR $DB_NB_SYNC_FROM_PROTO \
$DB_NB_SYNC_FROM_PORT $ovnnb_active_conf_file \
$DB_NB_PROBE_INTERVAL_TO_ACTIVE $DB_NB_CTRL_SOCK
}
demote_ovnsb() {
demote_xx_ovsdb $DB_SB_SYNC_FROM_ADDR $DB_SB_SYNC_FROM_PROTO \
$DB_SB_SYNC_FROM_PORT $ovnsb_active_conf_file \
$DB_SB_PROBE_INTERVAL_TO_ACTIVE $DB_SB_CTRL_SOCK
}
demote_ic_nb() {
demote_xx_ovsdb $DB_IC_NB_SYNC_FROM_ADDR $DB_IC_NB_SYNC_FROM_PROTO \
$DB_IC_NB_SYNC_FROM_PORT $ic_nb_active_conf_file $DB_IC_NB_CTRL_SOCK
}
demote_ic_sb() {
demote_xx_ovsdb $DB_IC_SB_SYNC_FROM_ADDR $DB_IC_SB_SYNC_FROM_PROTO \
$DB_IC_SB_SYNC_FROM_PORT $ic_sb_active_conf_file $DB_IC_SB_CTRL_SOCK
}
promote_xx_ovsdb() {
local active_conf_file=$1
local ctl_file=$2
rm -f $active_conf_file
ovn-appctl -t $ctl_file ovsdb-server/disconnect-active-ovsdb-server
}
promote_ovnnb() {
promote_xx_ovsdb $ovnnb_active_conf_file $DB_NB_CTRL_SOCK
}
promote_ovnsb() {
promote_xx_ovsdb $ovnsb_active_conf_file $DB_SB_CTRL_SOCK
}
promote_ic_nb() {
promote_xx_ovsdb $ic_nb_active_conf_file $DB_IC_NB_CTRL_SOCK
}
promote_ic_sb() {
promote_xx_ovsdb $ic_sb_active_conf_file $DB_IC_SB_CTRL_SOCK
}
start_ovsdb__() {
local DB=$1 db=$2 schema_name=$3 table_name=$4 wrapper=$5
local db_pid_file
local cluster_local_addr
local cluster_local_port
local cluster_local_proto
local cluster_remote_addr
local cluster_remote_port
local cluster_remote_proto
local sync_from_proto
local sync_from_addr
local sync_from_port
local file
local schema
local config_file
local logfile
local log
local sock
local ctrl_sock
local detach
local create_insecure_remote
local port
local addr
local active_conf_file
local use_remote_in_db
local ovn_db_ssl_key
local ovn_db_ssl_cert
local ovn_db_ssl_cacert
local ovn_db_election_timer
local relay_mode
local cluster_db_upgrade
local ovn_db_ssl_protocols
local ovn_db_ssl_ciphers
eval db_pid_file=\$DB_${DB}_PIDFILE
eval cluster_local_addr=\$DB_${DB}_CLUSTER_LOCAL_ADDR
eval cluster_local_port=\$DB_${DB}_CLUSTER_LOCAL_PORT
eval cluster_local_proto=\$DB_${DB}_CLUSTER_LOCAL_PROTO
eval cluster_remote_addr=\$DB_${DB}_CLUSTER_REMOTE_ADDR
eval cluster_remote_port=\$DB_${DB}_CLUSTER_REMOTE_PORT
eval cluster_remote_proto=\$DB_${DB}_CLUSTER_REMOTE_PROTO
eval sync_from_proto=\$DB_${DB}_SYNC_FROM_PROTO
eval sync_from_addr=\$DB_${DB}_SYNC_FROM_ADDR
eval sync_from_port=\$DB_${DB}_SYNC_FROM_PORT
eval file=\$DB_${DB}_FILE
eval schema=\$DB_${DB}_SCHEMA
eval config_file=\$DB_${DB}_CONFIG_FILE
eval logfile=\$OVN_${DB}_LOGFILE
eval log=\$OVN_${DB}_LOG
eval sock=\$DB_${DB}_SOCK
eval ctrl_sock=\$DB_${DB}_CTRL_SOCK
eval detach=\$DB_${DB}_DETACH
eval create_insecure_remote=\$DB_${DB}_CREATE_INSECURE_REMOTE
eval port=\$DB_${DB}_PORT
eval addr=\$DB_${DB}_ADDR
eval active_conf_file=\$ovn${db}_active_conf_file
eval use_remote_in_db=\$DB_${DB}_USE_REMOTE_IN_DB
eval ovn_db_ssl_key=\$OVN_${DB}_DB_SSL_KEY
eval ovn_db_ssl_cert=\$OVN_${DB}_DB_SSL_CERT
eval ovn_db_ssl_cacert=\$OVN_${DB}_DB_SSL_CA_CERT
eval ovn_db_election_timer=\$DB_${DB}_ELECTION_TIMER
eval relay_mode=\$RELAY_MODE
eval relay_remote=\$DB_${DB}_REMOTE
eval cluster_db_upgrade=\$DB_CLUSTER_SCHEMA_UPGRADE
eval ovn_db_ssl_protocols=\$OVN_${DB}_DB_SSL_PROTOCOLS
eval ovn_db_ssl_ciphers=\$OVN_${DB}_DB_SSL_CIPHERS
ovn_install_dir "$OVN_RUNDIR"
ovn_install_dir "$ovn_logdir"
ovn_install_dir "$ovn_dbdir"
ovn_install_dir "$ovn_etcdir"
# Check and eventually start ovsdb-server for DB
if pidfile_is_running $db_pid_file ovsdb-server; then
return
fi
if test ! -z "$cluster_local_addr"; then
mode=cluster
elif test ! -z "$sync_from_addr"; then
mode=active_passive
echo "$sync_from_proto:$sync_from_addr:\
$sync_from_port" > $active_conf_file
elif test X"$relay_mode" != Xno; then
mode=relay
else
mode=standalone
fi
if test $mode = cluster; then
# check for election timer arg support in ovsdb-tool
has_election_timer=$(ovsdb-tool --help | grep "\--election-timer")
if test -n "$ovn_db_election_timer" && \
test -z "$has_election_timer"; then
# caller requested election timer but ovsdb-tool doesn't support it
log_failure_msg "ovsdb-tool does not support --election-timer"
exit
fi
local local=$cluster_local_proto:$cluster_local_addr:\
$cluster_local_port
local remote=$cluster_remote_proto:$cluster_remote_addr:\
$cluster_remote_port
if test -n "$cluster_remote_addr"; then
join_cluster "$file" "$schema_name" "$local" "$remote"
else
create_cluster "$file" "$schema" "$local" "$ovn_db_election_timer"
fi
elif test $mode = relay; then
local file="relay:${schema_name}:${relay_remote}"
else
upgrade_db "$file" "$schema"
fi
# Set the owner of the ovn_dbdir (with -R option) to OVN_USER if set.
# This is required because the ovndbs are created with root permission
# if not present when create_cluster/upgrade_db is called.
INSTALL_USER="$(id -un)"
INSTALL_GROUP="$(id -gn)"
[ "$OVN_USER" != "" ] && INSTALL_USER="${OVN_USER%:*}"
[ "${OVN_USER##*:}" != "" ] && INSTALL_GROUP="${OVN_USER##*:}"
chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_dbdir
chown -R $INSTALL_USER:$INSTALL_GROUP $OVN_RUNDIR
chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_logdir
chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_etcdir
set ovsdb-server
set "$@" $log --log-file=$logfile
set "$@" --pidfile=$db_pid_file
if test X"$config_file" = X; then
set "$@" --remote=punix:$sock
else
set "$@" --config-file=$config_file
fi
set "$@" --unixctl=$ctrl_sock
[ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER"
if test X"$OVSDB_DISABLE_FILE_COLUMN_DIFF" = Xyes; then
(ovsdb-server --help | grep -q disable-file-column-diff) \
&& set "$@" --disable-file-column-diff
fi
if test X"$detach" != Xno; then
set "$@" --detach --monitor
else
set exec "$@"
fi
if test X"$use_remote_in_db" != Xno && test X"$config_file" = X; then
set "$@" --remote=db:$schema_name,$table_name,connections
fi
if test X"$ovn_db_ssl_key" != X; then
set "$@" --private-key=$ovn_db_ssl_key
else
set "$@" --private-key=db:$schema_name,SSL,private_key
fi
if test X"$ovn_db_ssl_cert" != X; then
set "$@" --certificate=$ovn_db_ssl_cert
else
set "$@" --certificate=db:$schema_name,SSL,certificate
fi
if test X"$ovn_db_ssl_cacert" != X; then
set "$@" --ca-cert=$ovn_db_ssl_cacert
else
set "$@" --ca-cert=db:$schema_name,SSL,ca_cert
fi
if test X"$ovn_db_ssl_protocols" != X; then
set "$@" --ssl-protocols=$ovn_db_ssl_protocols
else
set "$@" --ssl-protocols=db:$schema_name,SSL,ssl_protocols
fi
if test X"$ovn_db_ssl_ciphers" != X; then
set "$@" --ssl-ciphers=$ovn_db_ssl_ciphers
else
set "$@" --ssl-ciphers=db:$schema_name,SSL,ssl_ciphers
fi
if test X"$create_insecure_remote" = Xyes; then
set "$@" --remote=ptcp:$port:$addr
fi
if test $mode = active_passive; then
set "$@" --sync-from=`cat $active_conf_file`
fi
if test X"$extra_args" != X; then
set "$@" $extra_args
fi
local run_ovsdb_in_bg="no"
local process_id=
if test X$config_file = X; then
set "$@" "$file"
fi
if test X$detach = Xno && test $mode = cluster && test -z "$cluster_remote_addr" ; then
# When detach is no (for run_nb_ovsdb/run_sb_ovsdb commands)
# we want to run ovsdb-server in background rather than running it in
# foreground so that the OVN dbs are upgraded for the cluster mode.
# Otherwise, CMS has to take the responsibility of upgrading the dbs.
# Note: We run only the ovsdb-server in backgroud which created the
# cluster (i.e cluster_remote_addr is not set.).
run_ovsdb_in_bg="yes"
"$@" &
process_id=$!
else
start_wrapped_daemon "$wrapper" ovsdb-$db "" "$@"
fi
# Initialize the database if it's NOT joining a cluster.
if test -z "$cluster_remote_addr" && test X$mode != Xrelay; then
$(echo ovn-${db}ctl | tr _ -) --no-leader-only --db="unix:$sock" init
fi
if test $mode = cluster && test X"$cluster_db_upgrade" = Xyes; then
upgrade_cluster "$schema" "unix:$sock"
fi
if test $run_ovsdb_in_bg = yes; then
wait $process_id
fi
}
start_nb_ovsdb() {
start_ovsdb__ NB nb OVN_Northbound NB_Global "$OVSDB_NB_WRAPPER"
}
start_sb_relay_ovsdb() {
RELAY_MODE=yes
start_ovsdb__ SB_RELAY sb-relay OVN_Southbound SB_Global
}
start_sb_ovsdb() {
# Increase the limit on the number of open file descriptors, because
# SB DB may connect to large number of chassises, on top of connections
# for cluster members, northd, and serveral local unix sockets.
MAXFD=8192
if [ $(ulimit -n) -lt $MAXFD ]; then
ulimit -n $MAXFD
fi
start_ovsdb__ SB sb OVN_Southbound SB_Global "$OVSDB_SB_WRAPPER"
}
start_ovsdb () {
start_nb_ovsdb
start_sb_ovsdb
}
start_ic_nb_ovsdb() {
start_ovsdb__ IC_NB ic_nb OVN_IC_Northbound IC_NB_Global \
"$OVSDB_NB_WRAPPER"
}
start_ic_sb_ovsdb() {
start_ovsdb__ IC_SB ic_sb OVN_IC_Southbound IC_SB_Global \
"$OVSDB_SB_WRAPPER"
}
start_ic_ovsdb () {
start_ic_nb_ovsdb
start_ic_sb_ovsdb
}
sync_status() {
local ctl_file=$1
ovn-appctl -t $ctl_file ovsdb-server/sync-status | awk '{if(NR==1) print $2}'
}
status_ovnnb() {
if ! pidfile_is_running $DB_NB_PIDFILE; then
echo "not-running"
else
echo "running/$(sync_status $DB_NB_CTRL_SOCK)"
fi
}
status_ovnsb() {
if ! pidfile_is_running $DB_SB_PIDFILE; then
echo "not-running"
else
echo "running/$(sync_status $DB_SB_CTRL_SOCK)"
fi
}
status_ovsdb () {
if ! pidfile_is_running $DB_NB_PIDFILE; then
log_success_msg "OVN Northbound DB is not running"
else
log_success_msg "OVN Northbound DB is running"
fi
if ! pidfile_is_running $DB_SB_PIDFILE; then
log_success_msg "OVN Southbound DB is not running"
else
log_success_msg "OVN Southbound DB is running"
fi
}
status_ic_nb() {
if ! pidfile_is_running $DB_IC_NB_PIDFILE; then
echo "not-running"
else
echo "running/$(sync_status $DB_IC_NB_CTRL_SOCK)"
fi
}
status_ic_sb() {
if ! pidfile_is_running $DB_IC_SB_PIDFILE; then
echo "not-running"
else
echo "running/$(sync_status $DB_IC_SB_CTRL_SOCK)"
fi
}
status_ic_ovsdb () {
if ! pidfile_is_running $DB_IC_NB_PIDFILE; then
log_success_msg "OVN IC-Northbound DB is not running"
else
log_success_msg "OVN IC-Northbound DB is running"
fi
if ! pidfile_is_running $DB_IC_SB_PIDFILE; then
log_success_msg "OVN IC-Southbound DB is not running"
else
log_success_msg "OVN IC-Southbound DB is running"
fi
}
run_nb_ovsdb() {
DB_NB_DETACH=no
start_nb_ovsdb
}
run_sb_ovsdb() {
DB_SB_DETACH=no
start_sb_ovsdb
}
run_ic_nb_ovsdb() {
DB_IC_NB_DETACH=no
start_ic_nb_ovsdb
}
run_ic_sb_ovsdb() {
DB_IC_SB_DETACH=no
start_ic_sb_ovsdb
}
start_northd () {
if [ ! -e $ovn_northd_db_conf_file ]; then
if test X"$OVN_MANAGE_OVSDB" = Xyes; then
start_ovsdb
if ! pidfile_is_running $DB_NB_PIDFILE; then
log_failure_msg "OVN Northbound DB is not running"
exit
fi
if ! pidfile_is_running $DB_SB_PIDFILE; then
log_failure_msg "OVN Southbound DB is not running"
exit
fi
fi
ovn_northd_params="--ovnnb-db=$OVN_NORTHD_NB_DB \
--ovnsb-db=$OVN_NORTHD_SB_DB"
else
ovn_northd_params="`cat $ovn_northd_db_conf_file`"
fi
if daemon_is_running $OVN_NORTHD_BIN; then
log_success_msg "$OVN_NORTHD_BIN is already running"
else
set $OVN_NORTHD_BIN
if test X"$OVN_NORTHD_LOGFILE" != X; then
set "$@" --log-file=$OVN_NORTHD_LOGFILE
fi
if test X"$OVN_NORTHD_SSL_KEY" != X; then
set "$@" --private-key=$OVN_NORTHD_SSL_KEY
fi
if test X"$OVN_NORTHD_SSL_CERT" != X; then
set "$@" --certificate=$OVN_NORTHD_SSL_CERT
fi
if test X"$OVN_NORTHD_SSL_CA_CERT" != X; then
set "$@" --ca-cert=$OVN_NORTHD_SSL_CA_CERT
fi
if test "$OVN_NORTHD_N_THREADS" != 1; then
set "$@" --n-threads=$OVN_NORTHD_N_THREADS
fi
if test X"$OVN_NORTHD_SSL_PROTOCOLS" != X; then
set "$@" --ssl-protocols=$OVN_NORTHD_SSL_PROTOCOLS
fi
if test X"$OVN_NORTHD_SSL_CIPHERS" != X; then
set "$@" --ssl-ciphers=$OVN_NORTHD_SSL_CIPHERS
fi
[ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER"
set "$@" $OVN_NORTHD_LOG $ovn_northd_params
OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@"
fi
}
start_ic () {
if [ ! -e $ovn_ic_db_conf_file ]; then
ovn_ic_params="--ovnnb-db=$OVN_NORTHD_NB_DB \
--ovnsb-db=$OVN_NORTHD_SB_DB \
--ic-nb-db=$OVN_IC_NB_DB \
--ic-sb-db=$OVN_IC_SB_DB"
else
ovn_ic_params="`cat $ovn_ic_db_conf_file`"
fi
if daemon_is_running ovn-ic; then
log_success_msg "ovn-ic is already running"
else
set ovn-ic
if test X"$OVN_IC_LOGFILE" != X; then
set "$@" --log-file=$OVN_IC_LOGFILE
fi
if test X"$OVN_IC_SSL_KEY" != X; then
set "$@" --private-key=$OVN_IC_SSL_KEY
fi
if test X"$OVN_IC_SSL_CERT" != X; then
set "$@" --certificate=$OVN_IC_SSL_CERT
fi
if test X"$OVN_IC_SSL_CA_CERT" != X; then
set "$@" --ca-cert=$OVN_IC_SSL_CA_CERT
fi
if test X"$OVN_IC_SSL_PROTOCOLS" != X; then
set "$@" --ssl-protocols=$OVN_IC_SSL_PROTOCOLS
fi
if test X"$OVN_IC_SSL_CIPHERS" != X; then
set "$@" --ssl-ciphers=$OVN_IC_SSL_CIPHERS
fi
[ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER"
set "$@" $OVN_IC_LOG $ovn_ic_params
if test X"$extra_args" != X; then
set "$@" $extra_args
fi
OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_IC_PRIORITY" "$OVN_IC_WRAPPER" "$@"
fi
}
start_controller () {
set ovn-controller "unix:$DB_SOCK"
set "$@" $OVN_CONTROLLER_LOG
if test X"$OVN_CONTROLLER_SSL_KEY" != X; then
set "$@" --private-key=$OVN_CONTROLLER_SSL_KEY
fi
if test X"$OVN_CONTROLLER_SSL_CERT" != X; then
set "$@" --certificate=$OVN_CONTROLLER_SSL_CERT
fi
if test X"$OVN_CONTROLLER_SSL_CA_CERT" != X; then
set "$@" --ca-cert=$OVN_CONTROLLER_SSL_CA_CERT
fi
if test X"$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT" != X; then
set "$@" --bootstrap-ca-cert=$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT
fi
if test X"$OVN_CONTROLLER_SSL_PROTOCOLS" != X; then
set "$@" --ssl-protocols=$OVN_CONTROLLER_SSL_PROTOCOLS
fi
if test X"$OVN_CONTROLLER_SSL_CIPHERS" != X; then
set "$@" --ssl-ciphers=$OVN_CONTROLLER_SSL_CIPHERS
fi
[ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER"
if test X"$extra_args" != X; then
set "$@" $extra_args
fi
OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"
}
start_controller_vtep () {
set ovn-controller-vtep
set "$@" -vconsole:emer -vsyslog:err -vfile:info
if test X"$OVN_CONTROLLER_SSL_KEY" != X; then
set "$@" --private-key=$OVN_CONTROLLER_SSL_KEY
fi
if test X"$OVN_CONTROLLER_SSL_CERT" != X; then
set "$@" --certificate=$OVN_CONTROLLER_SSL_CERT
fi
if test X"$OVN_CONTROLLER_SSL_CA_CERT" != X; then
set "$@" --ca-cert=$OVN_CONTROLLER_SSL_CA_CERT
fi
if test X"$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT" != X; then
set "$@" --bootstrap-ca-cert=$OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT
fi
if test X"$OVN_CONTROLLER_SSL_PROTOCOLS" != X; then
set "$@" --ssl-protocols=$OVN_CONTROLLER_SSL_PROTOCOLS
fi
if test X"$OVN_CONTROLLER_SSL_CIPHERS" != X; then
set "$@" --ssl-ciphers=$OVN_CONTROLLER_SSL_CIPHERS
fi
if test X"$DB_SOCK" != X; then
set "$@" --vtep-db=$DB_SOCK
fi
if test X"$DB_SB_SOCK" != X; then
set "$@" --ovnsb-db=$DB_SB_SOCK
fi
[ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER"
if test X"$extra_args" != X; then
set "$@" $extra_args
fi
OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"
}
## ---- ##
## stop ##
## ---- ##
stop_northd () {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon $OVN_NORTHD_BIN
if [ ! -e $ovn_northd_db_conf_file ]; then
if test X"$OVN_MANAGE_OVSDB" = Xyes; then
stop_ovsdb
fi
fi
}
stop_ic () {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-ic
}
stop_controller () {
set "ovn-controller" "" ""
if test X"$RESTART" = Xyes; then
set "$@" "--restart"
fi
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon "$@"
}
stop_controller_vtep () {
OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller-vtep
}
## ------- ##
## restart ##
## ------- ##
restart_northd () {
stop_northd
start_northd
}
restart_ic () {
stop_ic
start_ic
}
restart_controller () {
RESTART=yes
stop_controller
start_controller
}
restart_controller_vtep () {
stop_controller_vtep
start_controller_vtep
}
restart_ovsdb () {
stop_ovsdb
start_ovsdb
}
restart_nb_ovsdb () {
stop_nb_ovsdb
start_nb_ovsdb
}
restart_sb_ovsdb () {
stop_sb_ovsdb
start_sb_ovsdb
}
restart_ic_ovsdb () {
stop_ic_ovsdb
start_ic_ovsdb
}
restart_ic_nb_ovsdb () {
stop_ic_nb_ovsdb
start_ic_nb_ovsdb
}
restart_ic_sb_ovsdb () {
stop_ic_sb_ovsdb
start_ic_sb_ovsdb
}
restart_sb_relay_ovsdb() {
stop_sb_relay_ovsdb
start_sb_relay_ovsdb
}
## ---- ##
## main ##
## ---- ##
set_defaults () {
OVN_MANAGE_OVSDB=yes
RESTART=no
OVS_RUNDIR=${OVS_RUNDIR:-${rundir}}
OVN_RUNDIR=${OVN_RUNDIR:-${ovn_rundir}}
DB_NB_SOCK=$OVN_RUNDIR/ovnnb_db.sock
DB_NB_PIDFILE=$OVN_RUNDIR/ovnnb_db.pid
DB_NB_CTRL_SOCK=$OVN_RUNDIR/ovnnb_db.ctl
DB_NB_FILE=$ovn_dbdir/ovnnb_db.db
DB_NB_ADDR=0.0.0.0
DB_NB_PORT=6641
DB_NB_SYNC_FROM_PROTO=tcp
DB_NB_SYNC_FROM_ADDR=
DB_NB_SYNC_FROM_PORT=6641
DB_NB_PROBE_INTERVAL_TO_ACTIVE=60000
DB_NB_ELECTION_TIMER=
DB_NB_CONFIG_FILE=
DB_SB_SOCK=$OVN_RUNDIR/ovnsb_db.sock
DB_SB_PIDFILE=$OVN_RUNDIR/ovnsb_db.pid
DB_SB_CTRL_SOCK=$OVN_RUNDIR/ovnsb_db.ctl
DB_SB_FILE=$ovn_dbdir/ovnsb_db.db
DB_SB_ADDR=0.0.0.0
DB_SB_PORT=6642
DB_SB_SYNC_FROM_PROTO=tcp
DB_SB_SYNC_FROM_ADDR=
DB_SB_SYNC_FROM_PORT=6642
DB_SB_PROBE_INTERVAL_TO_ACTIVE=60000
DB_SB_ELECTION_TIMER=
DB_SB_CONFIG_FILE=
DB_IC_NB_SOCK=$OVN_RUNDIR/ovn_ic_nb_db.sock
DB_IC_NB_PIDFILE=$OVN_RUNDIR/ovn_ic_nb_db.pid
DB_IC_NB_CTRL_SOCK=$OVN_RUNDIR/ovn_ic_nb_db.ctl
DB_IC_NB_FILE=$ovn_dbdir/ovn_ic_nb_db.db
DB_IC_NB_ADDR=0.0.0.0
DB_IC_NB_PORT=6645
DB_IC_NB_SYNC_FROM_PROTO=tcp
DB_IC_NB_SYNC_FROM_ADDR=
DB_IC_NB_SYNC_FROM_PORT=6645
DB_IC_NB_CONFIG_FILE=
DB_IC_SB_SOCK=$OVN_RUNDIR/ovn_ic_sb_db.sock
DB_IC_SB_PIDFILE=$OVN_RUNDIR/ovn_ic_sb_db.pid
DB_IC_SB_CTRL_SOCK=$OVN_RUNDIR/ovn_ic_sb_db.ctl
DB_IC_SB_FILE=$ovn_dbdir/ovn_ic_sb_db.db
DB_IC_SB_ADDR=0.0.0.0
DB_IC_SB_PORT=6646
DB_IC_SB_SYNC_FROM_PROTO=tcp
DB_IC_SB_SYNC_FROM_ADDR=
DB_IC_SB_SYNC_FROM_PORT=6646
DB_IC_SB_CONFIG_FILE=
DB_NB_SCHEMA=$ovn_datadir/ovn-nb.ovsschema
DB_SB_SCHEMA=$ovn_datadir/ovn-sb.ovsschema
DB_IC_NB_SCHEMA=$ovn_datadir/ovn-ic-nb.ovsschema
DB_IC_SB_SCHEMA=$ovn_datadir/ovn-ic-sb.ovsschema
DB_SOCK=$OVS_RUNDIR/db.sock
DB_CONF_FILE=$dbdir/conf.db
OVN_NORTHD_PRIORITY=-10
OVN_NORTHD_WRAPPER=
OVN_IC_PRIORITY=-10
OVN_IC_WRAPPER=
OVN_CONTROLLER_PRIORITY=-10
OVN_CONTROLLER_WRAPPER=
OVSDB_NB_WRAPPER=
OVSDB_SB_WRAPPER=
OVSDB_DISABLE_FILE_COLUMN_DIFF=no
OVN_USER=
OVN_CONTROLLER_LOG="-vconsole:emer -vsyslog:err -vfile:info"
OVN_NORTHD_LOG="-vconsole:emer -vsyslog:err -vfile:info"
OVN_NORTHD_LOGFILE=""
OVN_NORTHD_N_THREADS=1
OVN_IC_LOG="-vconsole:emer -vsyslog:err -vfile:info"
OVN_IC_LOGFILE=""
OVN_NB_LOG="-vconsole:off -vfile:info"
OVN_SB_LOG="-vconsole:off -vfile:info"
OVN_NB_LOGFILE="$ovn_logdir/ovsdb-server-nb.log"
OVN_SB_LOGFILE="$ovn_logdir/ovsdb-server-sb.log"
OVN_IC_NB_LOG="-vconsole:off -vfile:info"
OVN_IC_SB_LOG="-vconsole:off -vfile:info"
OVN_IC_NB_LOGFILE="$ovn_logdir/ovsdb-server-ic-nb.log"
OVN_IC_SB_LOGFILE="$ovn_logdir/ovsdb-server-ic-sb.log"
OVN_SB_RELAY_LOG="-vconsole:emer -vsyslog:err -vfile:info"
OVN_SB_RELAY_LOGFILE="$ovn_logdir/ovsdb-server-sb-relay.log"
OVN_CONTROLLER_SSL_KEY=""
OVN_CONTROLLER_SSL_CERT=""
OVN_CONTROLLER_SSL_CA_CERT=""
OVN_CONTROLLER_SSL_BOOTSTRAP_CA_CERT=""
OVN_CONTROLLER_SSL_PROTOCOLS=""
OVN_CONTROLLER_SSL_CIPHERS=""
OVN_NORTHD_SSL_KEY=""
OVN_NORTHD_SSL_CERT=""
OVN_NORTHD_SSL_CA_CERT=""
OVN_NORTHD_SSL_PROTOCOLS=""
OVN_NORTHD_SSL_CIPHERS=""
OVN_IC_SSL_KEY=""
OVN_IC_SSL_CERT=""
OVN_IC_SSL_CA_CERT=""
OVN_IC_SSL_PROTOCOLS=""
OVN_IC_SSL_CIPHERS=""
DB_SB_CREATE_INSECURE_REMOTE="no"
DB_NB_CREATE_INSECURE_REMOTE="no"
DB_IC_SB_CREATE_INSECURE_REMOTE="no"
DB_IC_NB_CREATE_INSECURE_REMOTE="no"
MONITOR="yes"
DB_NB_DETACH="yes"
DB_SB_DETACH="yes"
DB_IC_NB_DETACH="yes"
DB_IC_SB_DETACH="yes"
DB_NB_CLUSTER_LOCAL_ADDR=""
DB_NB_CLUSTER_LOCAL_PROTO="tcp"
DB_NB_CLUSTER_LOCAL_PORT=6643
DB_NB_CLUSTER_REMOTE_ADDR=""
DB_NB_CLUSTER_REMOTE_PROTO="tcp"
DB_NB_CLUSTER_REMOTE_PORT=6643
DB_SB_CLUSTER_LOCAL_ADDR=""
DB_SB_CLUSTER_LOCAL_PROTO="tcp"
DB_SB_CLUSTER_LOCAL_PORT=6644
DB_SB_CLUSTER_REMOTE_ADDR=""
DB_SB_CLUSTER_REMOTE_PROTO="tcp"
DB_SB_CLUSTER_REMOTE_PORT=6644
DB_IC_NB_CLUSTER_LOCAL_ADDR=""
DB_IC_NB_CLUSTER_LOCAL_PROTO="tcp"
DB_IC_NB_CLUSTER_LOCAL_PORT=6647
DB_IC_NB_CLUSTER_REMOTE_ADDR=""
DB_IC_NB_CLUSTER_REMOTE_PROTO="tcp"
DB_IC_NB_CLUSTER_REMOTE_PORT=6647
DB_IC_SB_CLUSTER_LOCAL_ADDR=""
DB_IC_SB_CLUSTER_LOCAL_PROTO="tcp"
DB_IC_SB_CLUSTER_LOCAL_PORT=6648
DB_IC_SB_CLUSTER_REMOTE_ADDR=""
DB_IC_SB_CLUSTER_REMOTE_PROTO="tcp"
DB_IC_SB_CLUSTER_REMOTE_PORT=6648
OVN_NORTHD_NB_DB="unix:$DB_NB_SOCK"
OVN_NORTHD_SB_DB="unix:$DB_SB_SOCK"
DB_NB_USE_REMOTE_IN_DB="yes"
DB_SB_USE_REMOTE_IN_DB="yes"
OVN_IC_NB_DB="unix:$DB_IC_NB_SOCK"
OVN_IC_SB_DB="unix:$DB_IC_SB_SOCK"
DB_IC_NB_USE_REMOTE_IN_DB="yes"
DB_IC_SB_USE_REMOTE_IN_DB="yes"
OVN_NB_DB_SSL_KEY=""
OVN_NB_DB_SSL_CERT=""
OVN_NB_DB_SSL_CA_CERT=""
OVN_NB_DB_SSL_PROTOCOLS=""
OVN_NB_DB_SSL_CIPHERS=""
OVN_SB_DB_SSL_KEY=""
OVN_SB_DB_SSL_CERT=""
OVN_SB_DB_SSL_CA_CERT=""
OVN_SB_DB_SSL_PROTOCOLS=""
OVN_SB_DB_SSL_CIPHERS=""
OVN_IC_NB_DB_SSL_KEY=""
OVN_IC_NB_DB_SSL_CERT=""
OVN_IC_NB_DB_SSL_CA_CERT=""
OVN_IC_NB_DB_SSL_PROTOCOLS=""
OVN_IC_NB_DB_SSL_CIPHERS=""
OVN_IC_SB_DB_SSL_KEY=""
OVN_IC_SB_DB_SSL_CERT=""
OVN_IC_SB_DB_SSL_CA_CERT=""
OVN_IC_SB_DB_SSL_PROTOCOLS=""
OVN_IC_SB_DB_SSL_CIPHERS=""
RELAY_MODE=no
DB_SB_RELAY_REMOTE=
DB_SB_RELAY_SOCK=$OVN_RUNDIR/ovnsb_relay_db.sock
DB_SB_RELAY_PIDFILE=$OVN_RUNDIR/ovnsb_relay_db.pid
DB_SB_RELAY_CTRL_SOCK=$OVN_RUNDIR/ovnsb_relay_db.ctl
OVN_SB_RELAY_DB_SSL_KEY=""
OVN_SB_RELAY_DB_SSL_CERT=""
OVN_SB_RELAY_DB_SSL_CA_CERT=""
DB_SB_RELAY_USE_REMOTE_IN_DB="yes"
DB_SB_RELAY_CONFIG_FILE=
DB_CLUSTER_SCHEMA_UPGRADE="yes"
}
set_option () {
var=`echo "$option" | tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
eval set=\${$var+yes}
eval old_value=\$$var
if test X$set = X || \
(test $type = bool && \
test X"$old_value" != Xno && test X"$old_value" != Xyes); then
echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
return
fi
eval $var=\$value
}
usage () {
set_defaults
cat << EOF
$0: controls Open Virtual Network daemons
usage: $0 [OPTIONS] COMMAND
This program is intended to be invoked internally by Open Virtual Network
startup scripts. System administrators should not normally invoke it directly.
Commands:
start_northd start ovn-northd
start_ovsdb start ovn related ovsdb-server processes
start_nb_ovsdb start ovn northbound db ovsdb-server process