Skip to content

Commit

Permalink
New utility ovs-vsctl.
Browse files Browse the repository at this point in the history
  • Loading branch information
blp committed Sep 14, 2009
1 parent 39fb088 commit 3b135da
Show file tree
Hide file tree
Showing 11 changed files with 1,001 additions and 8 deletions.
15 changes: 13 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,22 @@ ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
SUFFIXES = .in
.in:
$(PERL) $(srcdir)/soexpand.pl -I$(srcdir) < $< | \
sed -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
sed \
-e 's,[@]PKIDIR[@],$(PKIDIR),g' \
-e 's,[@]LOGDIR[@],$(LOGDIR),g' \
-e 's,[@]PERL[@],$(PERL),g' \
-e 's,[@]PYTHON[@],$(PYTHON),g' \
-e 's,[@]RUNDIR[@],$(RUNDIR),g' \
-e 's,[@]VERSION[@],$(VERSION),g' \
-e 's,[@]localstatedir[@],$(localstatedir),g' \
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
-e 's,[@]PERL[@],$(PERL),g' > $@
-e 's,[@]sysconfdir[@],$(sysconfdir),g' \
> [email protected]
@if head -n 1 [email protected] | grep -q '#!'; then \
echo chmod +x [email protected]; \
chmod +x [email protected]; \
fi
mv [email protected] $@

include lib/automake.mk
include ofproto/automake.mk
Expand Down
7 changes: 5 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ The main components of this distribution are:
to be installed on a Citrix XenServer host as a drop-in
replacement for its switch, with additional functionality.

* ovs-appctl, a utility that can control Open vSwitch daemons,
adjusting their logging levels among other uses.
* ovs-vsctl, a utility for querying and updating the configuration
of ovs-vswitchd.

* ovs-appctl, a utility that sends commands to running Open
vSwitch daemons.

Open vSwitch also provides an OpenFlow implementation and tools for
those interested in OpenFlow but not additional Open vSwitch features:
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ OVS_CHECK_LOGDIR
OVS_CHECK_CURSES
OVS_CHECK_LINUX_VT_H
OVS_CHECK_PCRE
OVS_CHECK_PYTHON
OVS_CHECK_IF_PACKET
OVS_CHECK_STRTOK_R

Expand Down
28 changes: 28 additions & 0 deletions m4/openvswitch.m4
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,31 @@ AC_DEFUN([OVS_CHECK_PCRE],
if test "$HAVE_PCRE" = yes; then
AC_DEFINE([HAVE_PCRE], [1], [Define to 1 if libpcre is installed.])
fi])

dnl Checks for Python 2.x, x >= 4.
AC_DEFUN([OVS_CHECK_PYTHON],
[AC_ARG_VAR([PYTHON], [path to Python 2.x])
AC_CACHE_CHECK(
[for Python 2.x for x >= 4],
[ovs_cv_python],
[if test -n "$PYTHON"; then
ovs_cv_python=$PYTHON
else
ovs_cv_python=no
for binary in python python2.4 python2.5; do
ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for dir in $PATH; do
IFS=$ovs_save_IFS
test -z "$dir" && dir=.
if test -x $dir/$binary && $dir/$binary -c 'import sys
if sys.hexversion >= 0x02040000 and sys.hexversion < 0x03000000:
sys.exit(0)
else:
sys.exit(1)'; then
ovs_cv_python=$dir/$binary
break 2
fi
done
done
fi])
PYTHON=$ovs_cv_python])
1 change: 1 addition & 0 deletions tests/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TESTSUITE_AT = \
tests/lcov-pre.at \
tests/library.at \
tests/stp.at \
tests/ovs-vsctl.at \
tests/lcov-post.at
TESTSUITE = $(srcdir)/tests/testsuite
DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE)
Expand Down
257 changes: 257 additions & 0 deletions tests/ovs-vsctl.at
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
AT_BANNER([ovs-vsctl unit tests -- real bridges])

dnl RUN_OVS_VSCTL(COMMAND, ...)
dnl
dnl Executes each ovs-vsctl COMMAND on a file named "conf" in the
dnl current directory. Creates "conf" if it does not already exist.
m4_define([RUN_OVS_VSCTL],
[: >> conf
m4_foreach([command], [$@], [ovs-vsctl --no-reload --config=conf command
])])

dnl CHECK_BRIDGES(BRIDGE, ...)
dnl
dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges,
dnl which must be in alphabetical order.
m4_define([CHECK_BRIDGES],
[AT_CHECK(
[RUN_OVS_VSCTL([list-br])],
[0],
[m4_foreach([port], [$@], [port
])])
m4_foreach([port], [$@], [AT_CHECK([RUN_OVS_VSCTL([br-exists port])])])
AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2])])

dnl CHECK_PORTS(BRIDGE, PORT[, PORT...])
dnl
dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified
dnl list of ports, which must be in alphabetical order. Also checks
dnl that "ovs-vsctl port-to-br" reports that each port is
dnl in BRIDGE.
m4_define([CHECK_PORTS],
[AT_CHECK(
[RUN_OVS_VSCTL([list-ports $1])],
[0],
[m4_foreach([port], m4_cdr($@), [port
])])
AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [], [ovs-vsctl: no port named $1
])
m4_foreach(
[port], m4_cdr($@),
[AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1
])])])

dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...])
dnl
dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified
dnl list of ifaces, which must be in alphabetical order. Also checks
dnl that "ovs-vsctl iface-to-br" reports that each interface is
dnl in BRIDGE.
m4_define([CHECK_IFACES],
[AT_CHECK(
[RUN_OVS_VSCTL([list-ifaces $1])],
[0],
[m4_foreach([iface], m4_cdr($@), [iface
])])
AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [], [ovs-vsctl: no interface named $1
])
m4_foreach(
[iface], m4_cdr($@),
[AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1
])])])

AT_SETUP([add-br a])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL([add-br a])])
AT_CHECK([cat conf], [0], [dnl
bridge.a.port=a
])
CHECK_BRIDGES([a])
CHECK_PORTS([a])
CHECK_IFACES([a])
AT_CLEANUP

AT_SETUP([add-br a, add-br b])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])])
AT_CHECK([cat conf], [0], [dnl
bridge.a.port=a
bridge.b.port=b
])
CHECK_BRIDGES([a], [b])
CHECK_PORTS([a])
CHECK_IFACES([a])
CHECK_PORTS([b])
CHECK_IFACES([b])
AT_CLEANUP

AT_SETUP([add-br a, add-br b, del-br a])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])])
AT_CHECK([cat conf], [0], [dnl
bridge.b.port=b
])
CHECK_BRIDGES([b])
CHECK_PORTS([b])
CHECK_IFACES([b])
AT_CLEANUP

AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-br b],
[add-port a a1],
[add-port b b1],
[del-br a])])
AT_CHECK([cat conf], [0],
[bridge.b.port=b
bridge.b.port=b1
])
CHECK_BRIDGES([b])
CHECK_PORTS([b], [b1])
CHECK_IFACES([b], [b1])
AT_CLEANUP

AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-bond a bond0 a1 a2 a3])])
AT_CHECK([cat conf], [0], [dnl
bonding.bond0.slave=a1
bonding.bond0.slave=a2
bonding.bond0.slave=a3
bridge.a.port=a
bridge.a.port=bond0
])
CHECK_BRIDGES([a])
CHECK_PORTS([a], [bond0])
CHECK_IFACES([a], [a1], [a2], [a3])
AT_CLEANUP

AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-br b],
[add-port a a1],
[add-port b b1],
[del-port a a1])])
AT_CHECK([cat conf], [0], [dnl
bridge.a.port=a
bridge.b.port=b
bridge.b.port=b1
])
CHECK_BRIDGES([a], [b])
CHECK_PORTS([a])
CHECK_IFACES([a])
CHECK_PORTS([b], [b1])
CHECK_IFACES([b], [b1])
AT_CLEANUP

AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port a bond0])
AT_KEYWORDS([ovs-vsctl])
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-bond a bond0 a1 a2 a3],
[del-port a bond0])])
AT_CHECK([cat conf], [0], [dnl
bridge.a.port=a
])
CHECK_BRIDGES([a])
CHECK_PORTS([a])
AT_CLEANUP

AT_BANNER([ovs-vsctl unit tests -- fake bridges])

m4_define([SIMPLE_FAKE_CONF], [dnl
bridge.xenbr0.port=eth0
bridge.xenbr0.port=eth0.9
bridge.xenbr0.port=xapi1
bridge.xenbr0.port=xenbr0
iface.xapi1.fake-bridge=true
iface.xapi1.internal=true
vlan.eth0.9.tag=9
vlan.xapi1.tag=9
])

AT_SETUP([simple fake bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
AT_CHECK([RUN_OVS_VSCTL(
[add-br xenbr0],
[add-port xenbr0 eth0],
[add-br xapi1 xenbr0 9],
[add-port xapi1 eth0.9])])
AT_CHECK([cat conf], [0], [SIMPLE_FAKE_CONF])
CHECK_BRIDGES([xenbr0], [xapi1])
CHECK_PORTS([xenbr0], [eth0])
CHECK_IFACES([xenbr0], [eth0])
CHECK_PORTS([xapi1], [eth0.9])
CHECK_IFACES([xapi1], [eth0.9])
AT_CLEANUP

AT_SETUP([simple fake bridge + del-br fake bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
AT_DATA([conf], [SIMPLE_FAKE_CONF])
AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
AT_CHECK([cat conf], [0], [dnl
bridge.xenbr0.port=eth0
bridge.xenbr0.port=xenbr0
])
CHECK_BRIDGES([xenbr0])
CHECK_PORTS([xenbr0], [eth0])
CHECK_IFACES([xenbr0], [eth0])
AT_CLEANUP

AT_SETUP([simple fake bridge + del-br real bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
AT_DATA([conf], [SIMPLE_FAKE_CONF])
AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])])
AT_CHECK([cat conf], [0], [])
CHECK_BRIDGES
AT_CLEANUP

m4_define([BOND_FAKE_CONF], [dnl
bonding.bond0.slave=eth0
bonding.bond0.slave=eth1
bridge.xapi1.port=bond0
bridge.xapi1.port=bond0.11
bridge.xapi1.port=xapi1
bridge.xapi1.port=xapi2
iface.xapi2.fake-bridge=true
iface.xapi2.internal=true
vlan.bond0.11.tag=11
vlan.xapi2.tag=11
])

AT_SETUP([fake bridge on bond])
AT_KEYWORDS([ovs-vsctl fake-bridge])
AT_CHECK([RUN_OVS_VSCTL(
[add-br xapi1],
[add-bond xapi1 bond0 eth0 eth1],
[add-br xapi2 xapi1 11],
[add-port xapi2 bond0.11])])
AT_CHECK([cat conf], [0], [BOND_FAKE_CONF])
CHECK_BRIDGES([xapi1], [xapi2])
CHECK_PORTS([xapi1], [bond0])
CHECK_IFACES([xapi1], [eth0], [eth1])
CHECK_PORTS([xapi2], [bond0.11])
CHECK_IFACES([xapi2], [bond0.11])
AT_CLEANUP

AT_SETUP([fake bridge on bond + del-br fake bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
AT_DATA([conf], [BOND_FAKE_CONF])
AT_CHECK([RUN_OVS_VSCTL([del-br xapi2])])
CHECK_BRIDGES([xapi1])
CHECK_PORTS([xapi1], [bond0])
CHECK_IFACES([xapi1], [eth0], [eth1])
AT_CLEANUP

AT_SETUP([fake bridge on bond + del-br real bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
AT_DATA([conf], [BOND_FAKE_CONF])
AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
CHECK_BRIDGES
AT_CLEANUP
2 changes: 2 additions & 0 deletions tests/testsuite.at
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ See the License for the specific language governing permissions and
limitations under the License.])

AT_TESTED([ovs-vswitchd])
AT_TESTED([ovs-vsctl])

m4_include([tests/lcov-pre.at])
m4_include([tests/library.at])
m4_include([tests/stp.at])
m4_include([tests/ovs-vsctl.at])
m4_include([tests/lcov-post.at])
13 changes: 9 additions & 4 deletions utilities/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bin_PROGRAMS += \
utilities/ovs-openflowd \
utilities/ovs-wdt
noinst_PROGRAMS += utilities/nlmon
bin_SCRIPTS += utilities/ovs-pki
bin_SCRIPTS += utilities/ovs-pki utilities/ovs-vsctl
noinst_SCRIPTS += utilities/ovs-pki-cgi utilities/ovs-parse-leaks
dist_sbin_SCRIPTS += utilities/ovs-monitor

Expand All @@ -25,7 +25,9 @@ EXTRA_DIST += \
utilities/ovs-parse-leaks.in \
utilities/ovs-pki-cgi.in \
utilities/ovs-pki.8.in \
utilities/ovs-pki.in
utilities/ovs-pki.in \
utilities/ovs-vsctl.8.in \
utilities/ovs-vsctl.in
DISTCLEANFILES += \
utilities/ovs-appctl.8 \
utilities/ovs-cfg-mod.8 \
Expand All @@ -37,8 +39,10 @@ DISTCLEANFILES += \
utilities/ovs-openflowd.8 \
utilities/ovs-parse-leaks \
utilities/ovs-pki \
utilities/ovs-pki-cgi \
utilities/ovs-pki.8 \
utilities/ovs-pki-cgi
utilities/ovs-vsctl \
utilities/ovs-vsctl.8

man_MANS += \
utilities/ovs-appctl.8 \
Expand All @@ -49,7 +53,8 @@ man_MANS += \
utilities/ovs-kill.8 \
utilities/ovs-ofctl.8 \
utilities/ovs-openflowd.8 \
utilities/ovs-pki.8
utilities/ovs-pki.8 \
utilities/ovs-vsctl.8

utilities_ovs_appctl_SOURCES = utilities/ovs-appctl.c
utilities_ovs_appctl_LDADD = lib/libopenvswitch.a
Expand Down
Loading

0 comments on commit 3b135da

Please sign in to comment.