summaryrefslogtreecommitdiff
path: root/python
Commit message (Collapse)AuthorAgeFilesLines
* python: Catch exception "SSL.SysCallError" for send by SSL.Guoshuai Li2017-01-141-1/+3
| | | | | | | | | | | | When OVSDB server is aborted, the SSL send function will throw SSL.SysCallError exception, which we need to catch and return it's -errno. While SSL.WantWriteError exception needs to return -EAGAIN based on its parent class, not EAGAIN Signed-off-by: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: Fix nroff indentation for <dl> after <hN>.Joe Stringer2017-01-061-3/+11
| | | | | | | | | | | | | | | When XML is used for writing manpages, in the case that there is a header tag followed by <dl>, the nroff python utility indents the <dl> tag (and children) an extra level which is unnecessary and makes the formatting inconsistent between manpages written directly in nroff vs manpages written in XML and converted to nroff. Fix the indentation by removing the extraneous .RS / .RE tags added to generated nroff in this case. This fixes the formatting of ovn/utilities/ovn-nbctl.8 man page. Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Add TCP/SSL probes for OVSDB python libGuoshuai Li2017-01-041-9/+26
| | | | | | | | | stream_or_pstream_needs_probes always return 0. This causes TCP/SSL connection not be probed, and no reconnect when the connection is aborted Signed-off-by: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Python tests: Daemon ported to WindowsAlin Balutoiu2017-01-033-37/+196
| | | | | | | | | | | | | | | | | | | | | | Instead of using os.fork (not supported on Windows), subprocess.Popen is used and os.pipe was replaced with Windows pipes. To be able to identify the child process, an extra parameter was added to daemon process '--pipe-handle'. This parameter contains the parent Windows pipe handle which is used by the child to notify the parent about the startup. The PID file is created directly on Windows, without using a temporary file because the symbolic link does not inherit the file lok set on the temporary file. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* Python tests: Ported UNIX sockets to WindowsAlin Balutoiu2017-01-035-39/+426
| | | | | | | | | | | | | | | | | | Unix sockets (AF_UNIX) are not supported on Windows. The replacement of Unix sockets on Windows is implemented using named pipes, we are trying to mimic the behaviour of unix sockets. Instead of using Unix sockets to communicate between components Named Pipes are used. This makes the python sockets compatible with the Named Pipe used in Windows applications. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* Python tests: Add winutils.py moduleAlin Balutoiu2017-01-032-1/+228
| | | | | | | | | | | | This patch adds a new python module which contains helper functions. These will be neccessary for the Windows implementation. They cover the following aspects: sockets and namedpipes. Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* ovsdb-idl: Change interface to conditional monitoring.Ben Pfaff2016-12-191-16/+15
| | | | | | | | | | | | | | | | | | | | | | | | Most users of OVSDB react to whatever is currently in their view of the database, as opposed to keeping track of changes and reacting to those changes individually. The interface to conditional monitoring was different, in that it expected the client to say what to add or remove from monitoring instead of what to monitor. This seemed reasonable at the time, but in practice it turns out that the usual approach actually works better, because the condition is generally a function of the data visible in the database. This commit changes the approach. This commit also changes the meaning of an empty condition for a table. Previously, an empty condition meant to replicate every row. Now, an empty condition means to replicate no rows. This is more convenient for code that gradually constructs conditions, because it does not need special cases for replicating nothing. This commit also changes the internal implementation of conditions from linked lists to arrays. I just couldn't see an advantage to using linked lists. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Liran Schour <lirans@il.ibm.com>
* python: Update comment to mention SSL support.Guoshuai Li2016-12-121-2/+2
| | | | | Signed-off-by: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: Reconnect SSL connections when ovsdb-server restarts.Guoshuai Li2016-12-121-0/+6
| | | | | | | | | | | | | | | | The do_handshake() function throws the exception OpenSSL.SSL.SysCallError when the peer's SSL connection is closed, And the recv() function also throws the exception OpenSSL.SSL.SysCallError when the peer's SSL connection is abnormally closed, This commit catches the exception and return error's errno. Similarly, the recv() function also throws the exception OpenSSL.SSL.ZeroReturnError when the peer's SSL connection is closed. This exception refers to TCP connection normal closed, return (0, "") Signed-off-by: Guoshuai Li <ligs@dtdream.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Numan Siddique <nusiddiq@redhat.com>
* python: Add double newline after fuction or class (E305).Daniele Di Proietto2016-12-024-0/+7
| | | | | | | | pycodestyle >= 2.1.0 reports E305 otherwise, and the flake8-check step fails. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idlc: Eliminate <prefix>_init() function from generated code.Ben Pfaff2016-10-193-71/+82
| | | | | Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
* Python-IDL: getattr after mutate fixAmitabha Biswas2016-10-141-14/+24
| | | | | | | | | | | This commit returns the updated column value when getattr is done after a mutate operation is performed (but before the commit). Signed-off-by: Amitabha Biswas <azbiswas@gmail.com> Reported-by: Richard Theis <rtheis@us.ibm.com> Reported-at: http://openvswitch.org/pipermail/dev/2016-September/080120.html Fixes: a59912a0ee8e ("python: Add support for partial map and set updates") Signed-off-by: Russell Bryant <russell@ovn.org>
* python: Add SSL support to the python ovs client libraryNuman Siddique2016-10-052-3/+96
| | | | | | | | | SSL support is added to the ovs/stream.py. pyOpenSSL library is used to support SSL. If this library is not present, then the SSL stream is not registered with the Stream class. Signed-off-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idlc: Make set and map update operations take const arguments.Ben Pfaff2016-08-311-1/+13
| | | | | | | | | | In a call like "ovsrec_bridge_update_ports_delvalue(bridge, port)", there's no reason for the port argument to be nonconst, because the call doesn't do anything to the port at all--it only searches the list of ports in the bridge for that particular port and, if it finds it, removes it. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* ovsdb: Fix mutation of newly inserted rows from Python IDL.Amitabha Biswas2016-08-301-1/+7
| | | | | | | | | | | | | | | This patch fixes the scenario, where the mutate operation on a row is sent in the same transaction as row insert operation. It was obvserved that this mutate operation was not getting committed to the OVSDB. To get around the above problem the "where" condition in an mutate operation is modified to use the named-uuid to identify a row created in the current transaction. Signed-off-by: Amitabha Biswas <abiswas@us.ibm.com> Suggested-by: Richard Theis <rtheis@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: Fix reference to table's row on condition_add|remove_clauseLiran Schour2016-08-261-3/+10
| | | | | | | | Use struct uuid * on [add|remove]_clause on columns which are references to tables. That prevents use-after-free errors. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb-idl: Fix bugs in Python IDL partial set and map.Amitabha Biswas2016-08-151-61/+57
| | | | | | | | | | | | | | | | | | This patch fixes a couple of bugs in commit a59912a0 (python: add support for partial map and partial set updates) and reverses a simplication added in commit 884d9bad (Simplify partial map Py3 IDL test) to make the Python3 test cases passes. The following changes have been made: 1. Allow multiple map updates on the same column in a transaction. 2. Partial map Py3 IDL test can now support multiple elements. 3. SetAttr overrides pre-existing insert and remove updates. 4. addvalue/delvalue contains unique elements Signed-off-by: Amitabha Biswas <abiswas@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: Add support for partial map and partial set updatesRyan Moats2016-08-141-11/+185
| | | | | | | | | | | | | | Allow the python IDL to use mutate operations more freely by mimicing the partial map and partial set operations now available in the C IDL. Unit tests for both of these types of operations are included. They are not carbon copies of the C tests, because testing idempotency is a bit difficult for the current python IDL test harness. Signed-off-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python tests: Fixed abs_file_name function for WindowsPaul Boca2016-08-031-2/+4
| | | | | | | | On windows a path containint ':' is considered an absolute path. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* python tests: Fixed OSError not iterable on WindowsPaul Boca2016-08-031-0/+6
| | | | | | | | | On Windows if this exception is triggered then it will raise an exception while in the exception handler. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* python tests: Added fcntl module for WindowsPaul Boca2016-08-032-0/+43
| | | | | | | | | | This is needed for lockf function used to lock the PID file on Windows. ioctl and fcntl functions are not implemented at this time because they are not used by any script. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* python tests: Fixed ctl file name for WindowsPaul Boca2016-08-032-4/+15
| | | | | | | | On Windows the CTL filename doesn't contain the pid of the process. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* python tests: Register signal handlers only on supported types on WindowsPaul Boca2016-08-031-2/+6
| | | | | | | | SIGHUP and SIGALRM are not available on Windows. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* python tests: Implemented signal.alarm for WindowsPaul Boca2016-08-031-0/+23
| | | | | | | | | | signal.alarm is not available in Windows and would trigger an exception when called. Implemented this to mentain compatibility between Windows and Linux for python tests. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Gurucharan Shetty <guru@ovn.org>
* python: Send old values of the updated cols in notify for update2Numan Siddique2016-07-271-6/+13
| | | | | | | | | | | | | When python IDL calls the "notify" function after processing the "update2" message from ovsdb-server, it is suppose to send the old values of the updated columns as the last parameter. But the recent commit "897c8064" sends the updated values. This breaks the behaviour. This patch fixes this issue. It also updates the description of the 'updates' param of the notify function to make it more clear. Fixes: 897c8064 ("python: move Python idl to work with monitor_cond") Signed-off-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: Serial JSON via Python's json lib.Terry Wilson2016-07-261-96/+10
| | | | | | | | | | | | There is no particularly good reason to use our own Python JSON serialization implementation when serialization can be done faster with Python's built-in JSON library. A few tests were changed due to Python's default JSON library returning slightly more precise floating point numbers. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: add set type for ovs.idl.data.Datum.from_pythonZong Kai LI2016-07-251-1/+1
| | | | | | | | | | | | | ovs.db.idl.Datum.from_python fails to handle set type value, while set type is also a common iterable sequence, just like list and tuple. No reason IDL caller must to turn set type parameters to list or tuple type. Otherwise, they will fail to insert data, but get no exception. Reported-at: https://bugs.launchpad.net/networking-ovn/+bug/1605573 Signed-off-by: Zong Kai LI <zealokii@gmail.com> Acked-by: Richard Theis <rtheis@us.ibm.com> Tested-by: Richard Theis <rtheis@us.ibm.com> Signed-off-by: Russell Bryant <russell@ovn.org>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+1
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* lib: add monitor_cond_change API to C IDL libLiran Schour2016-07-181-6/+24
| | | | | | | | | | Add to IDL API that allows the user to add and remove clauses on a table's condition iteratively. IDL maintain tables condition and send monitor_cond_change to the server upon condition change. Add tests for conditional monitoring to IDL. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: move Python idl to work with monitor_condLiran Schour2016-07-182-20/+168
| | | | | | | | Python idl works now with "monitor_cond" method. Add test for backward compatibility with old "monitor" method. Signed-off-by: Liran Schour <lirans@il.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* vlog.py: Remove redundant setLevel() if "/dev/log" doesn't exist.Daniele Di Proietto2016-07-061-3/+2
| | | | | | | Also update a comment. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Gurucharan Shetty <guru@ovn.org>
* vlog test: Disable default syslog loggerPaul Boca2016-07-061-0/+1
| | | | | | | | | Disable the syslog logger in case on Windows, '/dev/log' doesn't exist. Seems like on Python34 a default handler is added to the logger and it prints even if no handler is set by us. Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com> Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
* Add optional C extension wrapper for Python JSON parsingTerry Wilson2016-06-084-2/+331
| | | | | | | | | | | | | | | | | | | | The pure Python in-tree JSON parser is *much* slower than the in-tree C JSON parser. A local test parsing a 100Mb JSON file showed the Python version taking 270 seconds. With the C wrapper, it took under 4 seconds. The C extension will be used automatically if it can be built. If the extension fails to build, a warning is displayed and the build is restarted without the extension. The Serializer class is replaced with Python's built-in JSON library since the ability to process chunked data is not needed in that case. The extension should work with both Python 2.7 and Python 3.3+. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Ensure significand remains an integer in Python3 json parserTerry Wilson2016-06-081-1/+1
| | | | | | | | | | | | | | | | The / operation in Python 2 is "floor division" for int/long types while in Python 3 is "true division". This means that the significand can become a float with the existing code in Python 3. This, in turn, can result in a parse of something like [1.10e1] returning 11 in Python 2 and 11.0 in Python 3. Switching to the // operator resolves this difference. The JSON tests do not catch this difference because the built-in serializer prints floats with the %.15g format which will convert floats with no fractional part to an integer representation. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: Add TCP passive-mode to IDL.Ofer Ben-Yacov2016-05-202-11/+24
| | | | | | | | | Requested-by: "D M, Vikas" <vikas.d-m@hpe.com> Requested-by: "Kamat, Maruti Haridas" <maruti.kamat@hpe.com> Requested-by: "Sukhdev Kapur" <sukhdev@arista.com> Requested-by: "Migliaccio, Armando" <armando.migliaccio@hpe.com> Signed-off-by: "Ofer Ben-Yacov" <ofer.benyacov@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* python: Update Python version checks.Russell Bryant2016-04-152-9/+3
| | | | | | | | | | | | Instead of checking the raw version, use the six.PY2 and six.PY3 helpers to determine if Python 2 or Python 3 are in use. In one case, the check was to determine if the Python version was >= 2.6. We now only support >= 2.7, so this check would always be true. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org> Acked-by: Miguel Angel Ajo <majopela@redhat.com>
* ovsdb: Force columns that contain weak references to be immutable.Ben Pfaff2016-04-111-1/+7
| | | | | | | | | | An immutable weak reference is a hole in the constraint system: if referenced rows are deleted, then the weak reference needs to change. Therefore, force columsn that contain weak references to be mutable. Reported-by: "Elluru, Krishna Mohan" <elluru.kri.mohan@hpe.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Ryan Moats <rmoats@us.ibm.com>
* NEWS: Claim support for Python 3.Russell Bryant2016-02-221-1/+5
| | | | | | | | Also update the Python ovs package info to note that both Python 2 and 3 are supported. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* vlog: Add vlog/close command.Ben Pfaff2016-02-101-1/+10
| | | | | | | Requested-by: P R Dinesh Requested-at: https://github.com/openvswitch/ovs/pull/94 Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
* python: Deal with str and byte differences.Russell Bryant2016-02-023-0/+18
| | | | | | | | | | Python 3 has separate types for strings and bytes. Python 2 used the same type for both. We need to convert strings to bytes before writing them out to a socket. We also need to convert data read from the socket to a string. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Fix object comparisons in Python 3.Russell Bryant2016-02-022-0/+38
| | | | | | | | | | | | | Python 3 no longer supports __cmp__. Instead, we have to implement the "rich comparison" operators. We implement __eq__ and __lt__ and use functools.total_ordering to implement the rest. In one case, no __cmp__ method was provided and instead relied on the default behavior provided in Python 2. We have to implement the comparisons explicitly for Python 3. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Don't compare None and int.Russell Bryant2016-02-021-1/+1
| | | | | | | Comparing None to an integer worked in Python 2, but fails in Python 3. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Remove reamining direct type comparisons.Russell Bryant2016-02-027-26/+26
| | | | | | | | | | | I've hit several bugs in this Python 3 work where the fix was some code needed to be converted to use isinstance(). This has been primarily around deadling with the changes to unicode handling. Go ahead and convert the rest of the direct type comparisons to use isinstance(), as it could avoid a bug I haven't hit yet and it's more Pythonic, anyway. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Use six.unichr().Russell Bryant2016-02-021-1/+1
| | | | | | | | six.unichr() is equivalent to unichr() in Python 2 and chr() in Python 3. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Drop use of sys.maxint.Russell Bryant2016-02-024-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | sys.maxint does not exist in Python 3, as an int does not have a max value anymore (except as limited by implementation details and system resources). sys.maxsize works as a reasonable substitute as it's the same as sys.maxint. The Python 3.0 release notes have this to say: The sys.maxint constant was removed, since there is no longer a limit to the value of integers. However, sys.maxsize can be used as an integer larger than any practical list or string index. It conforms to the implementation’s “natural” integer size and is typically the same as sys.maxint in previous releases on the same platform (assuming the same build options). sys.maxsize is documented as: An integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Don't use StringIO directly.Russell Bryant2016-02-021-2/+1
| | | | | | | | StringIO.StringIO in Python 2 became io.StringIO in Python 3. Use six.StringIO which is an alias for the two cases. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Drop use of types.FunctionType.Russell Bryant2016-02-021-3/+1
| | | | | | | | | | This code asserted that the callback argument was of type types.FunctionType. It's more pythonic to just check that the argument is callable, and not specifically that it's a function. There are other ways to implement a callback than types.FunctionType. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Drop use of types.StringTypes.Russell Bryant2016-02-023-5/+7
| | | | | | | | types.StringTypes does not exist in Python 3. We can use six.string_types, instead. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Drop unicode type.Russell Bryant2016-02-028-38/+60
| | | | | | | | | | Python 2 had str and unicode. Python 3 only has str, which is always a unicode string. Drop use of unicode with the help of six.text_type (unicode in py2 and str in py3) and six.string_types ([str, unicode] in py2 and [str] in py3). Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* python: Drop usage of long type.Russell Bryant2016-02-027-34/+52
| | | | | | | | | | | | | | | | | | | | | Python 2 has both long and int types. Python 3 only has int, which behaves like long. In the case of needing a set of integer types, we can use six.integer_types which includes int and long for Python 2 and just int for Python 3. We can convert all cases of long(value) to int(value), because as of Python 2.4, when the result of an operation would be too big for an int, the type is automatically converted to a long. There were several places in this patch doing type comparisons. The preferred way to do this is using the isinstance() or issubclass() built-in functions, so I converted the similar checks nearby while I was at it. Signed-off-by: Russell Bryant <russell@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>