~ubuntu-branches/ubuntu/wily/openvswitch/wily

« back to all changes in this revision

Viewing changes to tutorial/ovs-sandbox

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-08-10 11:35:15 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20150810113515-575vj06oq29emxsn
Tags: 2.4.0~git20150810.97bab95-0ubuntu1
* New upstream snapshot from 2.4 branch:
  - d/*: Align any relevant packaging changes with upstream.
* d/*: wrap-and-sort.
* d/openvswitch-{common,vswitch}.install: Correct install location for
  bash completion files.
* d/tests/openflow.py: Explicitly use ovs-testcontroller as provided
  by 2.4.0 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
#
3
 
# Copyright (c) 2013 Nicira, Inc.
 
3
# Copyright (c) 2013, 2015 Nicira, Inc.
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
16
16
 
17
17
set -e
18
18
 
19
 
run () {
20
 
    echo "$@"
 
19
run() {
21
20
    (cd "$sandbox" && "$@") || exit 1
22
21
}
23
22
 
 
23
run_xterm() {
 
24
    title=$1;
 
25
    shift
 
26
    run xterm -T "$title" -e "$@"  &
 
27
}
 
28
 
 
29
rungdb() {
 
30
    under_gdb=$1
 
31
    gdb_run=$2
 
32
    shift
 
33
    shift
 
34
 
 
35
    # Remove the --detach and to put the process under gdb control.
 
36
    # Also remove --vconsole:off to allow error message to show up
 
37
    # on the console.
 
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`
 
41
        xterm_title=$1
 
42
 
 
43
        gdb_cmd=""
 
44
        if $gdb_run; then
 
45
            gdb_cmd="-ex run"
 
46
        fi
 
47
 
 
48
        run_xterm $xterm_title gdb $gdb_cmd --args $args
 
49
    else
 
50
        run $@
 
51
    fi
 
52
}
 
53
 
 
54
gdb_vswitchd=false
 
55
gdb_ovsdb=false
 
56
gdb_vswitchd_ex=false
 
57
gdb_ovsdb_ex=false
24
58
builddir=
25
59
srcdir=
26
60
schema=
27
61
installed=false
28
62
built=false
 
63
 
29
64
for option; do
30
65
    # This option-parsing mechanism borrowed from a Autoconf-generated
31
66
    # configure script under the following license:
63
98
  -s, --srcdir=DIR     specify Open vSwitch source directory
64
99
These options force ovs-sandbox to use an installed Open vSwitch:
65
100
  -i, --installed      use installed Open vSwitch
 
101
  -g, --gdb-vswitchd   run ovs-vswitchd under gdb
 
102
  -d, --gdb-ovsdb      run ovsdb-server under gdb
66
103
  -S, --schema=FILE    use FILE as vswitch.ovsschema
67
104
 
68
105
Other options:
98
135
            prev=schema
99
136
            installed=:
100
137
            ;;
 
138
        -g|--gdb-v*)
 
139
            gdb_vswitchd=true
 
140
            gdb_vswitchd_ex=false
 
141
            ;;
 
142
        -e|--gdb-ex-v*)
 
143
            gdb_vswitchd=true
 
144
            gdb_vswitchd_ex=true
 
145
            ;;
 
146
        -d|--gdb-o*)
 
147
            gdb_ovsdb=true
 
148
            gdb_ovsdb_ex=false
 
149
            ;;
 
150
        -r|--gdb-ex-o*)
 
151
            gdb_ovsdb=true
 
152
            gdb_ovsdb_ex=true
 
153
            ;;
101
154
        -*)
102
155
            echo "unrecognized option $option (use --help for help)" >&2
103
156
            exit 1
136
189
    case $srcdir in
137
190
        '')
138
191
            srcdir=$builddir
139
 
            if test ! -e "$srcdir"/WHY-OVS; then
 
192
            if test ! -e "$srcdir"/WHY-OVS.md; then
140
193
                srcdir=`cd $builddir/.. && pwd`
141
194
            fi
142
195
            ;;
190
243
 
191
244
if $built; then
192
245
    # Easy access to OVS manpages.
193
 
    (cd "$builddir" && make install-man mandir="$sandbox"/man)
 
246
    (cd "$builddir" && ${MAKE} install-man mandir="$sandbox"/man)
194
247
    MANPATH=$sandbox/man:; export MANPATH
195
248
fi
196
249
 
200
253
# Create database and start ovsdb-server.
201
254
touch "$sandbox"/.conf.db.~lock~
202
255
run ovsdb-tool create conf.db "$schema"
203
 
run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
 
256
rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
204
257
    --remote=punix:"$sandbox"/db.sock
205
258
 
 
259
#Add a small delay to allow ovsdb-server to launch.
 
260
sleep 0.1
 
261
 
 
262
#Wait for ovsdb-server to finish launching.
 
263
if test ! -e "$sandbox"/db.sock; then
 
264
    echo -n "Waiting for ovsdb-server to start..."
 
265
    while test ! -e "$sandbox"/db.sock; do
 
266
        sleep 1;
 
267
    done
 
268
    echo "  Done"
 
269
fi
 
270
 
 
271
# Initialize database.
 
272
run ovs-vsctl --no-wait -- init
 
273
 
206
274
# Start ovs-vswitchd.
207
 
run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
 
275
rungdb $gdb_vswitchd $gdb_vswitchd_ex ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
208
276
    --enable-dummy=override -vvconn -vnetdev_dummy
209
277
 
210
278
cat <<EOF