Enable Python3.5 support

Change-Id: I1696aaa9905d648c1985c8bd7219b91dbd880778
This commit is contained in:
Mark McClain 2017-03-06 14:19:52 -05:00
parent 60dd535045
commit 59a821fd54
8 changed files with 21 additions and 18 deletions

View File

@ -15,9 +15,13 @@
import gettext
import pbr.version
import six
__version__ = pbr.version.VersionInfo(
'networking_arista').version_string()
gettext.install('networking_arista', unicode=1)
if six.PY2:
gettext.install('networking_arista', unicode=1)
else:
gettext.install('networking_arista')

View File

@ -250,7 +250,9 @@ class AristaL3Driver(object):
if router:
router_name = self._arista_router_name(tenant_id, router['name'])
rdm = str(int(hashlib.sha256(router_name).hexdigest(), 16) % 65536)
hashed = hashlib.sha256(router_name.encode('utf-8'))
rdm = str(int(hashed.hexdigest(), 16) % 65536)
mlag_peer_failed = False
for s in self._servers:
try:

View File

@ -971,16 +971,16 @@ class AristaRPCWrapperJSON(AristaRPCWrapperBase):
# create instances first
if vmInst:
path = 'region/' + self.region + '/vm?tenantId=' + tenant_id
self._send_api_request(path, 'POST', vmInst.values())
self._send_api_request(path, 'POST', list(vmInst.values()))
if dhcpInst:
path = 'region/' + self.region + '/dhcp?tenantId=' + tenant_id
self._send_api_request(path, 'POST', dhcpInst.values())
self._send_api_request(path, 'POST', list(dhcpInst.values()))
if baremetalInst:
path = 'region/' + self.region + '/baremetal?tenantId=' + tenant_id
self._send_api_request(path, 'POST', baremetalInst.values())
self._send_api_request(path, 'POST', list(baremetalInst.values()))
if routerInst:
path = 'region/' + self.region + '/router?tenantId=' + tenant_id
self._send_api_request(path, 'POST', routerInst.values())
self._send_api_request(path, 'POST', list(routerInst.values()))
# now create ports for the instances
path = 'region/' + self.region + '/port'

View File

@ -14,7 +14,6 @@
# limitations under the License.
import functools
import itertools
import operator
import socket
@ -23,6 +22,7 @@ from mock import patch
from neutron_lib.api.definitions import portbindings
from neutron_lib import constants as n_const
from oslo_config import cfg
import six
import neutron.db.api as db
from neutron.plugins.ml2 import driver_api as api
@ -877,7 +877,7 @@ class PositiveRPCWrapperValidConfigTestCase(testlib_api.SqlTestCase):
calls = []
calls.extend(
mock.call(cmds=cmd, commands_to_log=log_cmd)
for cmd, log_cmd in itertools.izip(cmds, commands_to_log or cmds))
for cmd, log_cmd in six.moves.zip(cmds, commands_to_log or cmds))
mock_send_eapi_req.assert_has_calls(calls)
def test_no_exception_on_correct_configuration(self):
@ -2031,12 +2031,7 @@ class SyncServiceTest(testlib_api.SqlTestCase):
mock.call.get_region_updated_time()
]
self.assertTrue(self.rpc.mock_calls == expected_calls,
"Seen: %s\nExpected: %s" % (
self.rpc.mock_calls,
expected_calls,
)
)
self.rpc.assert_has_calls(expected_calls)
db_lib.forget_network_segment(tenant_1_id, tenant_1_net_1_id)
db_lib.forget_network_segment(tenant_2_id, tenant_2_net_1_id)

View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import itertools
import mock
from mock import patch
from oslo_config import cfg
@ -82,7 +84,7 @@ class VlanSyncServiceTest(testlib_api.SqlTestCase):
'allocatedVlans': '6-10,22,24,26,28,30'
}
assigned = range(1, 11) + range(21, 31)
assigned = list(itertools.chain(range(1, 11), range(21, 31)))
available = [1, 2, 3, 4, 5, 21, 23, 25, 27, 29]
allocated = list(set(assigned) - set(available))
@ -99,7 +101,7 @@ class VlanSyncServiceTest(testlib_api.SqlTestCase):
'allocatedVlans': '56-60,72,74,76,78,80'
}
assigned = range(51, 61) + range(71, 81)
assigned = list(itertools.chain(range(51, 61), range(71, 81)))
available = [51, 52, 53, 54, 55, 71, 73, 75, 77, 79]
allocated = list(set(assigned) - set(available))

View File

@ -596,7 +596,6 @@ class AristaDriverTestCase(testlib_api.SqlTestCase):
mechanism_arista.db_lib.assert_has_calls(expected_calls)
def test_update_port_precommit(self):
# Test the case where the port was not provisioned previsouly
# If port is not provisioned, we should bail out
mechanism_arista.db_lib.is_port_provisioned.return_value = False

View File

@ -6,3 +6,4 @@ Babel>=1.3
neutron-lib>=1.1.0 # Apache-2.0
oslo.log>=3.11.0 # Apache-2.0
pbr>=1.8
six>=1.9.0 # MIT

View File

@ -1,5 +1,5 @@
[tox]
envlist = py27,pep8
envlist = py27,py35,pep8
minversion = 1.6
skipsdist = True