summaryrefslogtreecommitdiff
path: root/python
Commit message (Collapse)AuthorAgeFilesLines
* Makefiles: Add $(AM_V_GEN) annotations to clean up "make" output.Ben Pfaff2014-09-291-4/+4
| | | | | | | | The Open vSwitch "make" output was still pretty verbose even when configured with --enable-silent-rules. This cleans it up. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Joe Stringer <joestringer@nicira.com>
* socket_util.py: Make set_dscp() python 2.4.3 compatible.Gurucharan Shetty2014-06-241-2/+2
| | | | | | | | There is no 'errno' field in socket.error. Instead use the get_exception_errno() function to get the error number. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* timeval: Add monotonic time functionality for NetBSD and FreeBSD.Ryan Wilson2014-06-051-7/+27
| | | | | | | | | | | | | | | | This patch also checks the system platform as clock_gettime could exist on different platforms but with different values of CLOCK_MONOTONIC and different definitions of 'struct timespec'. In this case, the system call would be expected to catch the error, which is dangerous. This patch ensures Linux, NetBSD and FreeBSD platforms use clock_gettime with their corresponding correct values and definitions. All other platforms use time.time(). Signed-off-by: Ryan Wilson <wryan@nicira.com> Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
* timeval: Import ctypes Python library within a try statement.Ryan Wilson2014-05-301-8/+8
| | | | | | | | | | | | Older versions of Python do not have ctypes as a default installed package. This patch puts the 'import ctypes' statement inside a try statement. This fixes a bug introduced by commit 8396f (timeval: Use monotonic time in OVS Python timeval library). Signed-off-by: Ryan Wilson <wryan@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* timeval: Use monotonic time in OVS Python timeval library.Ryan Wilson2014-05-301-1/+33
| | | | | | | | | | | | | | | | | | | | Python's time.time() function uses the system wall clock. However, if NTP resets the wall clock to be a time in the past, then this causes any applications that poll block based on time, such as ovs-xapi-sync, to poll block indefinitely since the time is unexpectedly negative. This patch fixes the issue by using time.monotonic() if Python's version >= 3.3. Otherwise, the timeval module calls out to the librt C shared library and uses the clock_gettime function with CLOCK_MONOTONIC. Note this is only enabled on Linux-based platforms. This has been tested on Ubuntu 12.04 and Redhat 6.4. Bug #1189434 Signed-off-by: Ryan Wilson <wryan@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* vlog: Use python 2.4 compatible functions.Gurucharan Shetty2014-05-051-2/+2
| | | | | | | Xenserver uses python 2.4. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Python Logging Formatting ImprovementsDave Tucker2014-04-281-12/+116
| | | | | | | | | | | | | | | | | | The Open vSwitch daemons written in C support user-configured logging patterns as described in ovs-appctl(8). This commit adds this capability to the daemons written in Python. - Add a '__log_patterns' attribute to the Vlog class - Populate this using the default patterns in ovs-appctl(8) - Add a '__start_time' attribute to the Vlog class to support '%r' - Update the '_log' method to build the log message according to the pattern - Add a 'set_pattern' method to allow the default patterns to be changed - Update 'set_levels_from_string' to support setting the pattern from a string Signed-off-by: Dave Tucker <dave@dtucker.co.uk> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Remove SPECS in favor of referring to RFC 7047.Ben Pfaff2014-04-041-2/+2
| | | | | | | Also, add some clarifications relative to RFC 7047 to ovsdb-server(1). Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* socket-util: Fix set_dscp for IPv6YAMAMOTO Takashi2014-02-261-1/+14
| | | | | | | | | | | | | | | | | | | Try IPPROTO_IPV6/IPV6_TCLASS socket option as well as IPPROTO_IP/IP_TOS so that this can work for IPv6 sockets. IPPROTO_IP/IP_TOS socket option is, as it's SOL indicates, for IPv4. What happens when it's used for IPv6 sockets? On Linux, it seems to be forwarded to IPv4 code and affects IPv4 part of the socket. (e.g. non-V6ONLY case) But it doesn't seem to be the intention of this function. On other platforms including NetBSD, it just fails with ENOPROTOOPT. Probably this function should take the address family but passing it around lib/*stream*.c would be a bigger change. Cc: Arun Sharma <arun.sharma@calsoftinc.com> Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Add IPv6 support for OpenFlow, OVSDB, NetFlow, and sFlow.Arun Sharma2014-02-061-9/+29
| | | | | | | | | | Does not add IPv6 support for in-band control. Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Nandan Nivgune <nandan.nivgune@calsoftinc.com> Signed-off-by: Abhijit Bhopatkar <abhijit.bhopatkar@calsoftinc.com> Signed-off-by: Arun Sharma <arun.sharma@calsoftinc.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* daemon: Cleanup some functions.Gurucharan Shetty2014-01-241-11/+0
| | | | | | | | Some functions are unused and some functions can be declared as static. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* jsonrpc: Only compose message to log if it's really going to be logged.Ben Pfaff2013-10-252-2/+26
| | | | | | | | | This suppresses a testsuite failure when the testsuite is run from a directory whose name contains a non-ASCII character. I'd rather fix the problem but webpages like the following make it sound difficult or impossible on Python 2.x: http://stackoverflow.com/a/11742928 Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: Add symlink based workaround for long pathnames.YAMAMOTO Takashi2013-10-171-1/+45
| | | | | | | | | The existing /proc workaround only works on Linux. Symlinks are more widely available. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Co-authored-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idl: Remove write-only member 'commit_seqno' from ovsdb_idl_txn.Ben Pfaff2013-10-081-1/+0
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* vlog: Fix formatting of milliseconds in Python log messages.Ben Pfaff2013-09-171-2/+2
| | | | | | | | | | | Commit 2b31d8e713de7 (vlog: Report timestamps in millisecond resolution in log messages.) introduced milliseconds to log messages by default, but the Python version did not ensure that milliseconds were always formatted with 3 digits, so 3.001 was formatted as "3.1" and 3.012 as "3.12", and so on. This commit fixes the problem. CC: Paul Ingram <paul@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* vlog: Report timestamps in millisecond resolution in log messages.Paul Ingram2013-09-131-1/+2
| | | | | | | To make debugging easier. Signed-off-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Paul Ingram <pingram@nicira.com>
* Fix misspellings in comments and docs.Andy Hill2013-06-042-2/+2
| | | | | | | | Flagged with: https://github.com/lyda/misspell-check Run with: git ls-files | misspellings -f - Signed-off-by: Andy Hill <hillad@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python: fix a typo error in python/ovs/socket_util.py.Alex Wang2013-04-181-2/+2
| | | | | | | | | | | | | The commit 89d7ffa9 (python: Workaround UNIX socket path length limits), fixes most failed tests. But it has a typo and the typo causes the failure of test <unixctl server errors - Python> when the path length is very long (e.g. more than 90 characters). This patch fixes the above issue. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/poller.py: workaround an eventlet bugYAMAMOTO Takashi2013-04-161-0/+13
| | | | | Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python.ovs.db.idl: Fix Row.delete() of a row already committed to the db.Ben Pfaff2013-04-081-1/+3
| | | | | | | | | | | Row.delete() handled the case of deleting a row that was added within the current transaction, but not yet committed, but it did not correctly handle the case of deleting a row that belonged to the database before the transaction started. This fixes the problem. Reported-by: Yeming Zhao <zhaoyeming@gmail.com> Tested-by: Yeming Zhao <zhaoyeming@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* vlog: extend syslog format to make OVS logs easier to filterRomain Lenglet2013-04-051-1/+1
| | | | | | | | Prepend "ovs|" to syslog logs to make them easier to filter out of all LOG_DAEMON logs. Signed-off-by: Romain Lenglet <rlenglet@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb-idlc: Make no-op writes to write-only columns cheaper.Ben Pfaff2013-03-051-1/+10
| | | | | | | | | For 1000 tunnels with CFM enabled, this reduces CPU use from about 36% to about 30%. Bug #15171. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* python: Do not include time stamp in syslog messages.Andy Zhou2013-02-281-2/+6
| | | | | | | | | | | | | | | vlog.py currently generates the same log messages, starts with the time stamp information, for console, syslog and file. All messages start with current time stamp information. Syslogd, by default, prepends time stamp with each message already. Thus the time stamp generated by vlog.py is redundant. This patch removes time stamp from the message before vlog.py sends it to syslogd. Signed-off-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* stream-unix: Use rundir as root for relative paths.Pavithra Ramesh2013-02-111-0/+4
| | | | | | | | | | | | | | Until now, "unix:" and "punix:" paths that are not absolute have been considered relative to the current working directory. It is more useful to consider them relative to the rundir, so this commit makes that change to the C and Python implementations of the stream code. This commit also relaxes the whitelist check in the bridge code so that any name that does not contain a "/" is considered OK. Signed-off-by: Pavithra Ramesh <paramesh@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/db/types: Fix English grammar for enums with one member.Ben Pfaff2013-02-041-1/+3
| | | | | | | | | | | | | Before this change, enums that have one member were formatted as, e.g.: "one of xyzzy, , or " This changes them to be formatted as: "must be xyzzy" which makes much more sense. (An enum with one member may make some sense if you are trying to leave the possibility for future expansion.) Signed-off-by: Ben Pfaff <blp@nicira.com>
* python: Workaround UNIX socket path length limitsJames Page2013-01-161-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | From aa28e8bfb646a54ba91e3545f3c0b9db39eddb7f Mon Sep 17 00:00:00 2001 From: James Page <james.page@ubuntu.com> Date: Wed, 16 Jan 2013 10:52:59 +0000 Subject: [PATCH] python: Workaround UNIX socket path length limits To: dev@openvswitch.org UNIX socket paths have a limit in terms of length. On Linux this is 103 characters. This is a problem in Debian/Ubuntu buildds which can generate quite long paths. This patch works around this issue by detecting when socket connection/binding fails due to this issue and accessing the socket path using a file descriptor path in /proc/self/fd. The workaround is limited to Linux. This is based on similar code in the C parts of OpenvSwitch. Signed-off-by: James Page <james.page@ubuntu.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* daemon: Start monitor process, not daemon process, in new session.Ben Pfaff2012-12-131-2/+3
| | | | | | | | | | | | | | | | | | | | | | To keep control+C and other signals in the initiating session from killing the monitor process, we need to put the monitor process into its own session. However, until this point, we've only done that for the daemon processes that the monitor started, which means that control+C would kill the monitor but not the daemons that it launched. I don't know of a benefit to putting the monitor and daemon processes in different sessions, as opposed to one new session for both of them, so this change does the latter. daemonize_post_detach() is called from one additional context where we'd want to be in a new session, the worker_start() function, but that function is documented as to be called after daemonize_start(), in which case we will (after this commit) already have called setsid(), so no additional change is required there. Bug #14280. Reported-by: Gordon Good <ggood@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/stream: Fix Stream.connect() retval for incomplete connection.Ben Pfaff2012-11-211-9/+11
| | | | | | | | | | If the loop condition in Stream.connect() was false, which is especially likely for TCP connections, then Stream.connect() would return None, which violates its documented behavior. This commit fixes the problem. Reported-by: Isaku Yamahata <yamahata@valinux.co.jp> Tested-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: Remove get_socket_error().Ben Pfaff2012-11-201-6/+0
| | | | | | | It has no remaining users. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* socket-util: Avoid using SO_ERROR.Ben Pfaff2012-11-201-2/+16
| | | | | | | | ESX doesn't implement it, and there's another approach that should work everywhere, so drop back to that. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* python/ovs/socket_util: Fix error path in set_nonblocking.Ben Pfaff2012-11-201-1/+1
| | | | | | | | 'e' is an exception, not a socket, so get_exception_errno() is the appropriate function to obtain an error code from it. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Kyle Mestery <kmestery@cisco.com>
* don't use select.POLL* constantsFUJITA Tomonori2012-11-193-19/+23
| | | | | | | | | | | Python doesn't have select.POLL* constants on some architectures (e.g. MacOSX). This code needs to define the constants for itself. It uses select.POLL* constants only internally (doesn't pass them outside). So there is no harm even if the definition would conflict with Python's those. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* stream.py: un-decorator Stream.register_methodIsaku Yamahata2012-10-171-7/+4
| | | | | | | | | c38f8724aeb994fd840fa4283a07e38c3c114d68 made stream.py not use class decorator. So Stream.register need not to be decorator any more. So simplify it. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* stream.py: Don't use class decorators.Reid Price2012-10-161-2/+2
| | | | | | | | | | | | | Commit 8cc820 (python/ovs/stream: teach stream.py tcp socket) made a change that used class decorators. Unfortunately, they were not introduced until Python 2.6. XenServer uses Python 2.4, so the change caused some Python-based daemons not to start. This commit uses an alternate syntax suggested by Reid Price. Bug #13580 Signed-off-by: Justin Pettit <jpettit@nicira.com> Signed-off-by: Reid Price <reid@nicira.com>
* python/ovs/socket_util: don't use Exception, but ValueErrorIsaku Yamahata2012-10-161-3/+3
| | | | | | | | | | 67656b9ff297f305b3bfcca2868e8e870e108283 used Exception, but it should be more specific error. Use ValueError instread of Exception. Suggested-by: Reid Price <reid@nicira.com> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/stream: teach stream.py tcp socketIsaku Yamahata2012-10-151-10/+56
| | | | | Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/socket_util: add tcp related helper functions which will be used ↵Isaku Yamahata2012-10-151-0/+42
| | | | | | | by tcp Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/db/idl: getattr(Row) raises TypeError, not AttributeError.Isaku Yamahata2012-09-271-0/+3
| | | | | | | | | | | | | | | | In some cases getattr(Row instance, attrname) doesn't raise AttributeError, but TypeError > File "python/ovs/db/idl.py", line 554, in __getattr__ > datum = self._data[column_name] > TypeError: 'NoneType' object has no attribute '__getitem__' So getattr(Row instance, attrname, default value) doesn't work. This occurs when row._changes doesn't include attrname and row._data is None. So teach Row.__getattr__ _data=None case. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* jsonrpc: Fix Python implementation of inactivity logic.Ben Pfaff2012-09-181-14/+14
| | | | | | | | | | | | | | When a JSON-RPC session receives bytes, or when it successfully sends queued bytes, then it should count that as activity. However, the code here was reversed, in that it used the wrong check in each place. That is, when it tried to receive data, it would check whether data had just been sent, and when it tried to send data, it would check whether data had just been received. Neither one makes sense and doesn't work. Bug #13214. Reported-by: Luca Giraudo <lgiraudo@nicira.com> CC: James Schmidt <jschmidt@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/db/idl.py: Transaction._substitute doesn't handle list/tupleIsaku Yamahata2012-09-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | Since Transaction._substitute doesn't substitute elements of list/tuple, setting list references results in transaction error. Teach it such case. Example: {"op": "update", "row":{"bridges":["set",[["uuid", "1f42bc19-307f-42e7-a9c0-c12178bd8b51"], ["uuid", "f97e0c76-7146-489d-9bed-29bc704f65fe"]]]}, "table": "Open_vSwitch", "where":[["_uuid", "==", ["uuid", "20c2a046-ae7e-4453-a576-11034db24985"]]]} In the above case, uuid in "row" aren't replaced by "named-uuid" because the function doesn't look into elements of lists. When list/tuple is found, look into elements recursively. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/db/idl: make SchemaHelper accept schema in json formIsaku Yamahata2012-09-121-7/+16
| | | | | | | | This is needed when using schema that was retrieved from ovsdb by get_schema method. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/db/idl: add counterpart of ovsdb_idl_add_table()Isaku Yamahata2012-09-121-0/+13
| | | | | | | | Add register_table method to SchemaHelper as Python counterpart of ovsdb_idl_add_table() in the C version of the IDL. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs: socket_util uses select.pollIsaku Yamahata2012-09-122-3/+4
| | | | | | | | | The changeset of ed815d9bd28422a490fe370d7804d24bcd676806 eliminated the use of select.poll for eventlet/gevent. It forgot to select.poll in socket_util. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* jsonrpc: Treat receiving part of a message as activity.Ben Pfaff2012-09-071-0/+14
| | | | | | | | | | | | | | | Until now, the jsonrpc code has only counted receiving a full JSON-RPC messages as activity. This could theoretically time out, then, while a very long message is in transit or if a slow link is involved. This commit changes this code to count receiving any part of a message as activity. This isn't a problem for OpenFlow connections because OpenFlow messages are at most 64 kB in size. This problem hasn't actually been observed in practice. Bug #12789. Signed-off-by: Ben Pfaff <blp@nicira.com>
* jsonrpc: Treat draining data from send queue as activity.Ben Pfaff2012-09-071-1/+11
| | | | | | | | | | | | | | | | | | | Until now, the jsonrpc module has used messages received from the remote peer as the sole means to determine that the JSON-RPC connection is up. This could in theory interact badly with a remote peer that stops reading and processing messages from the receive queue when there is a backlog in the send queue for a given connection (ovsdb-server is an example of a program that behaves this way). This commit fixes the problem by expanding the definition of "activity" to include successfully sending JSON-RPC data that was previously queued. The above change is exactly analogous to the similar change made to the rconn library in commit 133f2dc95454 (rconn: Treat draining a message from the send queue as activity.). Bug #12789. Signed-off-by: Ben Pfaff <blp@nicira.com>
* reconnect: Rename reconnect_received() to reconnect_activity().Ben Pfaff2012-09-072-15/+16
| | | | | | | | | | | | Receiving data is not the only reasonable way to verify that a connection is up. For example, on a TCP connection, receiving an acknowledgment that the remote side has accepted data that we sent is also a reasonable means. Therefore, this commit generalizes the naming. Also, similarly for the Python implementation: Reconnect.received() becomes Reconnect.activity(). Signed-off-by: Ben Pfaff <blp@nicira.com>
* python/ovs/poller: use select.select instead of select.poll.Isaku Yamahata2012-09-051-2/+61
| | | | | | | | | | | | eventlet/gevent doesn't work well with select.poll because select.poll blocks python interpreter as a whole instead of switching from the current thread which is about to block to other runnable thread. So ovsdb python binding can't be used with eventlet/gevent. Emulate select.poll with select.select because using python means that performance isn't so important. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Ben Pfaff <blp@nicira.com>
* dirs: dbdir default must be based on sysconfdir.Ben Pfaff2012-08-033-14/+52
| | | | | | | | | | | | | | | Some in-tree and out-of-tree code sets the OVS_SYSCONFDIR environment variable to control where /etc files go (mostly for test purposes). When the database directory (dbdir) was split off from the sysconfdir, the configure-time default continued to be based on the sysconfdir, but overriding the sysconfdir at runtime with OVS_SYSCONFDIR didn't have any effect on the dbdir, which caused a visible change in behavior for code that set the OVS_SYSCONFDIR environment variable. This commit reverts that change in behavior, by basing the dbdir on OVS_SYSCONFDIR if that environment variable is set (but the OVS_DBDIR environment variable is not). Signed-off-by: Ben Pfaff <blp@nicira.com>
* Fix a typo in commit f973f2af2.Mehak Mahajan2012-08-011-1/+1
| | | | Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
* Make the location of the database separately configurable.Ben Pfaff2012-08-012-0/+2
| | | | | | | | | The default is unchanged, /etc/openvswitch/conf.db. This makes it possible to transition each Open vSwitch packaging from /etc/openvswitch/conf.db to /var/lib/openvswitch/conf.db independently. Signed-off-by: Ben Pfaff <blp@nicira.com>