From patchwork Fri May 18 21:37:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 916618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhb772sFz9s2k for ; Sat, 19 May 2018 07:46:59 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B0B29D07; Fri, 18 May 2018 21:37:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id ECD4ACF6 for ; Fri, 18 May 2018 21:37:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4106BD3 for ; Fri, 18 May 2018 21:37:38 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 5FD5EE0003; Fri, 18 May 2018 23:37:37 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:26 -0700 Message-Id: <20180518213732.30912-1-blp@ovn.org> X-Mailer: git-send-email 2.16.1 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/7] ovsdb: Improve torture test for clusters. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This test is supposed to be parameterized, but one of the loops didn't honor the parameterization and just had hardcoded values. Also, the output comparison didn't work properly for more than 100 client sets (n1 > 100), so this adds some explicit sorting to the mix. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- tests/ovsdb-cluster.at | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ovsdb-cluster.at b/tests/ovsdb-cluster.at index e161d1abfc2a..cc66228c6265 100644 --- a/tests/ovsdb-cluster.at +++ b/tests/ovsdb-cluster.at @@ -196,12 +196,12 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral echo "...done" AT_CHECK([if test $phase != 2; then exit 77; fi]) - for i in `seq 0 9`; do - for j in `seq 5`; do + for i in $(seq 0 $(expr $n1 - 1) ); do + for j in `seq $n2`; do echo "$i-$j=$i-$j" done - done > expout - AT_CHECK([ovn-sbctl --timeout=30 --log-file=finalize.log -vtimeval:off -vfile -vsyslog:off --bare get SB_Global . external-ids | sed 's/, /\n/g; s/[[{}""]]//g;'], [0], [expout]) + done | sort > expout + AT_CHECK([ovn-sbctl --timeout=30 --log-file=finalize.log -vtimeval:off -vfile -vsyslog:off --bare get SB_Global . external-ids | sed 's/, /\n/g; s/[[{}""]]//g;' | sort], [0], [expout]) for i in `seq $n`; do if test $i != $victim || test $phase != 1; then From patchwork Fri May 18 21:37:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 916619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhbs24GDz9s2k for ; Sat, 19 May 2018 07:47:37 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8CCB0D1B; Fri, 18 May 2018 21:37:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1C059CF6 for ; Fri, 18 May 2018 21:37:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8F600D3 for ; Fri, 18 May 2018 21:37:39 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id E0BD3E0004; Fri, 18 May 2018 23:37:38 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:27 -0700 Message-Id: <20180518213732.30912-2-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518213732.30912-1-blp@ovn.org> References: <20180518213732.30912-1-blp@ovn.org> X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 2/7] ovsdb: Improve timing in cluster torture test. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Until now the timing in the cluster torture test has been pretty inaccurate because it just worked by calling "sleep 1" in a loop that did other things. The longer those other things too, the more inaccurate it got. This commit changes to using a separate process for timing. It still won't be all that accurate but at least the timing loop doesn't try to do anything else. (I'm not sure how to actually get accurate timing in shell.) Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- tests/ovsdb-cluster.at | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/ovsdb-cluster.at b/tests/ovsdb-cluster.at index cc66228c6265..755fa2dc8bbf 100644 --- a/tests/ovsdb-cluster.at +++ b/tests/ovsdb-cluster.at @@ -149,9 +149,9 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral sleep 2 echo "waiting for ovn-sbctl processes to exit..." - i=0 phase=0 - while :; do + i=0 + (while :; do echo; sleep 1; done) | while read; do printf "t=%2d s:" $i done=0 for j in $(seq 0 $(expr $n1 - 1)); do @@ -190,7 +190,6 @@ ovsdb|WARN|schema: changed 2 columns in 'OVN_Southbound' database from ephemeral ;; esac - sleep 1 i=$(expr $i + 1) done echo "...done" From patchwork Fri May 18 21:37:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 916620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhcF1tvYz9s2k for ; Sat, 19 May 2018 07:47:57 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 63A5DD6D; Fri, 18 May 2018 21:37:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5096BD01 for ; Fri, 18 May 2018 21:37:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5C772D3 for ; Fri, 18 May 2018 21:37:41 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 51679E0008; Fri, 18 May 2018 23:37:40 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:28 -0700 Message-Id: <20180518213732.30912-3-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518213732.30912-1-blp@ovn.org> References: <20180518213732.30912-1-blp@ovn.org> MIME-Version: 1.0 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 3/7] ovs-sim: Convert documentation to RST format. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- Documentation/automake.mk | 3 +- Documentation/conf.py | 4 +- Documentation/ref/index.rst | 1 + Documentation/ref/ovs-sim.1.rst | 224 ++++++++++++++++++++++++++++ tutorial/ovs-sandbox | 17 ++- utilities/.gitignore | 1 - utilities/automake.mk | 4 +- utilities/ovs-sim.1.xml | 323 ---------------------------------------- 8 files changed, 245 insertions(+), 332 deletions(-) create mode 100644 Documentation/ref/ovs-sim.1.rst delete mode 100644 utilities/ovs-sim.1.xml diff --git a/Documentation/automake.mk b/Documentation/automake.mk index 683ca1442af0..2202df45b6cc 100644 --- a/Documentation/automake.mk +++ b/Documentation/automake.mk @@ -158,7 +158,8 @@ RST_MANPAGES = \ ovs-vlan-test.8.rst \ ovsdb-server.7.rst \ ovsdb.5.rst \ - ovsdb.7.rst + ovsdb.7.rst \ + ovs-sim.1.rst # The GNU standards say that these variables should control # installation directories for manpages in each section. Automake diff --git a/Documentation/conf.py b/Documentation/conf.py index babda21defff..d81fcaeb440d 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -114,6 +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'), ('ovs-test.8', u'Check Linux drivers for performance, vlan and L3 tunneling problems'), ('ovs-vlan-test.8', @@ -123,7 +125,7 @@ _man_pages = [ ('ovsdb.5', u'Open vSwitch Database (File Formats)'), ('ovsdb.7', - u'Open vSwitch Database (Overview)'), + u'Open vSwitch Database (Overview)',), ] # Generate list of (path, name, description, [author, ...], section) diff --git a/Documentation/ref/index.rst b/Documentation/ref/index.rst index 3d511decb434..29183af623f0 100644 --- a/Documentation/ref/index.rst +++ b/Documentation/ref/index.rst @@ -39,6 +39,7 @@ time: .. toctree:: :maxdepth: 3 + ovs-sim.1 ovs-test.8 ovs-vlan-test.8 ovsdb-server.7 diff --git a/Documentation/ref/ovs-sim.1.rst b/Documentation/ref/ovs-sim.1.rst new file mode 100644 index 000000000000..faeee1791050 --- /dev/null +++ b/Documentation/ref/ovs-sim.1.rst @@ -0,0 +1,224 @@ +======= +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`` + 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``. + +``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 + 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' diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox index 9505c6c3d98b..aa60b9bc3157 100755 --- a/tutorial/ovs-sandbox +++ b/tutorial/ovs-sandbox @@ -72,6 +72,7 @@ ovnsb_schema= ovnnb_schema= ovn_rbac=true n_northds=1 +n_controllers=1 nbdb_model=standalone nbdb_servers=3 sbdb_model=backup @@ -212,6 +213,12 @@ EOF --n-northd*) prev=n_northds ;; + --n-controller*=*) + n_controllers=$optarg + ;; + --n-controller*) + prev=n_controllers + ;; --nbdb-s*=*) nbdb_servers=$optarg nbdb_model=clustered @@ -386,7 +393,9 @@ if $ovn; then $OVS_PKI -B 1024 init $OVS_PKI -B 1024 req+sign ovnsb switch $OVS_PKI -B 1024 req+sign ovnnb switch - $OVS_PKI -B 1024 -u req+sign chassis-1 switch + for i in $(seq $n_controllers); do + $OVS_PKI -B 1024 -u req+sign chassis-$i switch + done fi fi rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \ @@ -524,8 +533,10 @@ if $ovn; then --log-file=ovn-northd$i.log \ --ovnsb-db="$OVN_SB_DB" --ovnnb-db="$OVN_NB_DB" done - rungdb $gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \ - $OVN_CTRLR_PKI --detach --no-chdir --pidfile -vconsole:off --log-file + for i in $(seq $n_controllers); do + rungdb $gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \ + $OVN_CTRLR_PKI --detach --no-chdir --pidfile -vconsole:off --log-file + done rungdb $gdb_ovn_controller_vtep $gdb_ovn_controller_vtep_ex \ ovn-controller-vtep --detach --no-chdir --pidfile -vconsole:off \ $OVN_CTRLR_PKI --log-file --ovnsb-db=unix:"$sandbox"/ovnsb_db.sock diff --git a/utilities/.gitignore b/utilities/.gitignore index 34c58f20f53c..aca5f1a34984 100644 --- a/utilities/.gitignore +++ b/utilities/.gitignore @@ -37,4 +37,3 @@ /ovs-vsctl /ovs-vsctl.8 /ovs-sim -/ovs-sim.1 diff --git a/utilities/automake.mk b/utilities/automake.mk index afdbdb9f4da4..eb4fd6faaae6 100644 --- a/utilities/automake.mk +++ b/utilities/automake.mk @@ -31,8 +31,7 @@ check_SCRIPTS += \ utilities/ovs-appctl-bashcomp.bash \ utilities/ovs-vsctl-bashcomp.bash -EXTRA_DIST += utilities/ovs-sim.in utilities/ovs-sim.1.xml -noinst_man_MANS += utilities/ovs-sim.1 +EXTRA_DIST += utilities/ovs-sim.in noinst_SCRIPTS += utilities/ovs-sim utilities/ovs-lib: $(top_builddir)/config.status @@ -92,7 +91,6 @@ CLEANFILES += \ utilities/ovs-pki \ utilities/ovs-pki.8 \ utilities/ovs-sim \ - utilities/ovs-sim.1 \ utilities/ovs-tcpdump \ utilities/ovs-tcpdump.8 \ utilities/ovs-tcpundump \ diff --git a/utilities/ovs-sim.1.xml b/utilities/ovs-sim.1.xml deleted file mode 100644 index 62ac22bb33db..000000000000 --- a/utilities/ovs-sim.1.xml +++ /dev/null @@ -1,323 +0,0 @@ - - -

Name

-

ovs-sim -- Open vSwitch simulator environment

- -

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 cds into that directory. -
  2. - -
  3. - 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. -
  4. - -
  5. -

    - 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. -

    -
  6. - -
  7. - 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. -
  8. - -
  9. - If no scripts were specified, or if or - was specified, invokes an interactive - Bash subshell. The user can use arbitrary Bash commands, plus the - additional commands described under Commands, below. -
  10. -
- -

- 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

- -

- ovs-sim accepts the following options and arguments: -

- -
-
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. -
- -
-
-
- 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 create 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 the network - interconnection network. network 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
-
- Creates and initializes the central OVN databases (both - ovn-sb(5) and ovn-nb) and starts an instance - of ovsdb-server for each one. Also starts an instance of - ovn-northd. -
- -
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
-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'
-    
- -
From patchwork Fri May 18 21:37:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 916621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhcs0p1hz9s2k for ; Sat, 19 May 2018 07:48:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8B2A3D49; Fri, 18 May 2018 21:37:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1B540D59 for ; Fri, 18 May 2018 21:37:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B3958E5 for ; Fri, 18 May 2018 21:37:42 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 12108E0002; Fri, 18 May 2018 23:37:41 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:29 -0700 Message-Id: <20180518213732.30912-4-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518213732.30912-1-blp@ovn.org> References: <20180518213732.30912-1-blp@ovn.org> X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 4/7] ovs-sim: Install RST manpages into simulation environment too. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- utilities/ovs-sim.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/ovs-sim.in b/utilities/ovs-sim.in index 54c48799fde4..1a8a0e1f09a2 100755 --- a/utilities/ovs-sim.in +++ b/utilities/ovs-sim.in @@ -311,7 +311,7 @@ export -f ovn_attach # Easy access to OVS manpages. mkdir $sim_base/man mandir=`cd $sim_base/man && pwd` -(cd "$sim_builddir" && ${MAKE-make} install-man mandir=$mandir >/dev/null) +(cd "$sim_builddir" && ${MAKE-make} install-man install-man-rst mandir=$mandir >/dev/null) MANPATH=$mandir:; export MANPATH export scripts From patchwork Fri May 18 21:37:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 916622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhdH0LhDz9s2k for ; Sat, 19 May 2018 07:48:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7C44DD98; Fri, 18 May 2018 21:37:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3F290D49 for ; Fri, 18 May 2018 21:37:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 54472D3 for ; Fri, 18 May 2018 21:37:44 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 9AB31E0003; Fri, 18 May 2018 23:37:43 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:30 -0700 Message-Id: <20180518213732.30912-5-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518213732.30912-1-blp@ovn.org> References: <20180518213732.30912-1-blp@ovn.org> X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 5/7] ovs-sim, ovs-sandbox: Turn off logging to syslog. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org There's no value in having these testing tools log to syslog. It just pollutes the system log. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- tutorial/ovs-sandbox | 12 +++++++----- utilities/ovs-sim.in | 23 ++++++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox index aa60b9bc3157..2e68a3df0f5a 100755 --- a/tutorial/ovs-sandbox +++ b/tutorial/ovs-sandbox @@ -398,7 +398,7 @@ if $ovn; then done fi fi -rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \ +rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off \ --remote=punix:"$sandbox"/db.sock \ --remote=db:Open_vSwitch,Open_vSwitch,manager_options \ $ovsdb_server_args @@ -428,6 +428,7 @@ if $ovn; then local i=$1; shift rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir \ --pidfile=$db$i.pid -vconsole:off --log-file=$db$i.log \ + -vsyslog:off \ --remote=db:$schema_name,${DB}_Global,connections \ --private-key=db:$schema_name,SSL,private_key \ --certificate=db:$schema_name,SSL,certificate \ @@ -500,7 +501,7 @@ fi run ovs-vsctl --no-wait -- init # Start ovs-vswitchd. -rungdb $gdb_vswitchd $gdb_vswitchd_ex ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file \ +rungdb $gdb_vswitchd $gdb_vswitchd_ex ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off \ --enable-dummy=$dummy -vvconn -vnetdev_dummy if $ovn; then @@ -530,16 +531,17 @@ if $ovn; then for i in $(seq $n_northds); do rungdb $gdb_ovn_northd $gdb_ovn_northd_ex ovn-northd --detach \ --no-chdir --pidfile=ovn-northd$i.pid -vconsole:off \ - --log-file=ovn-northd$i.log \ + --log-file=ovn-northd$i.log -vsyslog:off \ --ovnsb-db="$OVN_SB_DB" --ovnnb-db="$OVN_NB_DB" done for i in $(seq $n_controllers); do rungdb $gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \ - $OVN_CTRLR_PKI --detach --no-chdir --pidfile -vconsole:off --log-file + $OVN_CTRLR_PKI --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off done rungdb $gdb_ovn_controller_vtep $gdb_ovn_controller_vtep_ex \ ovn-controller-vtep --detach --no-chdir --pidfile -vconsole:off \ - $OVN_CTRLR_PKI --log-file --ovnsb-db=unix:"$sandbox"/ovnsb_db.sock + $OVN_CTRLR_PKI --log-file -vsyslog:off \ + --ovnsb-db=unix:"$sandbox"/ovnsb_db.sock fi cat < X-Patchwork-Id: 916623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhdl641rz9s2k for ; Sat, 19 May 2018 07:49:15 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7AA8EDA3; Fri, 18 May 2018 21:37:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 86FE2D9B for ; Fri, 18 May 2018 21:37:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9AE16D3 for ; Fri, 18 May 2018 21:37:45 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 085D4E0006; Fri, 18 May 2018 23:37:44 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:31 -0700 Message-Id: <20180518213732.30912-6-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518213732.30912-1-blp@ovn.org> References: <20180518213732.30912-1-blp@ovn.org> X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 6/7] ovs-vsctl, ovn-nbctl, ovn-sbctl, vtep-ctl: Parse options before logging. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org These utilities logged the command very early, before parsing the options or the command. This meant that logging options (like --log-file or -vsyslog:off) weren't considered for the purpose of logging the command. This fixes the problem. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- lib/db-ctl-base.c | 8 +++----- lib/db-ctl-base.h | 2 +- ovn/utilities/ovn-nbctl.c | 9 +++------ ovn/utilities/ovn-sbctl.c | 8 +++----- utilities/ovs-vsctl.c | 8 +++----- vtep/vtep-ctl.c | 8 +++----- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index bfd7a54a8b5a..4e31e9a0a358 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -2046,12 +2046,10 @@ ctl_default_db(void) * database, otherwise false. (Not very smart, so it's prone to false * positives.) */ bool -ctl_might_write_to_db(char **argv) +ctl_might_write_to_db(const struct ctl_command *commands, size_t n) { - for (; *argv; argv++) { - const struct ctl_command_syntax *p = shash_find_data(&all_commands, - *argv); - if (p && p->mode == RW) { + for (size_t i = 0; i < n; i++) { + if (commands[i].syntax->mode == RW) { return true; } } diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index d8c4db2c6b3c..f246505325a4 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -155,7 +155,7 @@ struct ctl_command { struct table *table; }; -bool ctl_might_write_to_db(char **argv); +bool ctl_might_write_to_db(const struct ctl_command *, size_t n); const char *ctl_get_db_cmd_usage(void); const char *ctl_list_db_tables_usage(void); diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 6f133772d222..10ead0fc5ffd 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -97,7 +97,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -106,16 +105,14 @@ main(int argc, char *argv[]) nbctl_cmd_init(); - /* Log our arguments. This is often valuable for debugging systems. */ - args = process_escape_args(argv); - VLOG(ctl_might_write_to_db(argv) ? VLL_INFO : VLL_DBG, - "Called as %s", args); - /* Parse command line. */ + char *args = process_escape_args(argv); shash_init(&local_options); parse_options(argc, argv, &local_options); commands = ctl_parse_commands(argc - optind, argv + optind, &local_options, &n_commands); + VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, + "Called as %s", args); if (timeout) { time_alarm(timeout); diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index 9576119445bc..cfbe57313df9 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -100,7 +100,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -109,15 +108,14 @@ main(int argc, char *argv[]) sbctl_cmd_init(); - /* Log our arguments. This is often valuable for debugging systems. */ - args = process_escape_args(argv); - VLOG(ctl_might_write_to_db(argv) ? VLL_INFO : VLL_DBG, "Called as %s", args); - /* Parse command line. */ + char *args = process_escape_args(argv); shash_init(&local_options); parse_options(argc, argv, &local_options); commands = ctl_parse_commands(argc - optind, argv + optind, &local_options, &n_commands); + VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, + "Called as %s", args); if (timeout) { time_alarm(timeout); diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 6933266c5a39..3dd74a186ae0 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -136,7 +136,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -145,15 +144,14 @@ main(int argc, char *argv[]) vsctl_cmd_init(); - /* Log our arguments. This is often valuable for debugging systems. */ - args = process_escape_args(argv); - VLOG(ctl_might_write_to_db(argv) ? VLL_INFO : VLL_DBG, "Called as %s", args); - /* Parse command line. */ + char *args = process_escape_args(argv); shash_init(&local_options); parse_options(argc, argv, &local_options); commands = ctl_parse_commands(argc - optind, argv + optind, &local_options, &n_commands); + VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, + "Called as %s", args); if (timeout) { time_alarm(timeout); diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c index 0ae7d4621e60..c89ec503453c 100644 --- a/vtep/vtep-ctl.c +++ b/vtep/vtep-ctl.c @@ -99,7 +99,6 @@ main(int argc, char *argv[]) struct shash local_options; unsigned int seqno; size_t n_commands; - char *args; set_program_name(argv[0]); fatal_ignore_sigpipe(); @@ -108,15 +107,14 @@ main(int argc, char *argv[]) vtep_ctl_cmd_init(); - /* Log our arguments. This is often valuable for debugging systems. */ - args = process_escape_args(argv); - VLOG(ctl_might_write_to_db(argv) ? VLL_INFO : VLL_DBG, "Called as %s", args); - /* Parse command line. */ + char *args = process_escape_args(argv); shash_init(&local_options); parse_options(argc, argv, &local_options); commands = ctl_parse_commands(argc - optind, argv + optind, &local_options, &n_commands); + VLOG(ctl_might_write_to_db(commands, n_commands) ? VLL_INFO : VLL_DBG, + "Called as %s", args); if (timeout) { time_alarm(timeout); From patchwork Fri May 18 21:37:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 916624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40nhfC2dXcz9s37 for ; Sat, 19 May 2018 07:49:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 51F15DA0; Fri, 18 May 2018 21:37:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 37B5FD54 for ; Fri, 18 May 2018 21:37:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 21341D3 for ; Fri, 18 May 2018 21:37:46 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 5F117E0004; Fri, 18 May 2018 23:37:46 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Fri, 18 May 2018 14:37:32 -0700 Message-Id: <20180518213732.30912-7-blp@ovn.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180518213732.30912-1-blp@ovn.org> References: <20180518213732.30912-1-blp@ovn.org> MIME-Version: 1.0 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 7/7] ovs-sim: Support backup and clustered databases for ovn. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- Documentation/ref/ovs-sim.1.rst | 24 ++++- utilities/ovs-sim.in | 193 +++++++++++++++++++++++++++++++++++----- 2 files changed, 194 insertions(+), 23 deletions(-) diff --git a/Documentation/ref/ovs-sim.1.rst b/Documentation/ref/ovs-sim.1.rst index faeee1791050..ced1d5d2ef69 100644 --- a/Documentation/ref/ovs-sim.1.rst +++ b/Documentation/ref/ovs-sim.1.rst @@ -147,12 +147,32 @@ OVN Commands These commands interact with OVN, the Open Virtual Network. -``ovn_start`` +``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 @@ -195,7 +215,7 @@ Here’s a primitive OVN "scale test" (adjust the scale by changing ``n`` in the first line:: n=200; export n - ovn_start + ovn_start --sbdb-model=clustered net_add n1 ovn-nbctl ls-add br0 for i in `seq $n`; do diff --git a/utilities/ovs-sim.in b/utilities/ovs-sim.in index 4ec5898afa82..24c1da0a93e3 100755 --- a/utilities/ovs-sim.in +++ b/utilities/ovs-sim.in @@ -235,38 +235,189 @@ EOF } export -f net_attach +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 <&2 "$FUNCNAME: no arguments accepted (use --help for help)" - return 1 - fi + 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" - exit 1 + return 1 fi - daemon_opts="--detach --no-chdir --pidfile -vconsole:off -vsyslog:off --log-file" - for db in ovn-sb ovn-nb; do - mkdir "$sim_base"/$db - touch "$sim_base"/$db/.$db.db.~lock~ - as $db ovsdb-tool create "$sim_base"/$db/$db.db "$sim_srcdir"/ovn/$db.ovsschema - as $db ovsdb-server --remote=punix:"$sim_base"/$db/$db.sock "$sim_base"/$db/$db.db $daemon_opts - done - - OVN_NB_DB=unix:$sim_base/ovn-nb/ovn-nb.sock; export OVN_NB_DB - OVN_SB_DB=unix:$sim_base/ovn-sb/ovn-sb.sock; export OVN_SB_DB + ovn_start_db nb "$nbdb_model" "$nbdb_servers" "$sim_srcdir"/ovn/ovn-nb.ovsschema + ovn_start_db sb "$sbdb_model" "$sbdb_servers" "$sim_srcdir"/ovn/ovn-sb.ovsschema ovn-nbctl init ovn-sbctl init @@ -303,7 +454,7 @@ EOF 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=unix:$sim_base/ovn-sb/ovn-sb.sock \ + -- 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 \