3 # Copyright (c) 2013, 2015, 2016 Nicira, Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 (cd "$sandbox" && "$@") ||
exit 1
26 run xterm
-T "$title" -e "$@" &
35 # Remove the --detach and to put the process under gdb control.
36 # Also remove --vconsole:off to allow error message to show up
38 # Use "DISPLAY" variable to determine out if X is supported
39 if $under_gdb && [ "$DISPLAY" ]; then
40 args
=`echo $@ |sed s/--detach//g | sed s/--vconsole:off//g`
48 run_xterm
$xterm_title gdb
$gdb_cmd --args $args
59 gdb_ovn_northd_ex
=false
60 gdb_ovn_controller
=false
61 gdb_ovn_controller_ex
=false
62 gdb_ovn_controller_vtep
=false
63 gdb_ovn_controller_vtep_ex
=false
76 # This option-parsing mechanism borrowed from a Autoconf-generated
77 # configure script under the following license:
79 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
80 # 2002, 2003, 2004, 2005, 2006, 2009, 2013 Free Software Foundation, Inc.
81 # This configure script is free software; the Free Software Foundation
82 # gives unlimited permission to copy, distribute and modify it.
84 # If the previous option needs an argument, assign it.
85 if test -n "$prev"; then
91 *=*) optarg
=`expr "X$option" : '[^=]*=\(.*\)'` ;;
95 case $dashdash$option in
100 ovs-sandbox, for starting a sandboxed dummy Open vSwitch environment
101 usage: $0 [OPTION...]
103 If you run ovs-sandbox from an OVS build directory, it uses the OVS that
104 you built. Otherwise, if you have an installed Open vSwitch, it uses
105 the installed version.
107 These options force ovs-sandbox to use a particular OVS build:
108 -b, --builddir=DIR specify Open vSwitch build directory
109 -s, --srcdir=DIR specify Open vSwitch source directory
110 These options force ovs-sandbox to use an installed Open vSwitch:
111 -i, --installed use installed Open vSwitch
112 -g, --gdb-vswitchd run ovs-vswitchd under gdb
113 -d, --gdb-ovsdb run ovsdb-server under gdb
114 --gdb-ovn-northd run ovn-northd under gdb
115 --gdb-ovn-controller run ovn-controller under gdb
116 --gdb-ovn-controller-vtep run ovn-controller-vtep under gdb
117 --dummy=ARG pass --enable-dummy=ARG to vswitchd (default: override)
118 -R, --gdb-run automatically start running the daemon in gdb
119 for any daemon set to run under gdb
120 -S, --schema=FILE use FILE as vswitch.ovsschema
122 --no-ovn-rbac disable role-based access control for OVN
125 -h, --help Print this usage message.
165 gdb_vswitchd_ex
=false
182 --gdb-ovn-controller)
183 gdb_ovn_controller
=true
185 --gdb-ovn-controller-vtep)
186 gdb_ovn_controller_vtep
=true
197 gdb_ovn_northd_ex
=true
198 gdb_ovn_controller_ex
=true
199 gdb_ovn_controller_vtep_ex
=true
202 echo "unrecognized option $option (use --help for help)" >&2
206 echo "$option: non-option arguments not supported (use --help for help)" >&2
213 if $installed && $built; then
214 echo "sorry, conflicting options (use --help for help)" >&2
216 elif $installed ||
$built; then
218 elif test -e vswitchd
/ovs-vswitchd
; then
221 elif (ovs-vswitchd
--version) >/dev
/null
2>&1; then
224 echo "can't find an OVS build or install (use --help for help)" >&2
229 if test ! -e "$builddir"/vswitchd
/ovs-vswitchd
; then
230 echo "$builddir does not appear to be an OVS build directory" >&2
233 builddir
=`cd $builddir && pwd`
239 if test ! -e "$srcdir"/README.rst
; then
240 srcdir
=`cd $builddir/.. && pwd`
244 *) srcdir
=`pwd`/$srcdir ;;
246 schema
=$srcdir/vswitchd
/vswitch.ovsschema
247 if test ! -e "$schema"; then
248 echo >&2 'source directory not found, please use --srcdir'
252 ovnsb_schema
=$srcdir/ovn
/ovn-sb.ovsschema
253 if test ! -e "$ovnsb_schema"; then
254 echo >&2 'source directory not found, please use --srcdir'
257 ovnnb_schema
=$srcdir/ovn
/ovn-nb.ovsschema
258 if test ! -e "$ovnnb_schema"; then
259 echo >&2 'source directory not found, please use --srcdir'
262 vtep_schema
=$srcdir/vtep
/vtep.ovsschema
263 if test ! -e "$vtep_schema"; then
264 echo >&2 'source directory not found, please use --srcdir'
269 # Put built tools early in $PATH.
270 if test ! -e $builddir/vswitchd
/ovs-vswitchd
; then
271 echo >&2 'build not found, please change set $builddir or change directory'
274 PATH
=$builddir/ovsdb
:$builddir/vswitchd
:$builddir/utilities
:$builddir/vtep
:$PATH
276 PATH
=$builddir/ovn
/controller
:$builddir/ovn
/controller-vtep
:$builddir/ovn
/northd
:$builddir/ovn
/utilities
:$PATH
283 /usr
/local
/share
/openvswitch
/vswitch.ovsschema \
284 /usr
/share
/openvswitch
/vswitch.ovsschema \
286 if test -r $schema; then
292 *) schema
=`pwd`/$schema ;;
294 if test ! -r "$schema"; then
295 echo "can't find vswitch.ovsschema, please specify --schema" >&2
299 echo "running with ovn is only supported from the build dir." >&2
307 sandbox
=`cd sandbox && pwd`
309 # Set up environment for OVS programs to sandbox themselves.
310 OVS_RUNDIR
=$sandbox; export OVS_RUNDIR
311 OVS_LOGDIR
=$sandbox; export OVS_LOGDIR
312 OVS_DBDIR
=$sandbox; export OVS_DBDIR
313 OVS_SYSCONFDIR
=$sandbox; export OVS_SYSCONFDIR
316 # Easy access to OVS manpages.
317 (cd "$builddir" && ${MAKE-make} install-man mandir
="$sandbox"/man
)
318 MANPATH
=$sandbox/man
:; export MANPATH
322 trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15
324 # Create database and start ovsdb-server.
325 touch "$sandbox"/.conf.db.~lock~
326 run ovsdb-tool create conf.db
"$schema"
329 touch "$sandbox"/.ovnsb.db.~lock~
330 touch "$sandbox"/.ovnnb.db.~lock~
331 run ovsdb-tool create ovnsb.db
"$ovnsb_schema"
332 run ovsdb-tool create ovnsb2.db
"$ovnsb_schema"
333 run ovsdb-tool create ovnnb.db
"$ovnnb_schema"
334 run ovsdb-tool create vtep.db
"$vtep_schema"
335 ovsdb_server_args
="vtep.db conf.db"
336 ovsdb_sb_server_args
="ovnsb.db"
337 ovsdb_sb_backup_server_args
="ovnsb2.db"
338 ovsdb_nb_server_args
="ovnnb.db"
340 if [ "$HAVE_OPENSSL" = yes ]; then
341 OVS_PKI
="run ovs-pki --dir=$sandbox/pki --log=$sandbox/ovs-pki.log"
342 $OVS_PKI -B 1024 init
343 $OVS_PKI -B 1024 req
+sign ovnsb switch
344 $OVS_PKI -B 1024 req
+sign ovnnb switch
345 $OVS_PKI -B 1024 -u req
+sign chassis-1 switch
348 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir --pidfile -vconsole:off
--log-file \
349 --remote=punix
:"$sandbox"/db.sock
$ovsdb_server_args
351 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir \
352 --pidfile="$sandbox"/ovnnb_db.pid
-vconsole:off \
353 --log-file="$sandbox"/ovnnb_db.log \
354 --remote=db
:OVN_Northbound
,NB_Global
,connections \
355 --private-key=db
:OVN_Northbound
,SSL
,private_key \
356 --certificate=db
:OVN_Northbound
,SSL
,certificate \
357 --ca-cert=db
:OVN_Northbound
,SSL
,ca_cert \
358 --ssl-protocols=db
:OVN_Northbound
,SSL
,ssl_protocols \
359 --ssl-ciphers=db
:OVN_Northbound
,SSL
,ssl_ciphers \
360 --remote=punix
:"$sandbox"/ovnnb_db.sock
$ovsdb_nb_server_args
361 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir \
362 --pidfile="$sandbox"/ovnsb_db.pid
-vconsole:off \
363 --log-file="$sandbox"/ovnsb_db.log \
364 --remote=db
:OVN_Southbound
,SB_Global
,connections \
365 --private-key=db
:OVN_Southbound
,SSL
,private_key \
366 --certificate=db
:OVN_Southbound
,SSL
,certificate \
367 --ca-cert=db
:OVN_Southbound
,SSL
,ca_cert \
368 --ssl-protocols=db
:OVN_Southbound
,SSL
,ssl_protocols \
369 --ssl-ciphers=db
:OVN_Southbound
,SSL
,ssl_ciphers \
370 --remote=punix
:"$sandbox"/ovnsb_db.sock
$ovsdb_sb_server_args
371 # Start SB back up server
372 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir \
373 --pidfile="$sandbox"/ovnsb_db2.pid
-vconsole:off \
374 --log-file="$sandbox"/ovnsb_db2.log \
375 --private-key=db
:OVN_Southbound
,SSL
,private_key \
376 --certificate=db
:OVN_Southbound
,SSL
,certificate \
377 --ca-cert=db
:OVN_Southbound
,SSL
,ca_cert \
378 --remote=punix
:"$sandbox"/ovnsb_db2.sock \
379 --unixctl="$sandbox"/sb_backup_unixctl \
380 --sync-from=unix
:"$sandbox"/ovnsb_db.sock
$ovsdb_sb_backup_server_args
383 #Add a small delay to allow ovsdb-server to launch.
386 #Wait for ovsdb-server to finish launching.
387 if test ! -e "$sandbox"/db.sock
; then
388 echo -n "Waiting for ovsdb-server to start..."
389 while test ! -e "$sandbox"/db.sock
; do
395 # Initialize database.
396 run ovs-vsctl
--no-wait -- init
398 # Start ovs-vswitchd.
399 rungdb
$gdb_vswitchd $gdb_vswitchd_ex ovs-vswitchd
--detach --no-chdir --pidfile -vconsole:off
--log-file \
400 --enable-dummy=$dummy -vvconn -vnetdev_dummy
406 ovs-vsctl
set open . external-ids
:system-id
=chassis-1
407 ovs-vsctl
set open . external-ids
:hostname
=sandbox
408 ovs-vsctl
set open . external-ids
:ovn-encap-type
=geneve
409 ovs-vsctl
set open . external-ids
:ovn-encap-ip
=127.0.0.1
411 if [ "$HAVE_OPENSSL" = yes ]; then
412 ovn-nbctl set-ssl
$sandbox/ovnnb-privkey.pem
$sandbox/ovnnb-cert.pem
$sandbox/pki
/switchca
/cacert.pem
413 ovn-nbctl set-connection pssl
:6641
414 ovn-sbctl set-ssl
$sandbox/ovnsb-privkey.pem
$sandbox/ovnsb-cert.pem
$sandbox/pki
/switchca
/cacert.pem
416 ovn-sbctl set-connection role
=ovn-controller pssl
:6642
418 ovn-sbctl set-connection pssl
:6642
420 ovs-vsctl
set open . external-ids
:ovn-remote
=ssl
:127.0.0.1:6642
421 OVN_CTRLR_PKI
="-p $sandbox/chassis-1-privkey.pem -c $sandbox/chassis-1-cert.pem -C $sandbox/pki/switchca/cacert.pem"
423 ovs-vsctl
set open . external-ids
:ovn-remote
=unix
:"$sandbox"/ovnsb_db.sock
426 rungdb
$gdb_ovn_northd $gdb_ovn_northd_ex ovn-northd
--detach \
427 --no-chdir --pidfile -vconsole:off
--log-file \
428 --ovnsb-db=unix
:"$sandbox"/ovnsb_db.sock \
429 --ovnnb-db=unix
:"$sandbox"/ovnnb_db.sock
430 rungdb
$gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \
431 $OVN_CTRLR_PKI --detach --no-chdir --pidfile -vconsole:off
--log-file
432 rungdb
$gdb_ovn_controller_vtep $gdb_ovn_controller_vtep_ex \
433 ovn-controller-vtep
--detach --no-chdir --pidfile -vconsole:off \
434 $OVN_CTRLR_PKI --log-file --ovnsb-db=unix
:"$sandbox"/ovnsb_db.sock
441 ----------------------------------------------------------------------
442 You are running in a dummy Open vSwitch environment. You can use
443 ovs-vsctl, ovs-ofctl, ovs-appctl, and other tools to work with the
447 if $ovn; then cat << EOF
448 This environment also has the OVN daemons and databases enabled.
449 You can use ovn-nbctl and ovn-sbctl to interact with the OVN databases.
451 The backup server of OVN SB can be accessed by:
452 * ovn-sbctl --db=unix:`pwd`/sandbox/ovnsb_db2.sock
453 * ovs-appctl -t `pwd`/sandbox/sb_backup_unixctl
454 The backup database file is "sandbox"/ovnsb2.db
460 Log files, pidfiles, and the configuration database are in the
461 "sandbox" subdirectory.
463 Exit the shell to kill the running daemons.
466 status
=0; $SHELL || status
=$?
469 ----------------------------------------------------------------------