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
74 # This option-parsing mechanism borrowed from a Autoconf-generated
75 # configure script under the following license:
77 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
78 # 2002, 2003, 2004, 2005, 2006, 2009, 2013 Free Software Foundation, Inc.
79 # This configure script is free software; the Free Software Foundation
80 # gives unlimited permission to copy, distribute and modify it.
82 # If the previous option needs an argument, assign it.
83 if test -n "$prev"; then
89 *=*) optarg
=`expr "X$option" : '[^=]*=\(.*\)'` ;;
93 case $dashdash$option in
98 ovs-sandbox, for starting a sandboxed dummy Open vSwitch environment
101 If you run ovs-sandbox from an OVS build directory, it uses the OVS that
102 you built. Otherwise, if you have an installed Open vSwitch, it uses
103 the installed version.
105 These options force ovs-sandbox to use a particular OVS build:
106 -b, --builddir=DIR specify Open vSwitch build directory
107 -s, --srcdir=DIR specify Open vSwitch source directory
108 These options force ovs-sandbox to use an installed Open vSwitch:
109 -i, --installed use installed Open vSwitch
110 -g, --gdb-vswitchd run ovs-vswitchd under gdb
111 -d, --gdb-ovsdb run ovsdb-server under gdb
112 --gdb-ovn-northd run ovn-northd under gdb
113 --gdb-ovn-controller run ovn-controller under gdb
114 --gdb-ovn-controller-vtep run ovn-controller-vtep under gdb
115 -R, --gdb-run automatically start running the daemon in gdb
116 for any daemon set to run under gdb
117 -S, --schema=FILE use FILE as vswitch.ovsschema
121 -h, --help Print this usage message.
155 gdb_vswitchd_ex
=false
172 --gdb-ovn-controller)
173 gdb_ovn_controller
=true
175 --gdb-ovn-controller-vtep)
176 gdb_ovn_controller_vtep
=true
184 gdb_ovn_northd_ex
=true
185 gdb_ovn_controller_ex
=true
186 gdb_ovn_controller_vtep_ex
=true
189 echo "unrecognized option $option (use --help for help)" >&2
193 echo "$option: non-option arguments not supported (use --help for help)" >&2
200 if $installed && $built; then
201 echo "sorry, conflicting options (use --help for help)" >&2
203 elif $installed ||
$built; then
205 elif test -e vswitchd
/ovs-vswitchd
; then
208 elif (ovs-vswitchd
--version) >/dev
/null
2>&1; then
211 echo "can't find an OVS build or install (use --help for help)" >&2
216 if test ! -e "$builddir"/vswitchd
/ovs-vswitchd
; then
217 echo "$builddir does not appear to be an OVS build directory" >&2
220 builddir
=`cd $builddir && pwd`
226 if test ! -e "$srcdir"/WHY-OVS.rst
; then
227 srcdir
=`cd $builddir/.. && pwd`
231 *) srcdir
=`pwd`/$srcdir ;;
233 schema
=$srcdir/vswitchd
/vswitch.ovsschema
234 if test ! -e "$schema"; then
235 echo >&2 'source directory not found, please use --srcdir'
239 ovnsb_schema
=$srcdir/ovn
/ovn-sb.ovsschema
240 if test ! -e "$ovnsb_schema"; then
241 echo >&2 'source directory not found, please use --srcdir'
244 ovnnb_schema
=$srcdir/ovn
/ovn-nb.ovsschema
245 if test ! -e "$ovnnb_schema"; then
246 echo >&2 'source directory not found, please use --srcdir'
249 vtep_schema
=$srcdir/vtep
/vtep.ovsschema
250 if test ! -e "$vtep_schema"; then
251 echo >&2 'source directory not found, please use --srcdir'
256 # Put built tools early in $PATH.
257 if test ! -e $builddir/vswitchd
/ovs-vswitchd
; then
258 echo >&2 'build not found, please change set $builddir or change directory'
261 PATH
=$builddir/ovsdb
:$builddir/vswitchd
:$builddir/utilities
:$builddir/vtep
:$PATH
263 PATH
=$builddir/ovn
/controller
:$builddir/ovn
/controller-vtep
:$builddir/ovn
/northd
:$builddir/ovn
/utilities
:$PATH
270 /usr
/local
/share
/openvswitch
/vswitch.ovsschema \
271 /usr
/share
/openvswitch
/vswitch.ovsschema \
273 if test -r $schema; then
279 *) schema
=`pwd`/$schema ;;
281 if test ! -r "$schema"; then
282 echo "can't find vswitch.ovsschema, please specify --schema" >&2
286 echo "running with ovn is only supported from the build dir." >&2
294 sandbox
=`cd sandbox && pwd`
296 # Set up environment for OVS programs to sandbox themselves.
297 OVS_RUNDIR
=$sandbox; export OVS_RUNDIR
298 OVS_LOGDIR
=$sandbox; export OVS_LOGDIR
299 OVS_DBDIR
=$sandbox; export OVS_DBDIR
300 OVS_SYSCONFDIR
=$sandbox; export OVS_SYSCONFDIR
303 # Easy access to OVS manpages.
304 (cd "$builddir" && ${MAKE-make} install-man mandir
="$sandbox"/man
)
305 MANPATH
=$sandbox/man
:; export MANPATH
309 trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15
311 # Create database and start ovsdb-server.
312 touch "$sandbox"/.conf.db.~lock~
313 run ovsdb-tool create conf.db
"$schema"
316 touch "$sandbox"/.ovnsb.db.~lock~
317 touch "$sandbox"/.ovnnb.db.~lock~
318 run ovsdb-tool create ovnsb.db
"$ovnsb_schema"
319 run ovsdb-tool create ovnsb2.db
"$ovnsb_schema"
320 run ovsdb-tool create ovnnb.db
"$ovnnb_schema"
321 run ovsdb-tool create vtep.db
"$vtep_schema"
322 ovsdb_server_args
="vtep.db conf.db"
323 ovsdb_sb_server_args
="ovnsb.db"
324 ovsdb_sb_backup_server_args
="ovnsb2.db"
325 ovsdb_nb_server_args
="ovnnb.db"
327 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir --pidfile -vconsole:off
--log-file \
328 --remote=punix
:"$sandbox"/db.sock
$ovsdb_server_args
330 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir \
331 --pidfile="$sandbox"/ovnnb_db.pid
-vconsole:off \
332 --log-file="$sandbox"/ovnnb_db.log \
333 --remote=punix
:"$sandbox"/ovnnb_db.sock
$ovsdb_nb_server_args
334 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir \
335 --pidfile="$sandbox"/ovnsb_db.pid
-vconsole:off \
336 --log-file="$sandbox"/ovnsb_db.log \
337 --remote=punix
:"$sandbox"/ovnsb_db.sock
$ovsdb_sb_server_args
338 # Start SB back up server
339 rungdb
$gdb_ovsdb $gdb_ovsdb_ex ovsdb-server
--detach --no-chdir \
340 --pidfile="$sandbox"/ovnsb_db2.pid
-vconsole:off \
341 --log-file="$sandbox"/ovnsb_db2.log \
342 --remote=punix
:"$sandbox"/ovnsb_db2.sock \
343 --unixctl="$sandbox"/sb_backup_unixctl \
344 --sync-from=unix
:"$sandbox"/ovnsb_db.sock
$ovsdb_sb_backup_server_args
347 #Add a small delay to allow ovsdb-server to launch.
350 #Wait for ovsdb-server to finish launching.
351 if test ! -e "$sandbox"/db.sock
; then
352 echo -n "Waiting for ovsdb-server to start..."
353 while test ! -e "$sandbox"/db.sock
; do
359 # Initialize database.
360 run ovs-vsctl
--no-wait -- init
362 # Start ovs-vswitchd.
363 rungdb
$gdb_vswitchd $gdb_vswitchd_ex ovs-vswitchd
--detach --no-chdir --pidfile -vconsole:off
--log-file \
364 --enable-dummy=override
-vvconn -vnetdev_dummy
367 ovs-vsctl
set open . external-ids
:system-id
=56b18105-5706-46ef-80c4-ff20979ab068
368 ovs-vsctl
set open . external-ids
:hostname
=sandbox
369 ovs-vsctl
set open . external-ids
:ovn-remote
=unix
:"$sandbox"/ovnsb_db.sock
370 ovs-vsctl
set open . external-ids
:ovn-encap-type
=geneve
371 ovs-vsctl
set open . external-ids
:ovn-encap-ip
=127.0.0.1
376 rungdb
$gdb_ovn_northd $gdb_ovn_northd_ex ovn-northd
--detach \
377 --no-chdir --pidfile -vconsole:off
--log-file \
378 --ovnsb-db=unix
:"$sandbox"/ovnsb_db.sock \
379 --ovnnb-db=unix
:"$sandbox"/ovnnb_db.sock
380 rungdb
$gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \
381 --detach --no-chdir --pidfile -vconsole:off
--log-file
382 rungdb
$gdb_ovn_controller_vtep $gdb_ovn_controller_vtep_ex \
383 ovn-controller-vtep
--detach --no-chdir --pidfile -vconsole:off \
384 --log-file --ovnsb-db=unix
:"$sandbox"/ovnsb_db.sock
391 ----------------------------------------------------------------------
392 You are running in a dummy Open vSwitch environment. You can use
393 ovs-vsctl, ovs-ofctl, ovs-appctl, and other tools to work with the
397 if $ovn; then cat << EOF
398 This environment also has the OVN daemons and databases enabled.
399 You can use ovn-nbctl and ovn-sbctl to interact with the OVN databases.
401 The backup server of OVN SB can be accessed by:
402 * ovn-sbctl --db=unix:`pwd`/sandbox/ovnsb_db2.sock
403 * ovs-appctl -t `pwd`/sandbox/sb_backup_unixctl
404 The backup database file is "sandbox"/ovnsb2.db
410 Log files, pidfiles, and the configuration database are in the
411 "sandbox" subdirectory.
413 Exit the shell to kill the running daemons.
416 status
=0; $SHELL || status
=$?
419 ----------------------------------------------------------------------