summaryrefslogtreecommitdiff
path: root/python
Commit message (Collapse)AuthorAgeFilesLines
...
* python: Inherit from object.Russell Bryant2016-01-051-1/+1
| | | | | | | | | class Vlog now inherits from "object". This is a "new style" Python class, which isn't new at all at this point. This was introduced back in Python 2.2, and some Python 2 code won't work as expected without it. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Fix several pep8 whitespace errors.Russell Bryant2016-01-0510-21/+27
| | | | | | | | | | | | | | | | | | | | Fix the following pep8 errors: E201 whitespace after '(' E203 whitespace before ',' E222 multiple spaces after operator E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E231 missing whitespace after ':' E241 multiple spaces after ':' E251 unexpected spaces around keyword / parameter equals E261 at least two spaces before inline comment E262 inline comment should start with '# ' E265 block comment should start with '# ' E271 multiple spaces after keyword Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Resolve pep8 comparison errors.Russell Bryant2016-01-055-8/+10
| | | | | | | | | | | | | | | | | | | | | Resolve pep8 errors: E711 comparison to None should be 'if cond is None:' The reason comparing against None with "is None" is preferred over "== None" is because a class can define its own equality operator and produce bizarre unexpected behavior. Using "is None" has a very explicit meaning that can not be overridden. E721 do not compare types, use 'isinstance()' This one is actually a mistake by the tool in most cases. 'from ovs.db import types' looks just like types from the Python stdlib. In those cases, use the full ovs.db.types name. Fix one case where it actually was types from the stdlib. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Resolve pep8 blank line errors.Russell Bryant2016-01-058-1/+15
| | | | | | | | | | Resolve pep8 errors E302 and E303: E302 expected 2 blank lines, found 1 E303 too many blank lines (3) Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Fix invalid varable/function references.Russell Bryant2016-01-052-1/+8
| | | | | | | | | | | | | This code referred to "rows" where it meant to refer to "fetched_rows". The patch resolves flake8 error: F821 undefined name 'rows' python/build/nroff.py used a function fatal() that was not defined, which raised the same type of error. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Remove unused imports and variables.Russell Bryant2016-01-053-15/+3
| | | | | | | | | | This resolves the following flake8 error types: F841 local variable 'e' is assigned to but never used F401 'exceptions' imported but unused Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Run flake8 at build time.Russell Bryant2016-01-051-0/+7
| | | | | | | | | | | | If flake8 is installed, run it at build time. Similar to most Makefile targets, run it once and then only run again if the files change. flake8 is set to ignore all error and warning types that currently occur. Future patches will remove items from the ignore list as they are resolved. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Support for readonly columns that are fetched on-demandShad Ansari2015-11-231-4/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is currently no mechanism in IDL to fetch specific column values on-demand without having to register them for monitoring. In the case where the column represent a frequently changing entity (e.g. counter), and the reads are relatively infrequent (e.g. CLI client), there is a significant overhead in replication. This patch adds support in the Python IDL to register a subset of the columns of a table as "readonly". Readonly columns are not replicated. Users may "fetch" the readonly columns of a row on-demand. Once fetched, the columns are not updated until the next fetch by the user. Writes by the user to readonly columns does not change the value (both locally or on the server). The two main user visible changes in this patch are: - The SchemaHelper.register_columns() method now takes an optionaly argument to specify the subset of readonly column(s) - A new Row.fetch(columns) method to fetch values of readonly columns(s) Usage: ------ # Schema file includes all columns, including readonly schema_helper = ovs.db.idl.SchemaHelper(schema_file) # Register interest in columns with 'r' and 's' as readonly schema_helper.register_columns("simple", [i, r, s], [r, s]) # Create Idl and jsonrpc, and wait for update, as usual ... # Fetch value of column 'r' for a specific row row.fetch('r') txn.commit_block() print row.r print getattr(row, 'r') # Writing to readonly column has no effect (locally or on server) row.r = 3 print row.r # prints fetched value not 3 Signed-off-by: Shad Ansari <shad.ansari@hp.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* nroff: Add support for <b>...</b> and <i>...</i> inline markup.Ben Pfaff2015-09-291-2/+2
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* nroff: Support inline XML inside <pre> blocks.Ben Pfaff2015-09-291-12/+14
| | | | | | | | | | | | This is useful so that one can write, e.g. <p>The following shows how to add 1 to variable <var>x</var>:</p> <pre> <var>x</var> = <var>x</var> + 1; </pre> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* nroff: Allow comments in more contexts.Ben Pfaff2015-08-261-3/+8
| | | | | | Reported-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Russell Bryant <rbryant@redhat.com>
* nroff: Add support for 'diagram' XML element for protocol headers.Ben Pfaff2015-08-031-0/+97
| | | | | | | | | | This will be used in documentation for an upcoming change, to document how Geneve OVN options are encoded. The code in this change is from a series (not yet submitted) that makes much more extensive use of it for documenting protocol headers. Signed-off-by: Ben Pfaff <blp@nicira.com>
* xml2nroff: Allow comments in block XML.Ben Pfaff2015-07-121-0/+2
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* nroff: Fix style of names.Ben Pfaff2015-07-061-28/+28
| | | | | | | | | | | | | The recommended Google Python style is multi_word_names, not multiWordNames. There are lots of other places where the style could be improved. I started here because I was working in this code anyway and because this code is only used at build time and not installed, so that it can't break any third-party code. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Justin Pettit <jpettit@nicira.com>
* python: Fix issue with probes for JSONRPC connectionsSumit Garg2015-06-251-1/+1
| | | | | | | | | | | | | | | | | | | When opening a JSONRPC connection, the health probes are incorrectly getting turned off for connections that need probes. In other words, when stream_or_pstream_needs_probes() return non-zero, the probes are gettting disabled as the probe interval is getting set to zero. This leads to incorrect behavior such that probes are: - not getting turned off for unix: connections - getting turned off for tcp:/ssl: connections The changes in this commit fix this issue. Signed-off-by: Sumit Garg <sumit@extremenetworks.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python: Fix writing to non-"alert" column for newly inserted row.Sumit Garg2015-06-251-1/+1
| | | | | | | | | | | | | | | | | When 'alert' was turned off on a column, the code was erroring out when value for that column was being set in a newly inserted row. This is because the row._data was None at this time. It seems that new rows are not initialized to defaults and that's why the NULL error happens. IMO a newly inserted row should automatically get intialized to default values. This new behavior can be implemented as a separate improvement sometime in the future. For now, I don't see an issue with adding the additional check. This new check can continue as-is even after the new behavior is implemented. Signed-off-by: Sumit Garg <sumit@extremenetworks.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python: Fix attempt to use a bool as a function.Sumit Garg2015-06-251-1/+1
| | | | | | | | A bool (has_lock) was being accessed as a function call leading to a runtime exception. Signed-off-by: Sumit Garg <sumit@extremenetworks.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Makefiles: Stop distributing files because building them requires Python.Ben Pfaff2015-06-231-1/+1
| | | | | | | | | | | | A long time ago, the Open vSwitch build did not depend on Python (whereas the runtime did), so the "make dist" based distribution included the results of Python build tools. Later, the build began using Python, but the distribution still included some of those results, because no one had gone to the trouble of changing them. This commit changes the Makefiles not to distribute Python-generated files but instead to just generate them at build time. Signed-off-by: Ben Pfaff <blp@nicira.com>
* Increase prerequisite from Python 2.4 to Python 2.7.Ben Pfaff2015-06-234-2952/+1
| | | | | | | This means that users of XenServer 6.5 and earlier will need to install Python 2.7. Signed-off-by: Ben Pfaff <blp@nicira.com>
* nroff: Fix the escape of '.'.Ben Pfaff2015-06-231-1/+1
| | | | | Signed-off-by: Alex Wang <alexw@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* ovn-nbctl: Take default database target from OVN_NB_DB in environment.Ben Pfaff2015-06-161-1/+1
| | | | | | | | | | This makes life easier for testing at the point you start to separate your environment into multiple machines. Also work on the manpage a little. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* Allow subclasses of Idl to define a notification hookTerry Wilson2015-04-271-1/+41
| | | | | | | | | | | | | | | It is useful to make the notification events that Idl processes accessible to users of the library. This will make it possible to keep external systems in sync, but does not impose any particular notification pattern. The Row.from_json() call is added to be able to convert the 'old' JSON response on an update to a Row object to make it easy for users of notify() to see what changed, though this usage of Row is quite different than Idl's typical use. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* python: Add setuptools for Python lib for PyPI.Terry Wilson2015-04-144-0/+60
| | | | | | | | | | | | | | | This adds very basic support for setuptools so that the OVS Python lib can be added to PyPI. This currently uses the Open vSwitch version number and the generated dirs.py, though there is no real reason to tie the Python libraries releases or version numbers to the main project's. Signed-off-by: Terry Wilson <twilson@redhat.com> Acked-by: Russell Bryant <rbryant@redhat.com> Acked-by: Kyle Mestery <mestery@mestery.com> [blp@nicira.com adjusted automake.mk] Signed-off-by: Ben Pfaff <blp@nicira.com>
* socket-util: Use correct address family in set_dscp(), instead of guessing.Ben Pfaff2015-02-201-14/+15
| | | | | | | | | | | | | | | | | The set_dscp() function, until now, tried to set the DSCP as IPv4 and as IPv6. This worked OK on Linux, where an ENOPROTOOPT error made it really clear which one was wrong, but FreeBSD uses EINVAL instead, which has multiple meanings and which it therefore seems somewhat risky to ignore. Instead, this commit just tries to set the correct address family's DSCP option. Tested by Alex Wang on FreeBSD 9.3. Reported-by: Atanu Ghosh <atanu@acm.org> Signed-off-by: Ben Pfaff <blp@nicira.com> Co-authored-by: Alex Wang <alexw@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Tested-by: Alex Wang <alexw@nicira.com>
* ovsdb-doc: Factor out nroff formatting into a separate Python module.Ben Pfaff2015-02-193-0/+191
| | | | | | | This will make it cleaner to add another build-time program that generates nroff from XML. Signed-off-by: Ben Pfaff <blp@nicira.com>
* vlog: Fix "/dev/log" testYAMAMOTO Takashi2015-02-031-1/+1
| | | | | | | | | | | | | | | | | commit 7905aae3fc1633c2c44c8fdb9e9d3a3d6e63439b ("vlog: Don't fail syslog initialization in chroot.") uses os.path.isfile("/dev/log"), which tests if the given path is a regular file, to see if syslog can be usable. However, /dev/log is not a regular file for platforms I looked at. * On Ubuntu 14.04 and CentOS 6.5, /dev/log is a socket * On NetBSD-6, /dev/log is a symlink to a socket Replace the test with os.path.exists() so that it can work as intended for these platforms. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Acked-by: Gurucharan Shetty <gshetty@nicira.com>
* vlog: Don't fail syslog initialization in chroot.Gurucharan Shetty2015-01-291-3/+10
| | | | | | | | | | | When OVS unit tests are run inside chroot environment, there is no syslog infrastructure available. In a situation like that, don't fail or log additional messages to syslog by increasing the severity level of syslog very high (log messages would continue to be logged to console and file). Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Thomas Graf <tgraf@noironetworks.com>
* vlog: Ability to override the default log facility.Gurucharan Shetty2015-01-281-3/+32
| | | | | | | | | | | | | | | When Open vSwitch is run in hundreds of hypervisors, it is useful to collect log messages through log collectors. To collect log messages like this, it is useful to log them in a particular RFC5424 facility in the local system. The log collectors can then be used to collect logs anytime desired. This commit provides a sysadmin the ability to specify the facility through which the log messages are logged. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* vlog: Rename the currently used term 'facility' as 'destination'.Gurucharan Shetty2015-01-081-28/+28
| | | | | | | | | | | | In OVS, we currently use the term 'facility' to mean the place where we log (syslog, console or file). In Linux's syslog() and rfc5424, the term 'facility' is used to specify what type of program is logging the message (e.g: LOG_DAEMON). This causes confusion while reading vlog's code. This commit changes the term 'facility' to 'destination'. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* 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>