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>
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>
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>
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>
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.
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
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>
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.
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.
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.
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.
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.
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.
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.
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.
Pychecker complains about __read_pidfile() having too may returns.
I personally think the function is fine, but it's easy enough to
reduce them.
python/ovs/daemon.py:395: Function (__read_pidfile) has too many
returns (12)