Merge "Migrate "ethtool" to oslo.privsep"
This commit is contained in:
commit
8441737127
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
# dhcp-agent
|
# dhcp-agent
|
||||||
dnsmasq: CommandFilter, dnsmasq, root
|
dnsmasq: CommandFilter, dnsmasq, root
|
||||||
ethtool: CommandFilter, ethtool, root
|
|
||||||
# dhcp-agent uses kill as well, that's handled by the generic KillFilter
|
# dhcp-agent uses kill as well, that's handled by the generic KillFilter
|
||||||
# it looks like these are the only signals needed, per
|
# it looks like these are the only signals needed, per
|
||||||
# neutron/agent/linux/dhcp.py
|
# neutron/agent/linux/dhcp.py
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
arping: CommandFilter, arping, root
|
arping: CommandFilter, arping, root
|
||||||
|
|
||||||
# l3_agent
|
# l3_agent
|
||||||
ethtool: CommandFilter, ethtool, root
|
|
||||||
sysctl: CommandFilter, sysctl, root
|
sysctl: CommandFilter, sysctl, root
|
||||||
route: CommandFilter, route, root
|
route: CommandFilter, route, root
|
||||||
radvd: CommandFilter, radvd, root
|
radvd: CommandFilter, radvd, root
|
||||||
|
@ -24,12 +24,12 @@ from oslo_utils import excutils
|
|||||||
from pyroute2.netlink import exceptions as pyroute2_exc
|
from pyroute2.netlink import exceptions as pyroute2_exc
|
||||||
|
|
||||||
from neutron.agent.common import ovs_lib
|
from neutron.agent.common import ovs_lib
|
||||||
from neutron.agent.linux import ethtool
|
|
||||||
from neutron.agent.linux import ip_lib
|
from neutron.agent.linux import ip_lib
|
||||||
from neutron.common import utils
|
from neutron.common import utils
|
||||||
from neutron.conf.plugins.ml2.drivers import ovs_conf
|
from neutron.conf.plugins.ml2.drivers import ovs_conf
|
||||||
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
||||||
import constants as ovs_const
|
import constants as ovs_const
|
||||||
|
from neutron.privileged.agent.linux import ethtool
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
|
|||||||
# ovs-dpdk does not do checksum calculations for veth interface
|
# ovs-dpdk does not do checksum calculations for veth interface
|
||||||
# (bug 1832021)
|
# (bug 1832021)
|
||||||
if self.conf.OVS.datapath_type == ovs_const.OVS_DATAPATH_NETDEV:
|
if self.conf.OVS.datapath_type == ovs_const.OVS_DATAPATH_NETDEV:
|
||||||
ethtool.Ethtool.offload(ns_dev.name, rx=False, tx=False,
|
ethtool.offload(ns_dev.name, rx=False, tx=False,
|
||||||
namespace=namespace)
|
namespace=namespace)
|
||||||
root_dev.link.set_up()
|
root_dev.link.set_up()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Copyright 2020 OpenStack Foundation
|
# Copyright 2020 Red Hat, Inc.
|
||||||
# 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
|
||||||
@ -13,22 +13,19 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.agent.linux import ip_lib
|
from oslo_concurrency import processutils
|
||||||
|
|
||||||
|
from neutron import privileged
|
||||||
|
|
||||||
|
COMMAND = 'ethtool'
|
||||||
|
|
||||||
|
|
||||||
class Ethtool(object):
|
@privileged.default.entrypoint
|
||||||
|
def offload(device, rx, tx, namespace=None):
|
||||||
COMMAND = 'ethtool'
|
cmd = []
|
||||||
|
if namespace:
|
||||||
@staticmethod
|
cmd += ['ip', 'netns', 'exec', namespace]
|
||||||
def _cmd(cmd, namespace, **kwargs):
|
|
||||||
ip_wrapper = ip_lib.IPWrapper(namespace)
|
|
||||||
return ip_wrapper.netns.execute(cmd, run_as_root=True, **kwargs)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def offload(cls, device, rx, tx, namespace=None):
|
|
||||||
rx = 'on' if rx else 'off'
|
rx = 'on' if rx else 'off'
|
||||||
tx = 'on' if tx else 'off'
|
tx = 'on' if tx else 'off'
|
||||||
cmd = ['--offload', device, 'rx', rx, 'tx', tx]
|
cmd += [COMMAND, '--offload', device, 'rx', rx, 'tx', tx]
|
||||||
cmd = [cls.COMMAND] + cmd
|
return processutils.execute(*cmd)
|
||||||
cls._cmd(cmd, namespace)
|
|
@ -20,7 +20,6 @@ from oslo_utils import excutils
|
|||||||
from pyroute2.netlink import exceptions as pyroute2_exc
|
from pyroute2.netlink import exceptions as pyroute2_exc
|
||||||
|
|
||||||
from neutron.agent.common import ovs_lib
|
from neutron.agent.common import ovs_lib
|
||||||
from neutron.agent.linux import ethtool
|
|
||||||
from neutron.agent.linux import interface
|
from neutron.agent.linux import interface
|
||||||
from neutron.agent.linux import ip_lib
|
from neutron.agent.linux import ip_lib
|
||||||
from neutron.common import utils
|
from neutron.common import utils
|
||||||
@ -28,6 +27,7 @@ from neutron.conf.agent import common as config
|
|||||||
from neutron.conf.plugins.ml2.drivers import ovs_conf
|
from neutron.conf.plugins.ml2.drivers import ovs_conf
|
||||||
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
|
||||||
import constants as ovs_const
|
import constants as ovs_const
|
||||||
|
from neutron.privileged.agent.linux import ethtool
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ class TestBase(base.BaseTestCase):
|
|||||||
self.conf = config.setup_conf()
|
self.conf = config.setup_conf()
|
||||||
ovs_conf.register_ovs_opts(self.conf)
|
ovs_conf.register_ovs_opts(self.conf)
|
||||||
config.register_interface_opts(self.conf)
|
config.register_interface_opts(self.conf)
|
||||||
self.eth_tool_p = mock.patch.object(ethtool, 'Ethtool')
|
self.eth_offload_p = mock.patch.object(ethtool, 'offload')
|
||||||
self.eth_tool = self.eth_tool_p.start()
|
self.eth_offload = self.eth_offload_p.start()
|
||||||
self.ip_dev_p = mock.patch.object(ip_lib, 'IPDevice')
|
self.ip_dev_p = mock.patch.object(ip_lib, 'IPDevice')
|
||||||
self.ip_dev = self.ip_dev_p.start()
|
self.ip_dev = self.ip_dev_p.start()
|
||||||
self.ip_p = mock.patch.object(ip_lib, 'IPWrapper')
|
self.ip_p = mock.patch.object(ip_lib, 'IPWrapper')
|
||||||
@ -591,9 +591,8 @@ class TestOVSInterfaceDriverWithVeth(TestOVSInterfaceDriver):
|
|||||||
self.ip.assert_has_calls(expected)
|
self.ip.assert_has_calls(expected)
|
||||||
root_dev.assert_has_calls([mock.call.link.set_up()])
|
root_dev.assert_has_calls([mock.call.link.set_up()])
|
||||||
ns_dev.assert_has_calls([mock.call.link.set_up()])
|
ns_dev.assert_has_calls([mock.call.link.set_up()])
|
||||||
self.eth_tool.assert_has_calls([mock.call.offload(
|
self.eth_offload.assert_has_calls(
|
||||||
devname, rx=False,
|
[mock.call(devname, rx=False, tx=False, namespace=namespace)])
|
||||||
tx=False, namespace=namespace)])
|
|
||||||
|
|
||||||
def test_plug_new(self):
|
def test_plug_new(self):
|
||||||
# The purpose of test_plug_new in parent class(TestOVSInterfaceDriver)
|
# The purpose of test_plug_new in parent class(TestOVSInterfaceDriver)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user