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

207 Commits

Author SHA1 Message Date
Ben Pfaff
0a61b042a5 ovs.reconnect: Make Reconnect.Reconnect inherit from object.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
2ad4ef8920 ovs.jsonrpc: Use "not X" in place of "len(X) == 0" for testing strings.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
22bb61e9ee ovs.jsonrpc: Remove Connection.get_name()--clients can use 'name' directly.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
17af143600 ovs.jsonrpc: Remove dead class variable Message.__next_id.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
Ben Pfaff
e0b2332760 ovs.json: Optimize __dump_string().
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:05:13 -07:00
Ben Pfaff
32fcdd44c5 ovs.fatal_signal: Remove unnecessary "global" statement.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:44 -07:00
Ben Pfaff
1304578aeb ovs.fatal_signal: Reorder definitions to be more easily readable.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:44 -07:00
Ben Pfaff
71607f575e ovs.db.types: Introduce DEFAULT_MIN, DEFAULT_MAX as Type class members.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:44 -07:00
Ben Pfaff
ca2c5d3d32 ovs.db.types: Use toAtomicType() instead of open-coding it.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
f09aa106ee ovs.db.types: Simplify code to avoid try/except case.
Also fixes a typo that caused one version of the error message to have a
hyphen and the other to have a space.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
1a98f75260 ovs.db.types: Use .append instead of += for adding to lists.
Python does not do a good job of appending lists to lists.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
693e5dc748 ovs.db.schema: Factor common checks for identifiers into new function.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
c29e06be0e ovs.db.parser: Simplify code.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
bf6ec045b7 ovs.db.idl: Use top-level class to represent IDL rows.
According to Reid, there may be some disadvantages to having this class be
anonymous, for example, cannot do instance/typechecking, might be
allocating a new class for every row as well, which isn't the most memory
efficient.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
7d48f8f8bd ovs.db.idl: Actually use Idl.__modify_row()'s return value.
Idl.__parse_row_update() assumed that every change that the database server
sent down actually modified the database.  This is generally true, but
since Idl.__modify_row() already returns whether there was a change, we
might as well use it.

Reported-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
4c0f62718f ovs.db.idl: Improve error reporting for bad <row-update>s.
Strangely malformed <row-update>s could hypothetically get confusing error
message.  Using the Parser class should avoid that.

Reported-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:43 -07:00
Ben Pfaff
6a6f8d1673 ovsdb-data: Simplify converting an OVSDB datum to JSON by reordering logic.
Putting the "map" case first avoids duplicate tests.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
0233401f12 daemon: Stylistic improvement for __read_pidfile in Python implementation.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
a7675d4e56 daemon: Correct comment in Python implementation.
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
91c637960c python: Avoid using 'tuple' as a variable name.
'tuple' is a Python built-in function, so it's best to avoid using it as a
variable name.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
8758e8a373 python: Avoid using 'type' as a variable name.
'type' is a Python built-in function, so it's best to avoid using it as
a variable name.

Reported-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
d272c10ecd python: Take advantage of Python "x < y < z" syntax.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
f2d8ad13e1 python: Avoid lots of \" in quoted strings by using '' as outermost quotes.
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
b33a04c63a python: Join a list of strings instead of concatenating a long string.
Python does not do a good job of appending strings: it takes O(n**2) time
to append n strings.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
523a3bc773 python: Use getattr() and setattr() instead of __dict__.
This leaves one use of __dict__ used for iterating through attributes.
I could use dir() instead, but I was put off by this note in its
documentation in the Python Library Reference:

    Because dir() is supplied primarily as a convenience for use at an
    interactive prompt, it tries to supply an interesting set of names more
    than it tries to supply a rigorously or consistently defined set of names,
    and its detailed behavior may change across releases.  For example,
    metaclass attributes are not in the result list when the argument is a
    class.

Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:42 -07:00
Ben Pfaff
57d6a4c71b ovs.db.data: Fix bugs in Atom.is_default() and Datum.is_default().
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 11:57:14 -07:00
Ben Pfaff
9601fa824d ovs.stream: Fix logic bug in Stream.connect().
The loop here is supposed to run at least once, and to continue looping as
long as the loop body changes the current state, but this bug caused it to
continue looping until the connection completed in success or failure.  It
probably didn't cause many problems in practice because only Unix domain
socket connections are currently supported, and those connections normally
complete immediately.

Reported-by: Reid Price <reid@nicira.com>
2011-08-24 11:55:49 -07:00
Ben Pfaff
070de9bd41 python: Make invalid UTF-8 sequence messages consistent across Python versions.
Given the invalid input <C0 22>, some versions of Python report <C0> as the
invalid sequence and other versions report <C0 22> as the invalid sequence.
Similarly, given input <ED 80 7F>, some report <ED 80> and others report
<ED 80 7F> as the invalid sequence.  This caused spurious test failures for
the test "no invalid UTF-8 sequences in strings - Python", so this commit
makes the messages consistent by dropping the extra trailing byte from the
message.

I first noticed the longer sequences <C0 22> and <ED 80 7F> on Ubuntu
10.04 with python version 2.6.5-0ubuntu1, but undoubtedly it exists
elsewhere also.
2011-07-06 09:00:51 -07:00
Ben Pfaff
955400fb2f python: Fix "make install" on systems without Python.
Reported-by: 冯全树(Crab) <fqs888@126.com>
2011-06-14 09:48:23 -07:00
Ben Pfaff
d26c5b7422 python ovsdb: Fix one style inconsistency.
Reported-by: Justin Pettit <jpettit@nicira.com>
2011-06-06 09:09:47 -07:00
Ben Pfaff
6910a6e6f2 ovsdb: Implement table uniqueness constraints ("indexes"). 2011-06-06 09:09:10 -07:00
Ben Pfaff
be44585c21 tests: Fix the two Python XFAIL tests.
OVS has two Python tests that have always failed, for reasons not
understood, since they were added to the tree.  This commit fixes them.

One problem was that Python was assuming that stdout was encoded in ASCII.
Apparently the only way to "fix" this at runtime is to set PYTHONIOENCODING
to utf_8 in the environment, so this change does that.

Second, it appears that Python really doesn't like to print invalid UTF-8,
so this avoids doing that in python/ovs/json.py, instead just printing
the hexadecimal values of the invalid bytes.  For consistency, it makes
the same change to the C version.

Third, the C version of test-ovsdb doesn't check UTF-8 for consistency, it
just sends it blindly to the OVSDB server, but Python does check it and so
it bails out earlier.  This commit changes the Python version of the
"no invalid UTF-8 sequences in strings" to allow for the slight difference
in output that occurs for that reason.

Finally, test-ovsdb.py needs to convert error messages to Unicode
explicitly before printing them in the "parse-atoms" function.  I don't
really understand why, but now it works.
2011-05-24 11:32:22 -07:00
Ben Pfaff
aacea8ba43 daemon: Avoid races on pidfile creation.
Until now, if two copies of one OVS daemon started up at the same time,
then due to races in pidfile creation it was possible for both of them to
start successfully, instead of just one.  This was made worse when a
previous copy of the daemon had died abruptly, leaving a stale pidfile.

This commit implements a new pidfile creation and removal protocol that I
believe closes these races.  Now, a pidfile is asserted with "link" instead
of "rename", which prevents the race on creation, and a stale pidfile may
only be deleted by a process after it has taken a lock on it.

This may solve mysterious problems seen occasionally on vswitch restart.
I'm still puzzled by these problems, however, because I don't see anything
in our tests cases that would actually cause two copies of a daemon to
start at the same time, which as far as I can see is a necessary
precondition for the problem.
2011-04-04 10:59:19 -07:00
Ben Pfaff
00c0858987 daemon: Integrate checking for an existing pidfile into daemonize_start().
Until now, it has been the responsibility of an individual daemon to call
die_if_already_running() at an appropriate time.  A long time ago, this
had to happen *before* daemonizing, because once the process daemonized
itself there was no way to report failure to the process that originally
started the daemon.  With the introduction of daemonize_start(), this is
now possible, but we haven't been taking advantage of it.

Therefore, this commit integrates the die_if_already_running() call into
daemonize_start() and deletes the calls to it from individual daemons.
2011-04-04 10:58:55 -07:00
Ben Pfaff
af9a144207 daemon: Tolerate EINTR in fork_and_wait_for_startup().
It seems possible that a signal coming in at the wrong time could confuse
this code.  It's always best to loop on EINTR.
2011-04-04 10:58:55 -07:00
Ben Pfaff
42a49b9601 ovsdb: Force strong references to non-root tables to be persistent.
When a strong reference to a non-root table is ephemeral, the database log
can contain inconsistencies.  In particular, if the column in question is
the only reference to a row, then the row will be created in one logged
transaction but the reference to it will not be logged (because it is
ephemeral).  Thus, any later occurrence of the row later in the log (to
modify it, to delete it, or just to reference it) will yield a transaction
error and reading the database will abort at that point.

This commit fixes the problem by forcing any column with a strong reference
to a non-root table to be persistent.

The change to ovsdb_schema_from_json() looks bigger than it really is: it
just swaps the order of two operations on the schema and updates their
comments.  Similarly for the update to ovs.db.DbSchema.__init__().

Bug #5144.
Reported-by: Sujatha Sumanth <ssumanth@nicira.com>
Bug #5149.
Reported-by: Ram Jothikumar <rjothikumar@nicira.com>
2011-03-31 16:43:43 -07:00
Ben Pfaff
18e124a20b daemon: Avoid redundant code in already_running().
This function substantially duplicated read_pidfile(), so reuse that
code instead.
2011-03-29 10:09:47 -07:00
Ben Pfaff
2159de8391 daemon: Write "already running" message to log also.
Otherwise it's hard to diagnose later if the daemon failed to start because
it thinks that it is already running.
2011-03-29 10:09:23 -07:00
Andrew Evans
34d84bb951 reconnect.py: Fix Python 2.4 compatibility break.
Commit 5eda645e36 (ovsdb-server: Report time since last connect and disconnect
for each manager.) used a conditional expression in reconnect.py. That syntax
is only supported in Python 2.5 and later. XenServer 5.6 is based on RHEL 5,
which uses Python 2.4.3, so various OVS scripts on XenServer fail with Python
tracebacks.

Reported-by: Cedric Hobbs <cedric@nicira.com>
2011-03-15 14:42:49 -07:00
Andrew Evans
5eda645e36 ovsdb-server: Report time since last connect and disconnect for each manager.
Only the time connected (if connected) or disconnected (if disconnected) is
currently reported for each manager. Change to reporting both in seconds since
the last connect and disconnect events respectively. An empty value indicates
no previous connection or disconnection.

This can help diagnose certain connectivity problems, e.g. flapping.

Requested-by: Peter Balland <peter@nicira.com>
Bug #4833.
2011-03-14 13:10:02 -07:00
Ben Pfaff
c5f341ab19 ovsdb: Implement garbage collection. 2011-03-10 11:24:00 -08:00
Ben Pfaff
acb4f876b8 ovsdb-idlc: Initialize refType in IDL reference columns' types.
Otherwise the refType always appears to be 0 (OVSDB_REF_STRONG).

Nothing in the code that uses these structures actually uses the refType
yet, so this does not fix any existing bug, but upcoming commits will add
users.
2011-03-10 11:23:58 -08:00
Ben Pfaff
fdba672899 python/ovs/ovsuuid: Fix behavior of UUID.from_json() with no symbol table.
UUID.from_json(['named-uuid', 'x'], None) should raise an error about
invalid syntax, but instead it was raising a TypeError because it would
try to evaluate "'x' not in None".  This fixes the problem and adds a test.
2011-03-10 11:23:58 -08:00
Andrew Evans
c36cf65eda reconnect: Rename CONNECT_IN_PROGRESS state to CONNECTING (like rconn).
reconnect uses the same connection state names as rconn with the exception of
the above. This commit makes their states identical, which should reduce
confusion for people debugging connection problems.
2011-03-10 11:12:20 -08:00
Andrew Evans
eba18f0044 reconnect: Track last-disconnected time.
Commit a4613b01ab (ovsdb: Change the way connection duration time is reported
in Manager table.), pushed earlier today, requires this commit, so OVSDB has
been unbuildable from then to now.
2011-03-09 18:40:03 -08:00
Justin Pettit
da51646f6f jsonrpc.py: Import "ovs.json".
Reported-by: Giuseppe de Candia <giuseppe.decandia@gmail.com>
2011-02-21 23:56:07 -08:00
Ben Pfaff
a44d74d752 python: Use os.path.basename instead of open-coding it.
Reported-by: Justin Pettit <jpettit@nicira.com>
2011-01-12 13:51:42 -08:00
Ethan Jackson
5601839c45 python: properly initialize string length on 64bit systems.
types.py was initializing max string length to 2^64 - 1 instead of
UINT_MAX on 64 bit systems.  This commit fixes that problem.
2011-01-04 10:30:37 -08:00
Ben Pfaff
8159b984dc Implement database schema versioning.
As the database schema evolves, it might be useful to have an identifier
for the particular version in use.  This commit adds that feature.
2010-12-27 14:26:47 -08:00
Ben Pfaff
b43c6fe279 Make installation directories overridable at runtime.
This makes it possible to run tests that need access to installation
directories, such as the rundir, without having access to the actual
installation directories (/var/run is generally not world-writable), by
setting environment variables.  This is not a good way to do things in
general--usually it would be better to choose the correct directories
at configure time--so for now this is undocumented.
2010-11-29 16:29:11 -08:00