2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 04:47:49 +00:00

332 Commits

Author SHA1 Message Date
Ben Pfaff
8ba37945d6 python: Implement "vlog/reopen" unixctl command in Python vlog.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-22 10:17:05 -07:00
Ben Pfaff
53cf9963cc python: Break unixctl implementation into registry, client, and server.
I wish to add some unixctl commands to the Python vlog module.  However,
importing ovs.unixctl in ovs.vlog creates a circular dependency, because
ovs.unixctl imports ovs.vlog already.  The solution, in this commit, is to
break the unixctl module into three parts: a register (ovs.unixctl) that
does not depend on ovs.vlog, and client (ovs.unixctl.client) and server
(ovs.unixctl.server) modules that do.  This breaks the circular dependency.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-22 10:17:05 -07:00
Ben Pfaff
853d10830f Use PYTHONDONTWRITEBYTECODE=yes for invoking Python for build or test.
An upcoming commit will break the ovs.vlog module into an ovs.vlog package
with submodules.  This commit makes switching between trees with the old
structure and those with the new structure much easier.

This commit works by setting PYTHONDONTWRITEBYTECODE=yes in Python
invocations from the build system and testing.  This keeps Python 2.6+ from
creating .pyc and .pyo files.  Creating .py[co] works OK for any given
version of Open vSwitch, but it causes trouble if you switch from a version
with foo/__init__.py into an (older) version with plain foo.py, since
foo/__init__.pyc will cause Python to ignore foo.py.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-22 10:17:00 -07:00
Ben Pfaff
06f2a05360 Fix typo in "PYTHONPATH".
Reported-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-22 10:12:49 -07:00
Raju Subramanian
e0edde6fee Global replace of Nicira Networks.
Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc.

Feature #10593
Signed-off-by: Raju Subramanian <rsubramanian@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-05-02 17:08:02 -07:00
Ben Pfaff
c640c04f64 json: Correct position tracking in JSON parser implementations.
When json_lex_input() returns false, the parser does not consume the byte
passed in.  That byte will get processed again in the next iteration of
the json_parser_feed() loop.  Therefore, until now, this code has
double-counted bytes that cause a false return from json_lex_input().

This fixes the problem.  Every input byte is now counted only once.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-04-26 09:48:28 -07:00
Ansis Atteka
8d25d9a254 ovs-test: Enhancements to the ovs-test tool
-Implemented support for ovs-test client, so that it could automatically
spawn an ovs-test server process from itself. This reduces the number of
commands the user have to type to get tests running.
-Automated creation of OVS bridges and ports (for VLAN and GRE tests), so that
user would not need to invoke ovs-vsctl manually to switch from direct, 802.1Q
and GRE tests.
-Fixed some pylint reported warnings.
-Fixed ethtool invocation so that we always try to query the physical interface
to get the driver name and version.
-and some others enhancements.

The new usage:
Node1:ovs-test -s 15531
Node2:ovs-test -c 127.0.0.1,1.1.1.1 192.168.122.151,1.1.1.2 -d -l 125 -t gre

Signed-off-by: Ansis Atteka <aatteka@nicira.com>
2012-04-18 14:56:01 -07:00
Ethan Jackson
f1936eb651 stream: By default disable probing on unix sockets.
There isn't a lot of value in sending inactivity probes on unix
sockets.  This patch changes the default to disable them.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-04-12 00:43:22 -07:00
Ethan Jackson
bceb55c8ba python: Honor zero probe interval in reconnect.py
The python reconnect library attempted to send a probe every 0
milliseconds instead of disabling probing when the probe_interval
was zero.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-04-12 00:43:22 -07:00
Ben Pfaff
2f92678735 ovsdb-idl: Improve documentation.
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-04-12 08:28:14 -07:00
Ben Pfaff
94fbe1aae2 ovsdb-idl: Improve ovsdb_idl_txn_increment() interface.
The previous interface was just bizarre.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-04-12 08:28:13 -07:00
Ben Pfaff
854a94d9d2 ovsdb-idl: Simplify transaction retry.
Originally the IDL transaction state machine had a return value
TXN_TRY_AGAIN to signal the client to wait for a change in the database and
then retry its transaction.  However, this logic was incomplete, because
it was possible for the database to change before the reply to the
transaction RPC was received, in which case the client would wait for a
further change.  Commit 4fdfe5ccf84c (ovsdb-idl: Prevent occasional hang
when multiple database clients race.) fixed the problem by breaking
TXN_TRY_AGAIN into two status codes, TXN_AGAIN_WAIT that meant to wait for
a further change and TXN_AGAIN_NOW that meant that a change had already
occurred so try again immediately.

This is correct enough, but it is more complicated than necessary.  It is
simpler and just as correct to use a single "try again" status that
requires the client to wait for a change relative to the database contents
*before* the transaction was committed.  This commit makes that change.
It also changes ovsdb_idl_run()'s return type from bool to void because
its return type is hardly useful anymore.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-04-12 08:19:01 -07:00
Ethan Jackson
75c8be3c0a unixctl.py: Allow callers to manually set unixctl version.
Some clients of unixctl.py may want to use a different version than
the one supplied in ovs.version.VERSION.  This patch supports an
optional manual override of this value.

Feature #10383.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-31 01:12:44 -07:00
Ben Pfaff
8a07709cb8 configure: Remove --with-build-number.
From early days, Nicira used the --with-build-number option to configure to
stamp our internal builds.  We've since switched to another scheme, so
this option is obsolete.

Good riddance.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-19 10:07:09 -07:00
Ben Pfaff
c95ca86e67 python: Fix "make distcheck" error on version.py.
The generated version.py has to go in the srcdir and has to be regenerated
based on config.status, which breaks "make distcheck" because it
write-protects the srcdir.  However, the contents of version.py only change
when the version number changes, so we can just "touch" it when it doesn't
really need to change.

The same pattern is used elsewhere in the tree for other files in the same
situation, e.g. the various RPM spec files.

Reported-by: Chris Wright <chrisw@sous-sol.org>
Acked-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-12 12:30:44 -07:00
Ben Pfaff
746cb7604e ovsdb-doc: Use minus sign in negative numbers in nroff output.
ovs-vswitchd.conf.db.5 has autogenerated text "at least -1" in one place.
This '-' should be a minus sign, but ovsdb-doc was generating it as a
hyphen.

Found by lintian.

Reported-by: Thomas Goirand <zigo@debian.org>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-12 10:13:38 -07:00
Ethan Jackson
bf42f674e7 idl: Convert python daemons to utilize SchemaHelper.
The recently added SchemaHelper class significantly simplifies IDL
instantiation in Python.  This commit converts all users of the old
method to the new method, and removes support for the old method.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-09 13:37:39 -08:00
Ethan Jackson
c9a2d670eb python: Make build number format consistent with C.
The C code displays the build number as the empty string when 0,
and as +build<num> otherwise.  This commit updates version.py to be
consistent and tests that it is in the unit tests.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-07 16:50:16 -08:00
Ben Pfaff
7921b912de stream-unix: Do not bind a name for client sockets.
There's no reason for a Unix domain client socket to bind a name.  I don't
know why we've always done that.  Stevens's "Unix Network Programming"
Unix domain socket client example doesn't do a bind.

Removes the 'unlink_path' parameter from new_fd_stream() since it is now
always passed as NULL.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 16:33:15 -08:00
Ben Pfaff
daad931643 python socket_util: Use correct fatal_signal function on error path.
The correct function to call here is "remove_file_to_unlink".  That is,
since the file has already been unlinked there is no need to keep it on
the list of files to unlink.

However, "unlink_file_now" simplifies the code, so we might as well use
that.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 16:33:14 -08:00
Ben Pfaff
eaae5809c0 python socket_util: Don't try to unbind None bind_path.
This bug is not exposed in the current tree, because no existing caller
passes None as bind_path.

Signed-off-by: Ben Pfaff <blp@nicira.com>
2012-03-07 16:33:14 -08:00
Ethan Jackson
ad0991e687 python: Implement new SchemaHelper class.
The new SchemaHelper class makes it easier to prune database
schemas intended for the Python IDL.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-02 13:49:28 -08:00
Ethan Jackson
0a68ffd234 python: Port unixctl to Python.
Many of the currently implemented Python daemons, and likely many
daemons to be implemented in the future, could benefit from unixctl
support even if only to implement "exit" and "version" commands.
This patch implements unixctl in Python.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-02 13:30:32 -08:00
Ethan Jackson
ffc86c0db7 python: Add ovs_error() helper function to Python.
The ovs_error() and ovs_fatal() helper functions are useful enough
to be ported to Python.  A user will be added in a future commit.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-02 13:30:25 -08:00
Ethan Jackson
4fb7d81426 python: New method to retrieve OVS version at runtime.
Version information is typically fairly useful when debugging Open
vSwitch.  This patch adds a new version.py module which python code
can use to report its version to callers.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-02 13:30:25 -08:00
Ethan Jackson
79982e900b tests: Add code coverage for Python.
Adds support for Ned Batchelder's code coverage tool to the
test suite. http://nedbatchelder.com/code/coverage/

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-02 13:30:25 -08:00
Ethan Jackson
66eb76d0fc jsonrpc.py: Don't swallow errors in transact_block().
If a server returned an error in response to a request,
transact_block() would ignore it.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
2012-03-02 13:30:25 -08:00
Ben Pfaff
2c8fcc9cd6 daemon: Better log when fork child dies early from signals.
On one machine, "/etc/init.d/openvswitch-switch start" failed to start
with:

   ovs-vswitchd: fork child failed to signal startup (Success)
   Starting ovs-vswitchd ... failed!

"strace" revealed that the fork child was actually segfaulting, but the
message output didn't indicate that in any way.  This commit fixes the
log message (but not the segfault itself).

Reported-by: Michael Hu <mhu@nicira.com>
Bug #8457.
2011-11-28 12:33:34 -08:00
Ansis Atteka
0be6140a9a ovs-test: A new tool that allows to diagnose connectivity and performance issues
This tool will be a replacement for the current ovs-vlan-test
utility. Besides from connectivity issues it will also be able
to detect performance related issues in Open vSwitch setups.
Currently it uses UDP and TCP protocols for stressing.

Issue #6976
2011-11-18 10:39:20 -08:00
Ben Pfaff
4fdfe5ccf8 ovsdb-idl: Prevent occasional hang when multiple database clients race.
When a client of the IDL tries to commit a read-modify-write transaction
but the database has changed in the meantime, the IDL tells its client to
wait for the IDL to change and then try the transaction again by returning
TXN_TRY_AGAIN.  The "wait for the IDL to change" part is important because
there's no point in retrying the transaction before the IDL has received
the database updates (the transaction would fail in the same way all over
again).

However, the logic was incomplete: the database update can be received
*before* the reply to the transaction RPC (I think that in the current
ovsdb-server implementation this will always happen, in fact).  When this
happens, the right thing to do is to retry the transaction immediately;
if we wait, then we're waiting for an additional change to the database
that may never come, causing an indefinite hang.

This commit therefore breaks the "try again" IDL commit status code
into two, one that means "try again immediately" and another that means
"wait for a change then try again".  When an update is processed after a
transaction is committed but before the reply is received, the "try again
now" tells the IDL client not to wait for another database change before
retrying its transaction.

Bug #5980.
Reported-by: Ram Jothikumar <rjothikumar@nicira.com>
Reproduced-by: Alex Yip <alex@nicira.com>
2011-10-31 09:15:14 -07:00
Ben Pfaff
dae57238bc ovs.db.types: Consistently use commas in formatting large numbers.
Suggested-by: Justin Pettit <jpettit@nicira.com>
2011-10-12 10:20:37 -07:00
Ben Pfaff
e44a6fe503 ovs.daemon: Fix bug introduced by "pychecker" warning fixes.
Commit 591c20651f1 "daemon.py: Don't shadow built-in 'file' variable"
changed most instances of "file" to "file_handle" but missed this one.

I'm not certain that this solves a real problem, but it still seems wrong.

Bug #7533.
2011-09-29 07:30:51 -07:00
Ben Pfaff
723a8d23f5 ovs.daemon: Fix semantics of --pidfile option.
The --pidfile option is supposed to work like this:

   * Without --pidfile, you don't get a pidfile.
   * With --pidfile, you get the default pidfile.
   * With --pidfile=FILE, you get FILE as your pidfile.

However, it actually worked like this:

   * Without --pidfile, you got the default pidfile.
   * With --pidfile, you got no pidfile at all.
   * With --pidfile=FILE, you got FILE as your pidfile.

This is because of the semantics of "default" in argparse.  It is
documented as:

    The default keyword argument of add_argument(), whose value defaults to
    None, specifies what value should be used if the command-line argument
    is not present.  For optional arguments, the default value is used when
    the option string was not present at the command line.

We actually want "const", which is documented under the description of
nargs="?" as:

    If no command-line argument is present, the value from default will be
    produced.  Note that for optional arguments, there is an additional
    case - the option string is present but not followed by a command-line
    argument.  In this case the value from const will be produced.

Bug #7533.
2011-09-29 07:30:51 -07:00
Ethan Jackson
3a656eafb9 python: Upgrade to vlog.
This patch upgrades the library code in the python/ovs directory to
the new vlog module.
2011-09-27 14:51:49 -07:00
Ethan Jackson
b153e66790 python: Upgrade daemon module to argparse.
This patch also updates it's callers.
2011-09-27 14:51:49 -07:00
Ethan Jackson
ec394dad53 stream.py: Make usage() function return a string.
This will marginally simplify a future patch.
2011-09-27 14:50:26 -07:00
Ethan Jackson
8ed182d80e python: Create new vlog module.
Currently, each python daemon has to come up with it's own logging
solution.  These logging strategies are not consistent across the
python code or with the C vlog module.  This patch adds a new
logging module which hopes to solve the problem.  This new module
generates log messages in a manner consistent with the C code.
Furthermore, it can easily be extended to support things like rate
limiters in the future.

This patch does not update any python code to use the new module.
2011-09-27 14:50:26 -07:00
Ethan Jackson
6c88547dd0 python: Backport argparse to older platforms.
Argparse has some convenient advantages over optparse including the
ability to handle optional arguments to flags.  It also supports
parsing arguments as well as options.

This patch copies argparse.py from Python 2.7 into a newly created
compat directory.  It made some very minor syntactic updates in the
process.  Platforms which have a Python version too old to include
argparse by default will have this compat version installed as a
workaround.
2011-09-27 11:38:30 -07:00
Ben Pfaff
cd1b3f63f3 json.py: Typo in parsing code. 2011-09-26 11:43:25 -07:00
Ethan Jackson
26bb0f3129 python: Style cleanup.
This patch does minor style cleanups to the code in the python and
tests directory.  There's other code floating around that could use
similar treatment, but updating it is not convenient at the moment.
2011-09-24 16:32:54 -07:00
Ethan Jackson
4ad07e6063 ovsuuid.py: Fix use of undefined symbol.
Found by pychecker.
2011-09-24 00:16:06 -07:00
Ben Pfaff
8cdf034974 python: Implement write support in Python IDL for OVSDB.
Until now, the Python bindings for OVSDB have not supported writing to the
database.  Instead, writes had to be done with "ovs-vsctl" subprocesses.
This commit adds write support and brings the Python bindings in line with
the C bindings.

This commit deletes the Python-specific IDL tests in favor of using the
same tests as the C version of the IDL, which now pass with both
implementations.

This commit updates the two users of the Python IDL to use the new write
support.  I tested this updates only by writing unit tests for them,
which appear in upcoming commits.
2011-09-23 14:23:16 -07:00
Ben Pfaff
7cba02e442 ovs.db.types: Add table reference to ovs.db.types.BaseType.
Until now ovs.db.types.BaseType has kept track of the name of the
referenced table but not a reference to it.  This commit renames the
ref_table attribute to ref_table_name and adds a new ref_table attribute
whose value is a reference to the named table.

This will be useful in an upcoming commit where table references are
actually followed.
2011-09-23 09:10:45 -07:00
Ben Pfaff
5c3a4660c0 python: Accept multiple forms of strings and lists when parsing JSON.
The JSON parser in OVS always yields unicode strings and lists, never
non-unicode strings or tuples, but it's easy to create them when building
JSON elsewhere, so accept both forms.
2011-09-23 09:10:45 -07:00
Ben Pfaff
843fb01b61 python: Change 'clone' function names to 'copy'.
It seems that 'copy' is the proper name for this kind of function in
Python, based on the existence of dict.copy().
2011-09-23 09:10:45 -07:00
Ben Pfaff
49c541dc11 ovs.ovsuuid: Get rid of ovs.ovsuuid.UUID class.
This class only caused unnecessary confusion.  This commit changes all of
its methods into top-level functions.
2011-09-23 09:10:45 -07:00
Ben Pfaff
b2edc4e7d8 ovs.jsonrpc: Include result in Message.__str__() output.
This was overlooked in the initial implementation.  Including the result
member makes logging output more useful.
2011-09-23 09:10:44 -07:00
Ben Pfaff
9e4f0157ec ovs.db.data: Make Datum.check_constraints() work.
This code never got tested and so didn't work.

This does not fix an actual bug because Datum.check_constraints() does not
have any existing users.
2011-09-23 09:10:44 -07:00
Ben Pfaff
cf5404f67d ovs.db.data: Fix Atom.new()'s handling of Boolean values.
Boolean values have Boolean type, not real type.

This does not fix an actual bug because Atom.new() does not have existing
users.
2011-09-23 09:10:44 -07:00
Ben Pfaff
169390eed0 ovs.json: Remove commented-out debug code.
This must have slipped into an old commit by accident.
2011-09-23 09:10:44 -07:00