]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Python3: pass bytes to binascii.crc32
authorCyril Roelandt <cyril@redhat.com>
Thu, 23 Jul 2015 09:23:21 +0000 (09:23 +0000)
committerCyril Roelandt <cyril@redhat.com>
Fri, 31 Jul 2015 15:41:53 +0000 (17:41 +0200)
In Python3, binascii.crc32 must be given bytes. This commit does not change the
behaviour in Python 2.

Change-Id: I91607ced4ab26d1d2e3eb31a3e4b2a4b2131b7bd
Blueprint: neutron-python3

neutron/agent/l3/dvr_local_router.py
tox.ini

index 805b31ed7f79c60c82fa36b01cd1a872c0d7547b..e14fc2d172a8db9ae5c9750a83ca967b03bba883 100755 (executable)
@@ -17,6 +17,7 @@ import netaddr
 
 from oslo_log import log as logging
 from oslo_utils import excutils
+import six
 
 from neutron.agent.l3 import dvr_fip_ns
 from neutron.agent.l3 import dvr_router_base
@@ -206,6 +207,8 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
         """
         net = netaddr.IPNetwork(ip_cidr)
         if net.version == 6:
+            if isinstance(ip_cidr, six.text_type):
+                ip_cidr = ip_cidr.encode()  # Needed for Python 3.x
             # the crc32 & 0xffffffff is for Python 2.6 and 3.0 compatibility
             snat_idx = binascii.crc32(ip_cidr) & 0xffffffff
             # xor-fold the hash to reserve upper range to extend smaller values
diff --git a/tox.ini b/tox.ini
index fdc2dbe47ada77bae15633926bed5fd6cb8a4133..0462c0791a86a8a8d264d3931137786bfcb8ca68 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -179,6 +179,7 @@ commands = python -m testtools.run \
     neutron.tests.unit.agent.test_rpc \
     neutron.tests.unit.agent.test_securitygroups_rpc \
     neutron.tests.unit.agent.l3.test_link_local_allocator \
+    neutron.tests.unit.agent.l3.test_dvr_local_router \
     neutron.tests.unit.agent.l3.test_ha_router \
     neutron.tests.unit.agent.l3.test_legacy_router \
     neutron.tests.unit.agent.l3.test_router_info \