diff --git a/kuryr/lib/config.py b/kuryr/lib/config.py index 10eba751..413eb29a 100644 --- a/kuryr/lib/config.py +++ b/kuryr/lib/config.py @@ -67,7 +67,7 @@ binding_opts = [ cfg.StrOpt('veth_dst_prefix', default='eth', help=_('The name prefix of the veth endpoint put inside the ' - 'container.')), + 'container.')), cfg.StrOpt('driver', default='kuryr.lib.binding.drivers.veth', help=_('Driver to use for binding and unbinding ports.')), diff --git a/kuryr/lib/segmentation_type_drivers/vlan.py b/kuryr/lib/segmentation_type_drivers/vlan.py index 6bfd8a92..516699a0 100644 --- a/kuryr/lib/segmentation_type_drivers/vlan.py +++ b/kuryr/lib/segmentation_type_drivers/vlan.py @@ -22,7 +22,7 @@ DEFAULT_MAX_RETRY_COUNT = 3 class SegmentationDriver(object): def __init__(self): self.available_local_vlans = set(moves.range(const.MIN_VLAN_TAG, - const.MAX_VLAN_TAG + 1)) + const.MAX_VLAN_TAG + 1)) def allocate_segmentation_id(self, allocated_ids=set()): self.available_local_vlans.difference_update(allocated_ids) @@ -32,14 +32,15 @@ class SegmentationDriver(object): self.available_local_vlans.remove(allocated) return allocated except IndexError: - raise exceptions.SegmentationIdAllocationFailure('There are ' - 'no vlan ids available.') + raise exceptions.SegmentationIdAllocationFailure( + 'There are no vlan ids available.') except KeyError: # Other thread obtained the same vlan_id, so a new try is # needed continue - raise exceptions.SegmentationIdAllocationFailure('Max number of ' - 'retries reached without finding an available vlan id.') + raise exceptions.SegmentationIdAllocationFailure( + 'Max number of retries reached without ' + 'finding an available vlan id.') def release_segmentation_id(self, id): self.available_local_vlans.add(id) diff --git a/kuryr/lib/utils.py b/kuryr/lib/utils.py index ea5f7bc7..0b83bf87 100644 --- a/kuryr/lib/utils.py +++ b/kuryr/lib/utils.py @@ -77,8 +77,12 @@ def get_dict_format_fixed_ips_from_kv_format(fixed_ips): subnet_id = fixed_ip.split('=')[1] else: ip = fixed_ip.split('=')[1] - new_fixed_ips.append({'subnet_id': subnet_id, - 'ip_address': ip}) + new_fixed_ips.append( + { + 'subnet_id': subnet_id, + 'ip_address': ip + } + ) return new_fixed_ips diff --git a/kuryr/tests/unit/base.py b/kuryr/tests/unit/base.py index 2c87aa01..500813be 100644 --- a/kuryr/tests/unit/base.py +++ b/kuryr/tests/unit/base.py @@ -52,28 +52,32 @@ class TestCase(base.BaseTestCase): # http://developer.openstack.org/api-ref-networking-v2.html#createSubnet # noqa fake_subnet_response = { "subnets": [ - {"name": '-'.join([docker_endpoint_id, '192.168.1.0']), - "network_id": neutron_network_id, - "tenant_id": "c1210485b2424d48804aad5d39c61b8f", - "allocation_pools": [{"start": "192.168.1.2", - "end": "192.168.1.254"}], - "gateway_ip": "192.168.1.1", - "ip_version": 4, - "cidr": "192.168.1.0/24", - "id": fake_neutron_subnet_v4_id, - "enable_dhcp": True, - "subnetpool_id": ''}, - {"name": '-'.join([docker_endpoint_id, 'fe80::']), - "network_id": neutron_network_id, - "tenant_id": "c1210485b2424d48804aad5d39c61b8f", - "allocation_pools": [{"start": "fe80::f816:3eff:fe20:57c4", - "end": "fe80::ffff:ffff:ffff:ffff"}], - "gateway_ip": "fe80::f816:3eff:fe20:57c3", - "ip_version": 6, - "cidr": "fe80::/64", - "id": fake_neutron_subnet_v6_id, - "enable_dhcp": True, - "subnetpool_id": ''} + { + "name": '-'.join([docker_endpoint_id, '192.168.1.0']), + "network_id": neutron_network_id, + "tenant_id": "c1210485b2424d48804aad5d39c61b8f", + "allocation_pools": [{"start": "192.168.1.2", + "end": "192.168.1.254"}], + "gateway_ip": "192.168.1.1", + "ip_version": 4, + "cidr": "192.168.1.0/24", + "id": fake_neutron_subnet_v4_id, + "enable_dhcp": True, + "subnetpool_id": '' + }, + { + "name": '-'.join([docker_endpoint_id, 'fe80::']), + "network_id": neutron_network_id, + "tenant_id": "c1210485b2424d48804aad5d39c61b8f", + "allocation_pools": [{"start": "fe80::f816:3eff:fe20:57c4", + "end": "fe80::ffff:ffff:ffff:ffff"}], + "gateway_ip": "fe80::f816:3eff:fe20:57c3", + "ip_version": 6, + "cidr": "fe80::/64", + "id": fake_neutron_subnet_v6_id, + "enable_dhcp": True, + "subnetpool_id": '' + } ] } return fake_subnet_response diff --git a/kuryr/tests/unit/test_utils.py b/kuryr/tests/unit/test_utils.py index e4506cdf..747cbb88 100644 --- a/kuryr/tests/unit/test_utils.py +++ b/kuryr/tests/unit/test_utils.py @@ -102,5 +102,6 @@ class TestKuryrUtils(base.TestCase): def test_get_random_string(self): fake_string_len = 20 - self.assertEqual(fake_string_len, + self.assertEqual( + fake_string_len, len(utils.get_random_string(fake_string_len))) diff --git a/tox.ini b/tox.ini index b51c3088..a2ce8ca0 100644 --- a/tox.ini +++ b/tox.ini @@ -53,11 +53,10 @@ commands = python setup.py build_sphinx [flake8] # E125 continuation line does not distinguish itself from next logical line # E126 continuation line over-indented for hanging indent -# E128 continuation line under-indented for visual indent # E129 visually indented line with same indent as next logical line # E265 block comment should start with '# ' # N530 direct neutron imports not allowed -ignore = E125,E126,E128,E129,E265,H301,N530 +ignore = E125,E126,E129,E265,H301,N530 show-source = true exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes