Merge "E128 ignore statement make code unclearly"

This commit is contained in:
Jenkins 2017-02-13 14:30:43 +00:00 committed by Gerrit Code Review
commit 9583a26274
6 changed files with 42 additions and 33 deletions

View File

@ -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.')),

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)))

View File

@ -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