@@ -106,7 +106,7 @@ RST_MANPAGES = \
# rST formatted manpages that we don't want to install because they
# document stuff that only works with a build tree, not with an
# installed OVS.
-RST_MANPAGES_NOINST = ovs-sim.1.rst
+RST_MANPAGES_NOINST = ovn-sim.1.rst
# The GNU standards say that these variables should control
# installation directories for manpages in each section. Automake
@@ -114,8 +114,8 @@ html_static_path = ['_static']
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
_man_pages = [
- ('ovs-sim.1',
- u'Open vSwitch simulator environment'),
+ ('ovn-sim.1',
+ u'Open Virtual Network simulator environment'),
('ovsdb-server.7',
u'Open vSwitch Database Server Protocol'),
('ovsdb.5',
@@ -39,7 +39,7 @@ time:
.. toctree::
:maxdepth: 3
- ovs-sim.1
+ ovn-sim.1
ovsdb-server.7
ovsdb.5
ovsdb.7
new file mode 100644
@@ -0,0 +1,122 @@
+=======
+ovn-sim
+=======
+
+Synopsis
+========
+
+``ovn-sim`` [*option*]... [*script*]...
+
+Description
+===========
+
+``ovn-sim`` is a wrapper script that adds ovn related commands on
+top of ``ovs-sim``.
+
+``ovs-sim`` provides a convenient environment for running one or more Open
+vSwitch instances and related software in a sandboxed simulation environment.
+
+To use ``ovn-sim``, first build Open vSwitch, then invoke it directly from the
+build directory, e.g.::
+
+ git clone https://github.com/openvswitch/ovs.git
+ cd ovs
+ ./boot.sh && ./configure && make
+ cd ..
+ git clone https://github.com/ovn-org/ovn.git
+ cd ovn
+ ./boot.sh && ./configure --with-ovs-source=${PWD}/../ovs
+ make
+ utilities/ovn-sim
+
+See documentation on ``ovs-sim`` for info on simulator, including the
+parameters you can use.
+
+OVN Commands
+------------
+
+These commands interact with OVN, the Open Virtual Network.
+
+``ovn_start`` [*options*]
+ Creates and initializes the central OVN databases (both
+ ``ovn-sb(5)`` and ``ovn-nb(5)``) and starts an instance of
+ ``ovsdb-server`` for each one. Also starts an instance of
+ ``ovn-northd``.
+
+ The following options are available:
+
+ ``--nbdb-model`` *model*
+ Uses the given database model for the northbound database.
+ The *model* may be ``standalone`` (the default), ``backup``,
+ or ``clustered``.
+
+ ``--nbdb-servers`` *n*
+ For a clustered northbound database, the number of servers in
+ the cluster. The default is 3.
+
+ ``--sbdb-model`` *model*
+ Uses the given database model for the southbound database.
+ The *model* may be ``standalone`` (the default), ``backup``,
+ or ``clustered``.
+
+ ``--sbdb-servers`` *n*
+ For a clustered southbound database, the number of servers in
+ the cluster. The default is 3.
+
+``ovn_attach`` *network* *bridge* *ip* [*masklen*]
+ First, this command attaches bridge to interconnection network
+ network, just like ``net_attach`` *network* *bridge*. Second, it
+ configures (simulated) IP address *ip* (with network mask length
+ *masklen*, which defaults to 24) on *bridge*. Finally, it
+ configures the Open vSwitch database to work with OVN and starts
+ ``ovn-controller``.
+
+Examples
+========
+
+Simulating hypervisors and and starting ovn controller (via ovn_attach) on each::
+
+ ovn_start
+ ovn-nbctl ls-add lsw0
+ net_add n1
+ for i in 0 1; do
+ sim_add hv$i
+ as hv$i
+ ovs-vsctl add-br br-phys
+ ovn_attach n1 br-phys 192.168.0.`expr $i + 1`
+ ovs-vsctl add-port br-int vif$i -- set Interface vif$i external-ids:iface-id=lp$i
+ ovn-nbctl lsp-add lsw0 lp$i
+ ovn-nbctl lsp-set-addresses lp$i f0:00:00:00:00:0$i
+ done
+
+Here’s a primitive OVN "scale test" (adjust the scale by changing
+``n`` in the first line)::
+
+ n=200; export n
+ ovn_start --sbdb-model=clustered
+ net_add n1
+ ovn-nbctl ls-add br0
+ for i in `seq $n`; do
+ (sim_add hv$i
+ as hv$i
+ ovs-vsctl add-br br-phys
+ y=$(expr $i / 256)
+ x=$(expr $i % 256)
+ ovn_attach n1 br-phys 192.168.$y.$x
+ ovs-vsctl add-port br-int vif$i -- set Interface vif$i external-ids:iface-id=lp$i) &
+ case $i in
+ *50|*00) echo $i; wait ;;
+ esac
+ done
+ wait
+ for i in `seq $n`; do
+ yy=$(printf %02x $(expr $i / 256))
+ xx=$(printf %02x $(expr $i % 256))
+ ovn-nbctl lsp-add br0 lp$i
+ ovn-nbctl lsp-set-addresses lp$i f0:00:00:00:$yy:$xx
+ done
+
+When the scale test has finished initializing, you can watch the
+logical ports come up with a command like this::
+
+ watch 'for i in `seq $n`; do if test `ovn-nbctl lsp-get-up lp$i` != up; then echo $i; fi; done'
deleted file mode 100644
@@ -1,244 +0,0 @@
-=======
-ovs-sim
-=======
-
-Synopsis
-========
-
-``ovs-sim`` [*option*]... [*script*]...
-
-Description
-===========
-
-``ovs-sim`` provides a convenient environment for running one or more Open
-vSwitch instances and related software in a sandboxed simulation environment.
-
-To use ``ovs-sim``, first build Open vSwitch, then invoke it directly from the
-build directory, e.g.::
-
- git clone https://github.com/openvswitch/ovs.git
- cd ovs
- ./configure
- make
- utilities/ovs-sim
-
-When invoked in the most ordinary way as shown above, ovs-sim does the
-following:
-
-1. Creates a directory ``sandbox`` as a subdirectory of the current
- directory (first destroying such a directory if it already exists)
- and makes it the current directory.
-
-2. Installs all of the Open vSwitch manpages into a ``man``
- subdirectory of sandbox and adjusts the ``MANPATH`` environment
- variable so that ``man`` and other manpage viewers can find them.
-
-3. Creates a simulated Open vSwitch named ``main`` and sets it up as the
- default target for OVS commands, as if the following ``ovs-sim``
- commands had been run::
-
- sim_add main
- as main
-
- See `Commands`_, below, for an explanation.
-
-4. Runs any scripts specified on the command line (see `Options`_,
- below). The scripts can use arbitrary Bash syntax, plus the
- additional commands described under `Commands`_, below.
-
-5. If no scripts were specified, or if ``-i`` or ``--interactive`` was
- specified, invokes an interactive Bash subshell. The user can use
- arbitrary Bash commands, plus the additional commands described under
- `Commands`_, below.
-
-``ovs-sim`` and the sandbox environment that it creates does not require
-superuser or other special privileges. Generally, it should not be run with
-such privileges.
-
-Options
-=======
-
-.. program: ovs-sim
-
-*script*
- Runs *script*, which should be a Bash script, within a subshell
- after initializing. If multiple script arguments are given, then
- they are run in the order given. If any script exits with a
- nonzero exit code, then ``ovs-sim`` exits immediately with the
- same exit code.
-
-``-i`` or ``--interactive``
- By default, if any script is specified, ``ovs-sim`` exits as soon as the
- scripts finish executing. With this option, or if no scripts are specified,
- ``ovs-sim`` instead starts an interactive Bash session.
-
-Commands
-========
-
-Scripts and interactive usage may use the following commands
-implemented by ``ovs-sim``. They are implemented as Bash shell functions
-exported to subshells.
-
-Basic Commands
---------------
-
-These are the basic commands for working with sandboxed Open vSwitch
-instances.
-
-``sim_add`` *sandbox*
- Starts a new simulated Open vSwitch instance named *sandbox*.
- Files related to the instance, such as logs, databases, sockets,
- and pidfiles, are created in a subdirectory also named
- *sandbox*. Afterward, the ``as`` command (see below) can be used
- to run Open vSwitch utilities in the context of the new sandbox.
-
- The new sandbox starts out without any bridges. Use ``ovs-vsctl``
- in the context of the new sandbox to create a bridge, e.g.::
-
- sim_add hv0 # Create sandbox hv0.
- as hv0 # Set hv0 as default sandbox.
- ovs-vsctl add-br br0 # Add bridge br0 inside hv0.
-
- The Open vSwitch instances that ``sim_add`` creates enable
- ``dummy`` devices. This means that bridges and interfaces can be
- created with type ``dummy`` to indicate that they should be
- totally simulated, without any reference to system entities. In
- fact, ``ovs-sim`` also configures Open vSwitch so that the default
- system type of bridges and interfaces are replaced by dummy
- devices. Other types of devices, however, retain their usual
- functions, which means that, e.g., vxlan tunnels still act as
- tunnels (refer to the documentation).
-
-``as`` *sandbox*
- Sets sandbox as the default simulation target for Open vSwitch
- commands (e.g. ``ovs-vsctl``, ``ovs-ofctl``, ``ovs-appctl``).
-
- This command updates the beginning of the shell prompt to indicate
- the new default target.
-
-``as`` *sandbox* *command* *arg*...
- Runs the given command with *sandbox* as the simulation target,
- e.g. ``as hv0 ovs-vsctl add-br br0`` runs ``ovs-vsctl add-br
- br0`` within sandbox ``hv0``. The default target is unchanged.
-
-Interconnection Network Commands
---------------------------------
-
-When multiple sandboxed Open vSwitch instances exist, one will
-inevitably want to connect them together. These commands allow for
-that. Conceptually, an interconnection network is a switch that
-``ovs-sim`` makes it easy to plug into other switches in other
-sandboxed Open vSwitch instances. Interconnection networks are
-implemented as bridges in the ``main`` switch that ``ovs-sim`` creates
-by default, so to use interconnection networks please avoid working
-with ``main`` directly.
-
-``net_add`` *network*
- Creates a new interconnection network named *network*.
-
-``net_attach`` *network* *bridge*
- Adds a new port to *bridge* in the default sandbox (as set with
- ``as``) and plugs it into interconnection network *network*, which
- must already have been created by a previous invocation of
- ``net_add``. The default sandbox must not be ``main``.
-
-OVN Commands
-------------
-
-These commands interact with OVN, the Open Virtual Network.
-
-``ovn_start`` [*options*]
- Creates and initializes the central OVN databases (both
- ``ovn-sb(5)`` and ``ovn-nb(5)``) and starts an instance of
- ``ovsdb-server`` for each one. Also starts an instance of
- ``ovn-northd``.
-
- The following options are available:
-
- ``--nbdb-model`` *model*
- Uses the given database model for the northbound database.
- The *model* may be ``standalone`` (the default), ``backup``,
- or ``clustered``.
-
- ``--nbdb-servers`` *n*
- For a clustered northbound database, the number of servers in
- the cluster. The default is 3.
-
- ``--sbdb-model`` *model*
- Uses the given database model for the southbound database.
- The *model* may be ``standalone`` (the default), ``backup``,
- or ``clustered``.
-
- ``--sbdb-servers`` *n*
- For a clustered southbound database, the number of servers in
- the cluster. The default is 3.
-
-``ovn_attach`` *network* *bridge* *ip* [*masklen*]
- First, this command attaches bridge to interconnection network
- network, just like ``net_attach`` *network* *bridge*. Second, it
- configures (simulated) IP address *ip* (with network mask length
- *masklen*, which defaults to 24) on *bridge*. Finally, it
- configures the Open vSwitch database to work with OVN and starts
- ``ovn-controller``.
-
-Examples
-========
-
-The following creates a pair of Open vSwitch instances ``hv0`` and
-``hv1``, adds a port named ``vif0`` or ``vif1``, respectively, to each
-one, and then connects the two through an interconnection network
-``n1``::
-
- net_add n1
- for i in 0 1; do
- sim_add hv$i
- as hv$i ovs-vsctl add-br br0 -- add-port br0 vif$i
- as hv$i net_attach n1 br0
- done
-
-Here’s an extended version that also starts OVN::
-
- ovn_start
- ovn-nbctl ls-add lsw0
- net_add n1
- for i in 0 1; do
- sim_add hv$i
- as hv$i
- ovs-vsctl add-br br-phys
- ovn_attach n1 br-phys 192.168.0.`expr $i + 1`
- ovs-vsctl add-port br-int vif$i -- set Interface vif$i external-ids:iface-id=lp$i
- ovn-nbctl lsp-add lsw0 lp$i
- ovn-nbctl lsp-set-addresses lp$i f0:00:00:00:00:0$i
- done
-
-Here’s a primitive OVN "scale test" (adjust the scale by changing
-``n`` in the first line::
-
- n=200; export n
- ovn_start --sbdb-model=clustered
- net_add n1
- ovn-nbctl ls-add br0
- for i in `seq $n`; do
- (sim_add hv$i
- as hv$i
- ovs-vsctl add-br br-phys
- y=$(expr $i / 256)
- x=$(expr $i % 256)
- ovn_attach n1 br-phys 192.168.$y.$x
- ovs-vsctl add-port br-int vif$i -- set Interface vif$i external-ids:iface-id=lp$i) &
- case $i in
- *50|*00) echo $i; wait ;;
- esac
- done
- wait
- for i in `seq $n`; do
- yy=$(printf %02x $(expr $i / 256))
- xx=$(printf $02x $(expr $i % 256))
- ovn-nbctl lsp-add br0 lp$i
- ovn-nbctl lsp-set-addresses lp$i f0:00:00:00:$yy:$xx
- done
-
-When the scale test has finished initializing, you can watch the
-logical ports come up with a command like this::
-
- watch 'for i in `seq $n`; do if test `ovn-nbctl lsp-get-up lp$i` != up; then echo $i; fi; done'
@@ -173,6 +173,7 @@ SUFFIXES += .in
-e 's,[@]DBDIR[@],$(DBDIR),g' \
-e 's,[@]PYTHON[@],$(PYTHON),g' \
-e 's,[@]OVN_RUNDIR[@],$(OVN_RUNDIR),g' \
+ -e 's,[@]OVSBUILDDIR[@],$(OVSBUILDDIR),g' \
-e 's,[@]VERSION[@],$(VERSION),g' \
-e 's,[@]localstatedir[@],$(localstatedir),g' \
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
@@ -12,3 +12,4 @@
/ovn-docker-overlay-driver
/ovn-docker-underlay-driver
/ovn-lib
+/ovn-sim
@@ -52,7 +52,11 @@ CLEANFILES += \
utilities/ovn-detrace.1 \
utilities/ovn-detrace \
utilities/ovn-appctl.8 \
- utilities/ovn-appctl
+ utilities/ovn-appctl \
+ utilities/ovn-sim
+
+EXTRA_DIST += utilities/ovn-sim.in
+noinst_SCRIPTS += utilities/ovn-sim
utilities/ovn-lib: $(top_builddir)/config.status
new file mode 100755
@@ -0,0 +1,308 @@
+#! /usr/bin/env bash
+#
+# Copyright (c) 2019 Nicira, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+ovn_sim_builddir='@abs_builddir@'; export ovn_sim_builddir
+ovn_sim_srcdir='@abs_top_srcdir@'; export ovn_sim_srcdir
+ovs_sim_builddir='@OVSBUILDDIR@'
+
+# Check that we've got proper builddir and srcdir.
+if test ! -e "$ovs_sim_builddir"/utilities/ovs-sim; then
+ echo "$ovs_sim_builddir/utilities/ovs-sim does not exist ($0 requires ovs-sim)" >&2
+ exit 1
+fi
+if test ! -e "$ovn_sim_builddir"/northd/ovn-northd; then
+ echo "$ovn_sim_builddir/northd/ovn-northd does not exist (need to run \"make\"?)" >&2
+ exit 1
+fi
+if test ! -e "$ovn_sim_srcdir"/README.rst; then
+ echo "$ovn_sim_srcdir/README.rst does not exist" >&2
+ exit 1
+fi
+
+# Put built tools early in $PATH.
+PATH=$ovn_sim_builddir/controller:$ovn_sim_builddir/northd:$ovn_sim_builddir/utilities:$PATH
+export PATH
+
+ovn-nbctl () { command ovn-nbctl -vsyslog:off "$@"; }; export -f ovn-nbctl
+ovn-sbctl () { command ovn-sbctl -vsyslog:off "$@"; }; export -f ovn-sbctl
+
+ovn_start_db() {
+ local db=$1 model=$2 servers=$3 schema=$4
+ local DB=$(echo $db | tr a-z A-Z)
+ local schema_name=$(ovsdb-tool schema-name $schema)
+
+ case $model in
+ standalone | backup) ;;
+ clustered)
+ case $servers in
+ [1-9] | [1-9][0-9]) ;;
+ *) echo "${db}db servers must be between 1 and 99" >&2
+ exit 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "unknown ${db}db model \"$model\"" >&2
+ exit 1
+ ;;
+ esac
+
+ ovn_start_ovsdb_server() {
+ local i=$1; shift
+ as ${db}$i ovsdb-server --detach --no-chdir --pidfile=$db.pid \
+ -vsyslog:off -vconsole:off --log-file="$sim_base"/$db$i/$db.log \
+ --remote=db:$schema_name,${DB}_Global,connections \
+ --private-key=db:$schema_name,SSL,private_key \
+ --certificate=db:$schema_name,SSL,certificate \
+ --ca-cert=db:$schema_name,SSL,ca_cert \
+ --ssl-protocols=db:$schema_name,SSL,ssl_protocols \
+ --ssl-ciphers=db:$schema_name,SSL,ssl_ciphers \
+ --unixctl=${db} --remote=punix:$db.ovsdb \
+ "$sim_base"/$db$i/$db.db "$@"
+ }
+
+ ovn_prep_db() {
+ local i=$1
+ mkdir "$sim_base"/${db}$i
+ touch "$sim_base"/${db}$i/.$db.db.~lock~
+ }
+
+ local n_remotes=1
+ case $model in
+ standalone)
+ ovn_prep_db 1
+ ovsdb-tool create "$sim_base"/${db}1/$db.db "$schema"
+ ovn_start_ovsdb_server 1
+ ;;
+ backup)
+ for i in 1 2; do
+ ovn_prep_db $i
+ ovsdb-tool create "$sim_base"/$db$i/$db.db "$schema"
+ done
+ ovn_start_ovsdb_server 1
+ ovn_start_ovsdb_server 2 --sync-from=unix:"$sim_base"/${db}1/$db.ovsdb
+ cat <<EOF
+The backup server of OVN $DB can be accessed by:
+* ovn-${db}ctl --db=unix:$sim_base/${db}2/$db.ovsdb
+* ovs-appctl -t $sim_base/${db}2/${db}
+The backup database file is $sim_base/${db}2/$db.db
+EOF
+ ;;
+ clustered)
+ n_remotes=$servers
+ for i in $(seq $servers); do
+ ovn_prep_db $i
+ if test $i = 1; then
+ ovsdb-tool create-cluster "$sim_base"/$db$i/$db.db "$schema" unix:"$sim_base"/$db$i/db.raft
+ else
+ ovsdb-tool join-cluster "$sim_base"/$db$i/$db.db $schema_name unix:"$sim_base"/$db$i/db.raft unix:"$sim_base"/${db}1/db.raft
+ fi
+ ovn_start_ovsdb_server $i
+ done
+ for i in $(seq $servers); do
+ ovsdb-client wait unix:"$sim_base"/${db}$i/$db.ovsdb $schema_name connected
+ done
+ ;;
+ esac
+
+ remote=unix:"$sim_base"/${db}1/$db.ovsdb
+ for i in `seq 2 $n_remotes`; do
+ remote=$remote,unix:"$sim_base"/${db}$i/$db.ovsdb
+ done
+ eval OVN_${DB}_DB=\$remote
+ eval export OVN_${DB}_DB
+}
+export -f ovn_start_db
+
+ovn_start() {
+ local nbdb_model=standalone
+ local nbdb_servers=3
+ local sbdb_model=standalone
+ local sbdb_servers=3
+ local prev=
+ for option; do
+ # This option-parsing mechanism borrowed from a Autoconf-generated
+ # configure script under the following license:
+
+ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+ # 2002, 2003, 2004, 2005, 2006, 2009, 2013 Free Software Foundation, Inc.
+ # This configure script is free software; the Free Software Foundation
+ # gives unlimited permission to copy, distribute and modify it.
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ eval $prev=\$option
+ prev=
+ continue
+ fi
+ case $option in
+ *=*) optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;;
+ *) optarg=yes ;;
+ esac
+
+ case $dashdash$option in
+ --)
+ dashdash=yes ;;
+ -h|--help)
+ cat <<EOF
+$FUNCNAME: start OVN central databases and daemons
+usage: $FUNCNAME [OPTION...]
+
+This creates and initializes the central OVN databases (northbound and
+southbound), starts their ovsdb-server daemons, and starts the ovn-northd
+daemon.
+
+Options:
+ --nbdb-model=standalone|backup|clustered northbound database model
+ --nbdb-servers=N number of servers in nbdb cluster (default: 3)
+ --sbdb-model=standalone|backup|clustered southbound database model
+ --sbdb-servers=N number of servers in sbdb cluster (default: 3)
+ -h, --help Print this usage message.
+EOF
+ return
+ ;;
+
+ --nbdb-s*=*)
+ nbdb_servers=$optarg
+ nbdb_model=clustered
+ ;;
+ --nbdb-s*)
+ prev=nbdb_servers
+ nbdb_model=clustered
+ ;;
+ --nbdb-m*=*)
+ nbdb_model=$optarg
+ ;;
+ --nbdb-m*)
+ prev=nbdb_model
+ ;;
+ --sbdb-s*=*)
+ sbdb_servers=$optarg
+ sbdb_model=clustered
+ ;;
+ --sbdb-s*)
+ prev=sbdb_servers
+ sbdb_model=clustered
+ ;;
+ --sbdb-m*=*)
+ sbdb_model=$optarg
+ ;;
+ --sbdb-m*)
+ prev=sbdb_model
+ ;;
+ -*)
+ echo "unrecognized option $option (use --help for help)" >&2
+ return 1
+ ;;
+ *)
+ echo "$option: non-option arguments not supported (use --help for help)" >&2
+ return 1
+ ;;
+ esac
+ shift
+ done
+
+ if test -d ovn-sb || test -d ovn-nb; then
+ echo >&2 "OVN already started"
+ return 1
+ fi
+
+ ovn_sim_setvars $sandbox
+
+ # Build ovn man pages as part of ovn_start
+ ovn_man_pages
+
+ ovn_start_db nb "$nbdb_model" "$nbdb_servers" "$ovn_sim_srcdir"/ovn-nb.ovsschema
+ ovn_start_db sb "$sbdb_model" "$sbdb_servers" "$ovn_sim_srcdir"/ovn-sb.ovsschema
+
+ ovn-nbctl init
+ ovn-sbctl init
+
+ mkdir "$sim_base"/northd
+ as northd ovn-northd --detach --no-chdir --pidfile=ovn-northd.pid -vconsole:off \
+ --log-file=ovn-northd.log -vsyslog:off \
+ --ovnnb-db="$OVN_NB_DB" --ovnsb-db="$OVN_SB_DB"
+}
+export -f ovn_start
+
+ovn_attach() {
+ if test "$1" == --help; then
+ cat <<EOF
+$FUNCNAME: attach default sandbox to an interconnection network for OVN
+usage: $FUNCNAME NETWORK BRIDGE IP [MASKLEN]
+
+This starts by doing everything that net_attach does. Then it configures the
+specified IP and MASKLEN (e.g. 192.168.0.1 and 24) on BRIDGE and starts
+and configures ovn-controller.
+
+MASKLEN defaults to 24 if it is not specified.
+EOF
+ return 0
+ fi
+ if test $# != 3 && test $# != 4; then
+ echo >&2 "$FUNCNAME: wrong number of arguments (use --help for help)"
+ return 1
+ fi
+
+ local net=$1 bridge=$2 ip=$3 masklen=${4-24}
+ net_attach $net $bridge || return $?
+
+ ovn_sim_setvars $sandbox
+
+ ovs-appctl netdev-dummy/ip4addr $bridge $ip/$masklen >/dev/null
+ ovs-appctl ovs/route/add $ip/$masklen $bridge > /dev/null
+ ovs-vsctl \
+ -- set Open_vSwitch . external-ids:system-id=$sandbox \
+ -- set Open_vSwitch . external-ids:ovn-remote=$OVN_SB_DB \
+ -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \
+ -- set Open_vSwitch . external-ids:ovn-encap-ip=$ip\
+ -- add-br br-int \
+ -- set bridge br-int fail-mode=secure other-config:disable-in-band=true
+ ovn-controller --detach --no-chdir -vsyslog:off -vconsole:off \
+ --log-file=ovn-controller.${sandbox}.log \
+ --pidfile=ovn-controller.${sandbox}.pid
+}
+export -f ovn_attach
+
+ovn_sim_setvars() {
+ OVN_RUNDIR=$sim_base/$1; export OVN_RUNDIR
+ OVN_LOGDIR=$sim_base/$1; export OVN_LOGDIR
+ OVN_DBDIR=$sim_base/$1; export OVN_DBDIR
+ OVN_SYSCONFDIR=$sim_base/$1; export OVN_SYSCONFDIR
+}
+export -f ovn_sim_setvars
+
+ovn_as() {
+ if test -n "$1"; then
+ ovn_sim_setvars $1
+ fi
+ as $@
+}
+export -f ovn_as
+
+ovn_man_pages() {
+ # Easy access to OVN manpages.
+ mkdir -p $sim_base/man
+ mandir=`cd $sim_base/man && pwd`
+ (cd "$ovn_sim_builddir" && ${MAKE-make} install-man install-man-rst mandir=$mandir EXTRA_RST_MANPAGES=ovn-sim.1.rst >/dev/null)
+ # Note: MANPATH expected to be already exported by ovs-sim
+ #MANPATH=$mandir:; export MANPATH
+}
+export -f ovn_man_pages
+
+source ${ovs_sim_builddir}/utilities/ovs-sim
Adding a wrapper to ovs-sim called ovn-sim, which re-introduces the primitives for OVN in the simulator that were lost as part of the ovn-org/ovn split. Also resurrected the man page used to document ovn-sim usage. Lastly, there were some leftover ovs-sim references that were not proper. This patch renames these to ovn-sim. All in all, this change is nothing but porting over the OVN sections of ovs-sim from OVS version 2.12 (pre-split). Fixes #21 Reported-by: Flavio Fernandes <flavio@flaviof.com> Reported-at: https://github.com/ovn-org/ovn/issues/21 Signed-off-by: Flavio Fernandes <flavio@flaviof.com> --- Documentation/automake.mk | 2 +- Documentation/conf.py | 4 +- Documentation/ref/index.rst | 2 +- Documentation/ref/ovn-sim.1.rst | 122 +++++++++++++ Documentation/ref/ovs-sim.1.rst | 244 ------------------------- Makefile.am | 1 + utilities/.gitignore | 1 + utilities/automake.mk | 6 +- utilities/ovn-sim.in | 308 ++++++++++++++++++++++++++++++++ 9 files changed, 441 insertions(+), 249 deletions(-) create mode 100644 Documentation/ref/ovn-sim.1.rst delete mode 100644 Documentation/ref/ovs-sim.1.rst create mode 100755 utilities/ovn-sim.in