ovs-sandbox: Use new ovn-sb database name.
[cascardo/ovs.git] / tutorial / ovs-sandbox
index 5663acd..c299de0 100755 (executable)
@@ -21,7 +21,9 @@ run() {
 }
 
 run_xterm() {
-    run xterm -e "$@" &
+    title=$1;
+    shift
+    run xterm -T "$title" -e "$@"  &
 }
 
 rungdb() {
@@ -33,18 +35,24 @@ rungdb() {
     # Use "DISPLAY" variable to determine out if X is supported
     if $under_gdb && [ "$DISPLAY" ]; then
         args=`echo $@ |sed s/--detach//g | sed s/--vconsole:off//g`
-        run_xterm gdb --args $args
+        xterm_title=$1
+        run_xterm $xterm_title gdb --args $args
     else
         run $@
     fi
 }
 
-gdb_vswitchd=false;
+gdb_vswitchd=false
+gdb_ovsdb=false
+gdb_ovn_nbd=false
 builddir=
 srcdir=
 schema=
 installed=false
 built=false
+ovn=false
+ovnsb_schema=
+ovnnb_schema=
 
 for option; do
     # This option-parsing mechanism borrowed from a Autoconf-generated
@@ -84,7 +92,10 @@ These options force ovs-sandbox to use a particular OVS build:
 These options force ovs-sandbox to use an installed Open vSwitch:
   -i, --installed      use installed Open vSwitch
   -g, --gdb-vswitchd   run ovs-vswitchd under gdb
+  -d, --gdb-ovsdb      run ovsdb-server under gdb
+  --gdb-ovn-nbd        run ovn-nbd under gdb
   -S, --schema=FILE    use FILE as vswitch.ovsschema
+  -o, --ovn            enable OVN
 
 Other options:
   -h, --help           Print this usage message.
@@ -122,6 +133,15 @@ EOF
         -g|--gdb-v*)
             gdb_vswitchd=true
             ;;
+        -d|--gdb-ovsdb)
+            gdb_ovsdb=true
+            ;;
+        --gdb-ovn-nbd)
+            gdb_ovn_nbd=true
+            ;;
+        -o|--ovn)
+            ovn=true
+            ;;
         -*)
             echo "unrecognized option $option (use --help for help)" >&2
             exit 1
@@ -172,6 +192,18 @@ if $built; then
         echo >&2 'source directory not found, please use --srcdir'
         exit 1
     fi
+    if $ovn; then
+        ovnsb_schema=$srcdir/ovn/ovn-sb.ovsschema
+        if test ! -e "$ovnsb_schema"; then
+            echo >&2 'source directory not found, please use --srcdir'
+            exit 1
+        fi
+        ovnnb_schema=$srcdir/ovn/ovn-nb.ovsschema
+        if test ! -e "$ovnnb_schema"; then
+            echo >&2 'source directory not found, please use --srcdir'
+            exit 1
+        fi
+    fi
 
     # Put built tools early in $PATH.
     if test ! -e $builddir/vswitchd/ovs-vswitchd; then
@@ -179,6 +211,9 @@ if $built; then
         exit 1
     fi
     PATH=$builddir/ovsdb:$builddir/vswitchd:$builddir/utilities:$PATH
+    if $ovn; then
+        PATH=$builddir/ovn:$PATH
+    fi
     export PATH
 else
     case $schema in
@@ -199,6 +234,10 @@ else
         echo "can't find vswitch.ovsschema, please specify --schema" >&2
         exit 1
     fi
+    if $ovn; then
+        echo "running with ovn is only supported from the build dir." >&2
+        exit 1
+    fi
 fi
 
 # Create sandbox.
@@ -224,13 +263,25 @@ trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15
 # Create database and start ovsdb-server.
 touch "$sandbox"/.conf.db.~lock~
 run ovsdb-tool create conf.db "$schema"
-run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
-    --remote=punix:"$sandbox"/db.sock
+ovsdb_server_args=
+if $ovn; then
+    touch "$sandbox"/.ovnsb.db.~lock~
+    touch "$sandbox"/.ovnnb.db.~lock~
+    run ovsdb-tool create ovnsb.db "$ovnsb_schema"
+    run ovsdb-tool create ovnnb.db "$ovnnb_schema"
+    ovsdb_server_args="ovnsb.db ovnnb.db conf.db"
+fi
+rungdb $gdb_ovsdb ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
+    --remote=punix:"$sandbox"/db.sock $ovsdb_server_args
 
 # Start ovs-vswitchd.
 rungdb $gdb_vswitchd ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \
     --enable-dummy=override -vvconn -vnetdev_dummy
 
+if $ovn; then
+    rungdb $gdb_ovn_nbd ovn-nbd --detach --no-chdir --pidfile -vconsole:off --log-file
+fi
+
 cat <<EOF