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
36 action "Creating empty database $DB_FILE" ovsdb-tool create "$DB_FILE" "$DB_SCHEMA"
40 if test ! -e "$DB_NB_FILE"; then
41 create_db "$DB_NB_FILE" "$DB_NB_SCHEMA"
44 if test ! -e "$DB_SB_FILE"; then
45 create_db "$DB_SB_FILE" "$DB_SB_SCHEMA"
48 running_ovn_dbs=$(ovs-appctl -t ovsdb-server ovsdb-server/list-dbs | grep OVN | wc -l)
49 if [ "$running_ovn_dbs" != "2" ] ; then
50 ovs-appctl -t ovsdb-server ovsdb-server/add-db $DB_NB_FILE
51 ovs-appctl -t ovsdb-server ovsdb-server/add-db $DB_SB_FILE
52 running_ovn_dbs=$(ovs-appctl -t ovsdb-server ovsdb-server/list-dbs | grep OVN | wc -l)
53 if [ "$running_ovn_dbs" != "2" ] ; then
54 echo >&2 "$0: Failed to add OVN dbs to ovsdb-server"
61 # We expect ovn-northd to be co-located with ovsdb-server handling both the
62 # OVN_Northbound and OVN_Southbound dbs.
66 set "$@" -vconsole:emer -vsyslog:err -vfile:info
67 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@"
71 set ovn-controller "unix:$DB_SOCK"
72 set "$@" -vconsole:emer -vsyslog:err -vfile:info
73 OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"
81 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-northd
85 OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-controller
97 restart_controller () {
107 DB_SOCK=$rundir/db.sock
108 DB_NB_FILE=$dbdir/ovnnb.db
109 DB_SB_FILE=$dbdir/ovnsb.db
110 DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
111 DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
113 OVN_NORTHD_PRIORITY=-10
115 OVN_CONTROLLER_PRIORITY=-10
116 OVN_CONTROLLER_WRAPPER=
118 OVS_RUNDIR=${OVS_RUNDIR:-${rundir}}
119 OVN_RUNDIR=${OVN_RUNDIR:-${OVS_RUNDIR}}
123 var=`echo "$option" | tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
124 eval set=\${$var+yes}
125 eval old_value=\$$var
126 if test X$set = X || \
127 (test $type = bool && \
128 test X"$old_value" != Xno && test X"$old_value" != Xyes); then
129 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
138 $0: controls Open Virtual Network daemons
139 usage: $0 [OPTIONS] COMMAND
141 This program is intended to be invoked internally by Open Virtual Network
142 startup scripts. System administrators should not normally invoke it directly.
145 start_northd start ovn-northd
146 start_controller start ovn-controller
147 stop_northd stop ovn-northd
148 stop_controller stop ovn-controller
149 restart_northd restart ovn-northd
150 restart_controller restart ovn-controller
153 --ovn-northd-priority=NICE set ovn-northd's niceness (default: $OVN_NORTHD_PRIORITY)
154 --ovn-northd-wrapper=WRAPPER run with a wrapper like valgrind for debugging
155 --ovn-controller-priority=NICE set ovn-northd's niceness (default: $OVN_CONTROLLER_PRIORITY)
156 --ovn-controller-wrapper=WRAPPER run with a wrapper like valgrind for debugging
157 -h, --help display this help message
159 File location options:
160 --db-sock=SOCKET JSON-RPC socket name (default: $DB_SOCK)
161 --db-nb-file=FILE OVN_Northbound db file (default: $DB_NB_FILE)
162 --db-sb-file=FILE OVN_Southbound db file (default: $DB_SB_FILE)
163 --db-nb-schema=FILE OVN_Northbound db file (default: $DB_NB_SCHEMA)
164 --db-sb-schema=FILE OVN_Southbound db file (default: $DB_SB_SCHEMA)
166 Default directories with "configure" option and environment variable override:
167 logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
168 pidfiles and sockets: /usr/local/var/run/openvswitch (--with-rundir, OVS_RUNDIR)
169 ovn-nb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
170 ovn-sb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR)
171 system configuration: /usr/local/etc (--sysconfdir, OVS_SYSCONFDIR)
172 data files: /usr/local/share/openvswitch (--pkgdatadir, OVS_PKGDATADIR)
173 user binaries: /usr/local/bin (--bindir, OVS_BINDIR)
174 system binaries: /usr/local/sbin (--sbindir, OVS_SBINDIR)
187 option=`expr X"$arg" : 'X--\([^=]*\)'`
188 value=`expr X"$arg" : 'X[^=]*=\(.*\)'`
193 option=`expr X"$arg" : 'X--no-\(.*\)'`
199 option=`expr X"$arg" : 'X--\(.*\)'`
205 echo >&2 "$0: unknown option \"$arg\" (use --help for help)"
209 if test X"$command" = X; then
212 echo >&2 "$0: exactly one non-option argument required (use --help for help)"
241 echo >&2 "$0: preheating ovn to 350 degrees F."
245 echo >&2 "$0: missing command name (use --help for help)"
249 echo >&2 "$0: unknown command \"$command\" (use --help for help)"