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
Ben Pfaff
cba641035b
ovs.json: Actually implement the "pretty" option for serialization.
2011-09-23 09:10:44 -07:00
Ben Pfaff
9b46cccc33
python: Avoid shadowing standard or global names.
...
Found by pychecker.
2011-09-23 09:10:44 -07:00
Ben Pfaff
28c781df8a
python: Avoid "unused parameter" warnings from pychecker.
...
pychecker ignores parameters named "_" or prefixed with "unused_".
2011-09-23 09:10:43 -07:00
Ben Pfaff
14cd095f26
ovs.db.types: Always initialize ref_type attribute.
...
The ref_type attribute was initialized on some paths but not others.
Found by pychecker.
2011-09-23 09:10:43 -07:00
Ethan Jackson
2a8859b0a4
daemon.py: Silence return warning.
...
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)
2011-09-16 18:27:33 -07:00
Ethan Jackson
591c20651f
daemon.py: Don't shadow built-in 'file' variable.
...
Pychecker considers it bad style.
2011-09-16 18:27:33 -07:00
Ethan Jackson
cadc9871c2
daemon.py: Whitespace cleanup.
...
The python style guide requires two newlines between top level
definitions. This patch also removes some trailing whitespace.
2011-09-16 16:03:31 -07:00
Ben Pfaff
44852fdf63
Mark "uninstall-local" targets phony.
2011-09-15 11:19:59 -07:00
Ben Pfaff
54658e6169
ovs.db.types: Remove write-only variable from constraintsToEnglish().
...
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
973d7411d6
python: Remove unused imports.
...
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
1f00acd0bc
ovs.stream: Remove unused parameter from usage().
...
This function has no callers. We could delete it entirely, instead.
2011-08-25 11:07:23 -07:00
Ben Pfaff
fecf78c237
ovs.ovsuuid: Fix UUID.cInitUUID invocation of re.match with too few params.
...
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
4071e24db4
ovs.jsonrpc: Fix static method Session.open() reference to 'self'.
...
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
b2a5856fef
ovs.jsonrpc: Fix static method Message.__validate_arg reference to 'self'.
...
This method needs to be an instance method because it refers to 'self'.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
6732237bee
ovs.json: Use Exception, which exists, instead of Error, which doesn't.
...
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
7550c333d3
ovs.db.idl: Fix error message format arguments.
...
There's no variable table_name.
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
c6b24dd7cd
ovs.daemon: Add missing format string argument.
...
Found by pychecker.
2011-08-25 11:07:23 -07:00
Ben Pfaff
0003748f58
ovs.daemon: Fix name of EALREADY error.
...
Found by pychecker.
2011-08-25 11:07:22 -07:00
Ben Pfaff
dbad9de126
ovs.daemon: Add missing 'global' when setting _pidfile_dev, _pidfile_ino.
...
Found by pychecker.
2011-08-25 11:07:22 -07:00
Ben Pfaff
af1eba26c3
ovs.db.idl: Fix call to ovs.db.parser.Parser constructor.
...
This bug was introduced by commit 4c0f62718f "ovs.db.idl: Improve error
reporting for bad <row-update>s."
Found by pychecker.
Bug #7006 .
2011-08-25 11:06:53 -07:00
Ben Pfaff
367da73833
python: Use enumerate() builtin function to simplify counted iteration.
...
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
8ba31bf16d
ovs.stream: Simplify logic in Stream.wait().
...
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
63b1a52133
ovs.stream: Drop Stream.get_name() since clients can use 'name' directly.
...
Suggested-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
1f9dd59cf1
ovs.stream: Use %d in place of %ld since the two are equivalent in Python.
...
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:53 -07:00
Ben Pfaff
90d9dcfc12
ovs.reconnect: Fix typo in documentation.
...
Reported-by: Reid Price <reid@nicira.com>
2011-08-24 12:06:52 -07:00
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