diff --git a/networking_arista/__init__.py b/networking_arista/__init__.py index 41807ab..ecc1a68 100644 --- a/networking_arista/__init__.py +++ b/networking_arista/__init__.py @@ -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') diff --git a/networking_arista/l3Plugin/arista_l3_driver.py b/networking_arista/l3Plugin/arista_l3_driver.py index b7d83d7..649be74 100644 --- a/networking_arista/l3Plugin/arista_l3_driver.py +++ b/networking_arista/l3Plugin/arista_l3_driver.py @@ -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: diff --git a/networking_arista/ml2/arista_ml2.py b/networking_arista/ml2/arista_ml2.py index ea5ef11..cdebf23 100644 --- a/networking_arista/ml2/arista_ml2.py +++ b/networking_arista/ml2/arista_ml2.py @@ -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' diff --git a/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py b/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py index 3551dee..4730ccd 100644 --- a/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py +++ b/networking_arista/tests/unit/ml2/test_arista_mechanism_driver.py @@ -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) diff --git a/networking_arista/tests/unit/ml2/test_arista_type_driver.py b/networking_arista/tests/unit/ml2/test_arista_type_driver.py index e36cc7f..fe273fa 100644 --- a/networking_arista/tests/unit/ml2/test_arista_type_driver.py +++ b/networking_arista/tests/unit/ml2/test_arista_type_driver.py @@ -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)) diff --git a/networking_arista/tests/unit/ml2/test_mechanism_arista.py b/networking_arista/tests/unit/ml2/test_mechanism_arista.py index 331c0bb..f669107 100644 --- a/networking_arista/tests/unit/ml2/test_mechanism_arista.py +++ b/networking_arista/tests/unit/ml2/test_mechanism_arista.py @@ -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 diff --git a/requirements.txt b/requirements.txt index 0f2d410..cc6b539 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index 9709b19..e4a5822 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,pep8 +envlist = py27,py35,pep8 minversion = 1.6 skipsdist = True