]> git.proxmox.com Git - mirror_ovs.git/commitdiff
python: Fix xmlrpclib imports.
authorRussell Bryant <russell@ovn.org>
Mon, 14 Dec 2015 19:03:14 +0000 (14:03 -0500)
committerRussell Bryant <russell@ovn.org>
Wed, 20 Jan 2016 21:43:15 +0000 (16:43 -0500)
Fix imports of xmlrpclib to be compatible with Python 3.  Python 2 had
xmlrpclib (client) and SimpleXMLRPCServer (server).  In Python 3, these
have been renamed to xmlrpc.client and xmlrpc.server.

The solution implemented here is to use the six library.  It may seem
excessive for this particular issue, but the six library provides
helpers for Python 2 and 3 compatibility for many different issues.
This is just the first of many uses of the six library.

Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
INSTALL.md
debian/control
m4/openvswitch.m4
python/ovstest/rpcserver.py
python/ovstest/util.py
rhel/openvswitch-fedora.spec.in
rhel/openvswitch.spec.in

index bf756f27ca31e3260d05bec5e0c7700a64b90e41..dc688adbc7c0d24e663a4da62c3151e09a12f8f6 100644 (file)
@@ -48,7 +48,7 @@ you will need the following software:
     privileges.  If libcap-ng is installed, then Open vSwitch will
     automatically build with support for it.
 
-  - Python 2.7.
+  - Python 2.7. You must also have the Python six library.
 
 On Linux, you may choose to compile the kernel module that comes with
 the Open vSwitch distribution or to use the kernel module built into
@@ -150,6 +150,8 @@ following software:
     from iproute2 (part of all major distributions and available at
     http://www.linux-foundation.org/en/Net:Iproute2).
 
+  - Python 2.7. You must also have the Python six library.
+
 On Linux you should ensure that /dev/urandom exists.  To support TAP
 devices, you must also ensure that /dev/net/tun exists.
 
index a71c8fb487b6b47357bd96d54acddaed5b99e9de..2918d061295d99d014a051c23ac3a4f386e7efd3 100644 (file)
@@ -16,7 +16,8 @@ Build-Depends: graphviz,
                python-all (>= 2.7),
                python-qt4,
                python-twisted-conch,
-               python-zopeinterface
+               python-zopeinterface,
+               python-six
 Standards-Version: 3.9.3
 Homepage: http://openvswitch.org/
 
@@ -57,8 +58,8 @@ Description: Open vSwitch datapath module source - DKMS version
 Package: openvswitch-common
 Architecture: linux-any
 Depends: openssl,
-         python,
-         python (>= 2.7) | python-argparse,
+         python (>= 2.7),
+         python-six,
          ${misc:Depends},
          ${shlibs:Depends}
 Suggests: ethtool
index 6d4e5da9c27ebc665af3296793f975c843685272..0149c30787ee25b07535570d108c77b02fd745aa 100644 (file)
@@ -341,6 +341,12 @@ else:
             fi
           done
         done
+        if test $ovs_cv_python != no; then
+          if test -x "$ovs_cv_python" && ! "$ovs_cv_python" -c 'import six' >/dev/null 2>&1; then
+            ovs_cv_python=no
+            AC_MSG_WARN([Missing Python six library.])
+          fi
+        fi
       fi])
    AC_SUBST([HAVE_PYTHON])
    AM_MISSING_PROG([PYTHON], [python])
index 80fc5dc7e3023dcb31c9384e1c318cffbd40bea8..7abf13cb81990f3db286550891b849098c706f55 100644 (file)
@@ -20,8 +20,8 @@ from __future__ import print_function
 
 import exceptions
 import sys
-import xmlrpclib
 
+import six.moves.xmlrpc_client
 from twisted.internet import reactor
 from twisted.internet.error import CannotListenError
 from twisted.web import xmlrpc
@@ -108,7 +108,8 @@ class TestArena(xmlrpc.XMLRPC):
         Returns the ovs-test server IP address that the other ovs-test server
         with the given ip will see.
         """
-        server1 = xmlrpclib.Server("http://%s:%u/" % (his_ip, his_port))
+        server1 = six.moves.xmlrpc_client.Server("http://%s:%u/" %
+                                                 (his_ip, his_port))
         return server1.get_my_address()
 
     def xmlrpc_create_udp_listener(self, port):
index 16c012e7a155882cab02b57c4d50ede79c951e0c..a52219540af2065fd97f5d1e442983b3a15092da 100644 (file)
@@ -25,7 +25,8 @@ import struct
 import signal
 import subprocess
 import re
-import xmlrpclib
+
+import six.moves.xmlrpc_client
 
 
 def str_ip(ip_address):
@@ -167,7 +168,8 @@ def get_interface_from_routing_decision(ip):
 
 
 def rpc_client(ip, port):
-    return xmlrpclib.Server("http://%s:%u/" % (ip, port), allow_none=True)
+    return six.moves.xmlrpc_client.Server("http://%s:%u/" % (ip, port),
+                                          allow_none=True)
 
 
 def sigint_intercept():
index 15f5c60829bab647042783c952db3ee529ffc81e..e655665539ed144a029d7c749386c9b7198d4ffd 100644 (file)
@@ -41,7 +41,7 @@ Source: http://openvswitch.org/releases/%{name}-%{version}.tar.gz
 
 BuildRequires: autoconf automake libtool
 BuildRequires: systemd-units openssl openssl-devel
-BuildRequires: python python-twisted-core python-zope-interface PyQt4
+BuildRequires: python python-twisted-core python-zope-interface PyQt4 python-six
 BuildRequires: desktop-file-utils
 BuildRequires: groff graphviz
 # make check dependencies
@@ -71,6 +71,7 @@ Summary: Open vSwitch python bindings
 License: ASL 2.0
 BuildArch: noarch
 Requires: python
+Requires: python-six
 
 %description -n python-openvswitch
 Python bindings for the Open vSwitch database
index fdb187936183bb5a07b16e83f88f55ef3600b628..a1f9b18786ce5d854aac55840edb012fb5f01ab2 100644 (file)
@@ -22,7 +22,7 @@ License: ASL 2.0
 Release: 1
 Source: openvswitch-%{version}.tar.gz
 Buildroot: /tmp/openvswitch-rpm
-Requires: logrotate, python >= 2.7
+Requires: logrotate, python >= 2.7, python-six
 BuildRequires: openssl-devel
 
 %bcond_without check