From: Cyril Roelandt Date: Thu, 23 Jul 2015 09:23:21 +0000 (+0000) Subject: Python3: pass bytes to binascii.crc32 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=99f9ec3e3812d39857f311894a516d0d43f166ec;p=openstack-build%2Fneutron-build.git Python3: pass bytes to binascii.crc32 In Python3, binascii.crc32 must be given bytes. This commit does not change the behaviour in Python 2. Change-Id: I91607ced4ab26d1d2e3eb31a3e4b2a4b2131b7bd Blueprint: neutron-python3 --- diff --git a/neutron/agent/l3/dvr_local_router.py b/neutron/agent/l3/dvr_local_router.py index 805b31ed7..e14fc2d17 100755 --- a/neutron/agent/l3/dvr_local_router.py +++ b/neutron/agent/l3/dvr_local_router.py @@ -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 fdc2dbe47..0462c0791 100644 --- 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 \