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', cfg.StrOpt('veth_dst_prefix',
default='eth', default='eth',
help=_('The name prefix of the veth endpoint put inside the ' help=_('The name prefix of the veth endpoint put inside the '
'container.')), 'container.')),
cfg.StrOpt('driver', cfg.StrOpt('driver',
default='kuryr.lib.binding.drivers.veth', default='kuryr.lib.binding.drivers.veth',
help=_('Driver to use for binding and unbinding ports.')), help=_('Driver to use for binding and unbinding ports.')),

View File

@ -22,7 +22,7 @@ DEFAULT_MAX_RETRY_COUNT = 3
class SegmentationDriver(object): class SegmentationDriver(object):
def __init__(self): def __init__(self):
self.available_local_vlans = set(moves.range(const.MIN_VLAN_TAG, 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()): def allocate_segmentation_id(self, allocated_ids=set()):
self.available_local_vlans.difference_update(allocated_ids) self.available_local_vlans.difference_update(allocated_ids)
@ -32,14 +32,15 @@ class SegmentationDriver(object):
self.available_local_vlans.remove(allocated) self.available_local_vlans.remove(allocated)
return allocated return allocated
except IndexError: except IndexError:
raise exceptions.SegmentationIdAllocationFailure('There are ' raise exceptions.SegmentationIdAllocationFailure(
'no vlan ids available.') 'There are no vlan ids available.')
except KeyError: except KeyError:
# Other thread obtained the same vlan_id, so a new try is # Other thread obtained the same vlan_id, so a new try is
# needed # needed
continue continue
raise exceptions.SegmentationIdAllocationFailure('Max number of ' raise exceptions.SegmentationIdAllocationFailure(
'retries reached without finding an available vlan id.') 'Max number of retries reached without '
'finding an available vlan id.')
def release_segmentation_id(self, id): def release_segmentation_id(self, id):
self.available_local_vlans.add(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] subnet_id = fixed_ip.split('=')[1]
else: else:
ip = fixed_ip.split('=')[1] ip = fixed_ip.split('=')[1]
new_fixed_ips.append({'subnet_id': subnet_id, new_fixed_ips.append(
'ip_address': ip}) {
'subnet_id': subnet_id,
'ip_address': ip
}
)
return new_fixed_ips 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 # http://developer.openstack.org/api-ref-networking-v2.html#createSubnet # noqa
fake_subnet_response = { fake_subnet_response = {
"subnets": [ "subnets": [
{"name": '-'.join([docker_endpoint_id, '192.168.1.0']), {
"network_id": neutron_network_id, "name": '-'.join([docker_endpoint_id, '192.168.1.0']),
"tenant_id": "c1210485b2424d48804aad5d39c61b8f", "network_id": neutron_network_id,
"allocation_pools": [{"start": "192.168.1.2", "tenant_id": "c1210485b2424d48804aad5d39c61b8f",
"end": "192.168.1.254"}], "allocation_pools": [{"start": "192.168.1.2",
"gateway_ip": "192.168.1.1", "end": "192.168.1.254"}],
"ip_version": 4, "gateway_ip": "192.168.1.1",
"cidr": "192.168.1.0/24", "ip_version": 4,
"id": fake_neutron_subnet_v4_id, "cidr": "192.168.1.0/24",
"enable_dhcp": True, "id": fake_neutron_subnet_v4_id,
"subnetpool_id": ''}, "enable_dhcp": True,
{"name": '-'.join([docker_endpoint_id, 'fe80::']), "subnetpool_id": ''
"network_id": neutron_network_id, },
"tenant_id": "c1210485b2424d48804aad5d39c61b8f", {
"allocation_pools": [{"start": "fe80::f816:3eff:fe20:57c4", "name": '-'.join([docker_endpoint_id, 'fe80::']),
"end": "fe80::ffff:ffff:ffff:ffff"}], "network_id": neutron_network_id,
"gateway_ip": "fe80::f816:3eff:fe20:57c3", "tenant_id": "c1210485b2424d48804aad5d39c61b8f",
"ip_version": 6, "allocation_pools": [{"start": "fe80::f816:3eff:fe20:57c4",
"cidr": "fe80::/64", "end": "fe80::ffff:ffff:ffff:ffff"}],
"id": fake_neutron_subnet_v6_id, "gateway_ip": "fe80::f816:3eff:fe20:57c3",
"enable_dhcp": True, "ip_version": 6,
"subnetpool_id": ''} "cidr": "fe80::/64",
"id": fake_neutron_subnet_v6_id,
"enable_dhcp": True,
"subnetpool_id": ''
}
] ]
} }
return fake_subnet_response return fake_subnet_response

View File

@ -102,5 +102,6 @@ class TestKuryrUtils(base.TestCase):
def test_get_random_string(self): def test_get_random_string(self):
fake_string_len = 20 fake_string_len = 20
self.assertEqual(fake_string_len, self.assertEqual(
fake_string_len,
len(utils.get_random_string(fake_string_len))) len(utils.get_random_string(fake_string_len)))

View File

@ -53,11 +53,10 @@ commands = python setup.py build_sphinx
[flake8] [flake8]
# E125 continuation line does not distinguish itself from next logical line # E125 continuation line does not distinguish itself from next logical line
# E126 continuation line over-indented for hanging indent # 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 # E129 visually indented line with same indent as next logical line
# E265 block comment should start with '# ' # E265 block comment should start with '# '
# N530 direct neutron imports not allowed # N530 direct neutron imports not allowed
ignore = E125,E126,E128,E129,E265,H301,N530 ignore = E125,E126,E129,E265,H301,N530
show-source = true show-source = true
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.ropeproject,rally-scenarios,releasenotes