Cleanup and enforce pep8 checks
tox.ini contains a bunch of excludes, that are unnecessary. Some are leftovers from neutron. Some are already fixed and there is no point in excluding them and some are easy to fix. This commit does not fix E128 as it is the only serious exclusion with (currently 166 lines to be changed) Change-Id: I48cb6cd2258b2d8ed5b8dfdd3ceac7d8d573be81
This commit is contained in:
parent
87039c64ea
commit
6d9e564251
|
@ -64,7 +64,7 @@ class BridgeDriver(BaseBridgeDriver):
|
||||||
class VIFOpenVSwitchDriver(BaseBridgeDriver):
|
class VIFOpenVSwitchDriver(BaseBridgeDriver):
|
||||||
def connect(self, vif, ifname, netns):
|
def connect(self, vif, ifname, netns):
|
||||||
super(VIFOpenVSwitchDriver, self).connect(vif, ifname, netns)
|
super(VIFOpenVSwitchDriver, self).connect(vif, ifname, netns)
|
||||||
#FIXME(irenab) use pod_id (neutron port device_id)
|
# FIXME(irenab) use pod_id (neutron port device_id)
|
||||||
instance_id = 'kuryr'
|
instance_id = 'kuryr'
|
||||||
net_utils.create_ovs_vif_port(vif.bridge_name, vif.vif_name,
|
net_utils.create_ovs_vif_port(vif.bridge_name, vif.vif_name,
|
||||||
vif.port_profile.interface_id,
|
vif.port_profile.interface_id,
|
||||||
|
|
|
@ -69,9 +69,9 @@ class DriverBase(object):
|
||||||
if not isinstance(driver, cls):
|
if not isinstance(driver, cls):
|
||||||
raise TypeError(_("Invalid %(alias)r driver type: %(driver)s, "
|
raise TypeError(_("Invalid %(alias)r driver type: %(driver)s, "
|
||||||
"must be a subclass of %(type)s") % {
|
"must be a subclass of %(type)s") % {
|
||||||
'alias': alias,
|
'alias': alias,
|
||||||
'driver': driver.__class__.__name__,
|
'driver': driver.__class__.__name__,
|
||||||
'type': cls})
|
'type': cls})
|
||||||
return driver
|
return driver
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,74 +1,74 @@
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from kuryr.lib._i18n import _
|
from kuryr.lib._i18n import _
|
||||||
from kuryr.lib import exceptions as kl_exc
|
from kuryr.lib import exceptions as kl_exc
|
||||||
from neutronclient.common import exceptions as n_exc
|
from neutronclient.common import exceptions as n_exc
|
||||||
from oslo_config import cfg as oslo_cfg
|
from oslo_config import cfg as oslo_cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from kuryr_kubernetes.controller.drivers import neutron_vif
|
from kuryr_kubernetes.controller.drivers import neutron_vif
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Moved out from neutron_defaults group
|
# Moved out from neutron_defaults group
|
||||||
nested_vif_driver_opts = [
|
nested_vif_driver_opts = [
|
||||||
oslo_cfg.StrOpt('worker_nodes_subnet',
|
oslo_cfg.StrOpt('worker_nodes_subnet',
|
||||||
help=_("Neutron subnet ID for k8s worker node vms.")),
|
help=_("Neutron subnet ID for k8s worker node vms.")),
|
||||||
]
|
]
|
||||||
|
|
||||||
oslo_cfg.CONF.register_opts(nested_vif_driver_opts, "pod_vif_nested")
|
oslo_cfg.CONF.register_opts(nested_vif_driver_opts, "pod_vif_nested")
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver):
|
class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver):
|
||||||
"""Skeletal handler driver for VIFs for Nested Pods."""
|
"""Skeletal handler driver for VIFs for Nested Pods."""
|
||||||
|
|
||||||
def _get_parent_port(self, neutron, pod):
|
def _get_parent_port(self, neutron, pod):
|
||||||
node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet
|
node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet
|
||||||
if not node_subnet_id:
|
if not node_subnet_id:
|
||||||
raise oslo_cfg.RequiredOptError('worker_nodes_subnet',
|
raise oslo_cfg.RequiredOptError('worker_nodes_subnet',
|
||||||
oslo_cfg.OptGroup('pod_vif_nested'))
|
oslo_cfg.OptGroup('pod_vif_nested'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# REVISIT(vikasc): Assumption is being made that hostIP is the IP
|
# REVISIT(vikasc): Assumption is being made that hostIP is the IP
|
||||||
# of trunk interface on the node(vm).
|
# of trunk interface on the node(vm).
|
||||||
node_fixed_ip = pod['status']['hostIP']
|
node_fixed_ip = pod['status']['hostIP']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if pod['status']['conditions'][0]['type'] != "Initialized":
|
if pod['status']['conditions'][0]['type'] != "Initialized":
|
||||||
LOG.debug("Pod condition type is not 'Initialized'")
|
LOG.debug("Pod condition type is not 'Initialized'")
|
||||||
|
|
||||||
LOG.error("Failed to get parent vm port ip")
|
LOG.error("Failed to get parent vm port ip")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
|
fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
|
||||||
'ip_address=%s' % str(node_fixed_ip)]
|
'ip_address=%s' % str(node_fixed_ip)]
|
||||||
ports = neutron.list_ports(fixed_ips=fixed_ips)
|
ports = neutron.list_ports(fixed_ips=fixed_ips)
|
||||||
except n_exc.NeutronClientException as ex:
|
except n_exc.NeutronClientException as ex:
|
||||||
LOG.error("Parent vm port with fixed ips %s not found!",
|
LOG.error("Parent vm port with fixed ips %s not found!",
|
||||||
fixed_ips)
|
fixed_ips)
|
||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
if ports['ports']:
|
if ports['ports']:
|
||||||
return ports['ports'][0]
|
return ports['ports'][0]
|
||||||
else:
|
else:
|
||||||
LOG.error("Neutron port for vm port with fixed ips %s"
|
LOG.error("Neutron port for vm port with fixed ips %s"
|
||||||
" not found!", fixed_ips)
|
" not found!", fixed_ips)
|
||||||
raise kl_exc.NoResourceException
|
raise kl_exc.NoResourceException
|
||||||
|
|
|
@ -36,15 +36,15 @@ class LinuxNetworkUtilsTestCase(test_base.TestCase):
|
||||||
|
|
||||||
def test_create_ovs_vif_port(self):
|
def test_create_ovs_vif_port(self):
|
||||||
calls = [
|
calls = [
|
||||||
mock.call('ovs-vsctl', '--', '--if-exists',
|
mock.call('ovs-vsctl', '--', '--if-exists',
|
||||||
'del-port', 'fake-dev', '--', 'add-port',
|
'del-port', 'fake-dev', '--', 'add-port',
|
||||||
'fake-bridge', 'fake-dev',
|
'fake-bridge', 'fake-dev',
|
||||||
'--', 'set', 'Interface', 'fake-dev',
|
'--', 'set', 'Interface', 'fake-dev',
|
||||||
'external-ids:iface-id=fake-iface-id',
|
'external-ids:iface-id=fake-iface-id',
|
||||||
'external-ids:iface-status=active',
|
'external-ids:iface-status=active',
|
||||||
'external-ids:attached-mac=fake-mac',
|
'external-ids:attached-mac=fake-mac',
|
||||||
'external-ids:vm-uuid=fake-instance-uuid',
|
'external-ids:vm-uuid=fake-instance-uuid',
|
||||||
run_as_root=True)]
|
run_as_root=True)]
|
||||||
with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
|
with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
|
||||||
linux_net.create_ovs_vif_port('fake-bridge', 'fake-dev',
|
linux_net.create_ovs_vif_port('fake-bridge', 'fake-dev',
|
||||||
'fake-iface-id', 'fake-mac',
|
'fake-iface-id', 'fake-mac',
|
||||||
|
@ -53,9 +53,9 @@ class LinuxNetworkUtilsTestCase(test_base.TestCase):
|
||||||
|
|
||||||
def test_delete_ovs_vif_port(self):
|
def test_delete_ovs_vif_port(self):
|
||||||
calls = [
|
calls = [
|
||||||
mock.call('ovs-vsctl', '--', '--if-exists',
|
mock.call('ovs-vsctl', '--', '--if-exists',
|
||||||
'del-port', 'fake-bridge', 'fake-dev',
|
'del-port', 'fake-bridge', 'fake-dev',
|
||||||
run_as_root=True)]
|
run_as_root=True)]
|
||||||
with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
|
with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
|
||||||
linux_net.delete_ovs_vif_port('fake-bridge', 'fake-dev')
|
linux_net.delete_ovs_vif_port('fake-bridge', 'fake-dev')
|
||||||
ex.assert_has_calls(calls)
|
ex.assert_has_calls(calls)
|
||||||
|
|
|
@ -77,9 +77,9 @@ class TestNoOpPlugin(base.TestCase):
|
||||||
expected = objects.host_info.HostPluginInfo(
|
expected = objects.host_info.HostPluginInfo(
|
||||||
plugin_name='noop',
|
plugin_name='noop',
|
||||||
vif_info=[
|
vif_info=[
|
||||||
objects.host_info.HostVIFInfo(
|
objects.host_info.HostVIFInfo(
|
||||||
vif_object_name=k_vif.VIFVlanNested.__name__,
|
vif_object_name=k_vif.VIFVlanNested.__name__,
|
||||||
min_version="1.0",
|
min_version="1.0",
|
||||||
max_version="1.0"),
|
max_version="1.0"),
|
||||||
])
|
])
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
9
tox.ini
9
tox.ini
|
@ -49,15 +49,8 @@ commands =
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx
|
||||||
|
|
||||||
[flake8]
|
[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
|
# E128 continuation line under-indented for visual indent
|
||||||
# E129 visually indented line with same indent as next logical line
|
ignore = E128
|
||||||
# E265 block comment should start with '# '
|
|
||||||
# TODO(dougwig) -- uncomment this to test for remaining linkages
|
|
||||||
# N530 direct neutron imports not allowed
|
|
||||||
# N531 log message does not translate
|
|
||||||
ignore = E125,E126,E128,E129,E265,H301,N530,N531
|
|
||||||
show-source = true
|
show-source = true
|
||||||
|
|
||||||
# TODO(dougw) neutron/tests/unit/vmware exclusion is a temporary services split hack
|
# TODO(dougw) neutron/tests/unit/vmware exclusion is a temporary services split hack
|
||||||
|
|
Loading…
Reference in New Issue