-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"
+ run ovsdb-tool create vtep.db "$vtep_schema"
+ ovsdb_server_args="ovnsb.db ovnnb.db vtep.db conf.db"
+fi
+rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
+ --remote=punix:"$sandbox"/db.sock $ovsdb_server_args
+
+#Add a small delay to allow ovsdb-server to launch.
+sleep 0.1
+
+#Wait for ovsdb-server to finish launching.
+if test ! -e "$sandbox"/db.sock; then
+ echo -n "Waiting for ovsdb-server to start..."
+ while test ! -e "$sandbox"/db.sock; do
+ sleep 1;
+ done
+ echo " Done"
+fi
+
+# Initialize database.
+run ovs-vsctl --no-wait -- init