Bump the minimum pyroute2 version to 0.7.3
This patch also removes the pylint disablement message control statements and imports NetNS and IPRoute from the new locations in pyroute2. Trivial-Fix Change-Id: I298a7da767473c236ddf03c5702a2904d4870284
This commit is contained in:
parent
b71b25820b
commit
1d84aaf877
@ -21,8 +21,7 @@ from neutron_lib.plugins.ml2 import ovs_constants
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from pyroute2.netlink import exceptions \
|
||||
as netlink_exceptions # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions as netlink_exceptions
|
||||
|
||||
from neutron.agent.linux import bridge_lib
|
||||
from neutron.conf.agent import l2_ext_fdb_population
|
||||
|
@ -19,8 +19,7 @@ import netaddr
|
||||
from neutron_lib import constants as lib_constants
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from pyroute2.netlink import exceptions \
|
||||
as pyroute2_exc # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions as pyroute2_exc
|
||||
|
||||
from neutron.agent.l3 import dvr_fip_ns
|
||||
from neutron.agent.l3 import dvr_router_base
|
||||
|
@ -21,8 +21,7 @@ from neutron_lib.exceptions import l3 as l3_exc
|
||||
from neutron_lib.utils import helpers
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import netutils
|
||||
from pyroute2.netlink import exceptions \
|
||||
as pyroute2_exc # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions as pyroute2_exc
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent.l3 import namespaces
|
||||
|
@ -20,8 +20,7 @@ import collections
|
||||
import functools
|
||||
import os
|
||||
|
||||
from pyroute2.netlink import exceptions \
|
||||
as netlink_exceptions # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions as netlink_exceptions
|
||||
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
|
@ -24,8 +24,7 @@ from neutron_lib import exceptions
|
||||
from neutron_lib.plugins.ml2 import ovs_constants as ovs_const
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from pyroute2.netlink import exceptions \
|
||||
as pyroute2_exc # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions as pyroute2_exc
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent.common import ovs_lib
|
||||
|
@ -26,13 +26,11 @@ from neutron_lib import exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import netutils
|
||||
from pyroute2.netlink import exceptions \
|
||||
as netlink_exceptions # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import rtnl # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink.rtnl import \
|
||||
ifaddrmsg # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink.rtnl import ifinfmsg # pylint: disable=no-name-in-module
|
||||
from pyroute2 import netns # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions as netlink_exceptions
|
||||
from pyroute2.netlink import rtnl
|
||||
from pyroute2.netlink.rtnl import ifaddrmsg
|
||||
from pyroute2.netlink.rtnl import ifinfmsg
|
||||
from pyroute2 import netns
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent.common import utils
|
||||
|
@ -21,11 +21,9 @@ from neutron_lib import exceptions
|
||||
from neutron_lib.exceptions import qos as qos_exc
|
||||
from neutron_lib.services.qos import constants as qos_consts
|
||||
from oslo_log import log as logging
|
||||
from pyroute2.iproute import linux \
|
||||
as iproute_linux # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import rtnl # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink.rtnl.tcmsg import common \
|
||||
as rtnl_common # pylint: disable=no-name-in-module
|
||||
from pyroute2.iproute import linux as iproute_linux
|
||||
from pyroute2.netlink import rtnl
|
||||
from pyroute2.netlink.rtnl.tcmsg import common as rtnl_common
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent.linux import ip_lib
|
||||
|
@ -17,14 +17,13 @@ import socket
|
||||
import netaddr
|
||||
from neutron_lib import constants
|
||||
from oslo_log import log as logging
|
||||
import pyroute2
|
||||
from pyroute2 import netlink # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import exceptions \
|
||||
as netlink_exceptions # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink import rtnl # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink.rtnl import ifinfmsg # pylint: disable=no-name-in-module
|
||||
from pyroute2.netlink.rtnl import ndmsg # pylint: disable=no-name-in-module
|
||||
from pyroute2 import netns # pylint: disable=no-name-in-module
|
||||
from pyroute2 import iproute
|
||||
from pyroute2.netlink import exceptions as netlink_exceptions
|
||||
from pyroute2.netlink import rtnl
|
||||
from pyroute2.netlink.rtnl import ifinfmsg
|
||||
from pyroute2.netlink.rtnl import ndmsg
|
||||
from pyroute2 import netns
|
||||
from pyroute2.nslink import nslink
|
||||
import tenacity
|
||||
|
||||
from neutron._i18n import _
|
||||
@ -147,15 +146,15 @@ def get_iproute(namespace):
|
||||
# `NetNS` -- RTNL API to another network namespace
|
||||
if namespace:
|
||||
# do not try and create the namespace
|
||||
return pyroute2.NetNS(namespace, flags=0, libc=priv_linux.get_cdll())
|
||||
return nslink.NetNS(namespace, flags=0, libc=priv_linux.get_cdll())
|
||||
else:
|
||||
return pyroute2.IPRoute()
|
||||
return iproute.IPRoute()
|
||||
|
||||
|
||||
@privileged.default.entrypoint
|
||||
def open_namespace(namespace):
|
||||
"""Open namespace to test if the namespace is ready to be manipulated"""
|
||||
with pyroute2.NetNS(namespace, flags=0):
|
||||
with nslink.NetNS(namespace, flags=0):
|
||||
pass
|
||||
|
||||
|
||||
@ -213,7 +212,7 @@ def _run_iproute_link(command, device, namespace=None, **kwargs):
|
||||
with get_iproute(namespace) as ip:
|
||||
idx = get_link_id(device, namespace)
|
||||
return ip.link(command, index=idx, **kwargs)
|
||||
except netlink.NetlinkError as e:
|
||||
except netlink_exceptions.NetlinkError as e:
|
||||
_translate_ip_device_exception(e, device, namespace)
|
||||
raise
|
||||
except OSError as e:
|
||||
|
@ -17,8 +17,7 @@ import socket
|
||||
|
||||
from neutron_lib import constants as n_constants
|
||||
import pyroute2
|
||||
from pyroute2 import protocols \
|
||||
as pyroute2_protocols # pylint: disable=no-name-in-module
|
||||
from pyroute2 import protocols as pyroute2_protocols
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron import privileged
|
||||
|
@ -23,11 +23,11 @@ from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from oslo_utils import netutils
|
||||
from oslo_utils import uuidutils
|
||||
import pyroute2
|
||||
from pyroute2.netlink import exceptions as netlink_exceptions
|
||||
from pyroute2.netlink.rtnl import ifinfmsg
|
||||
from pyroute2.netlink.rtnl import ndmsg
|
||||
from pyroute2 import NetlinkError
|
||||
from pyroute2 import netns
|
||||
from pyroute2.nslink import nslink
|
||||
import testtools
|
||||
|
||||
from neutron.agent.common import utils # noqa
|
||||
@ -957,7 +957,7 @@ class TestIpNeighCommand(TestIPCmdBase):
|
||||
self.addCleanup(privileged.default.set_client_mode, True)
|
||||
privileged.default.set_client_mode(False)
|
||||
|
||||
@mock.patch.object(pyroute2, 'NetNS')
|
||||
@mock.patch.object(nslink, 'NetNS')
|
||||
def test_add_entry(self, mock_netns):
|
||||
mock_netns_instance = mock_netns.return_value
|
||||
mock_netns_enter = mock_netns_instance.__enter__.return_value
|
||||
@ -972,20 +972,20 @@ class TestIpNeighCommand(TestIPCmdBase):
|
||||
ifindex=1,
|
||||
state=ndmsg.states['permanent'])
|
||||
|
||||
@mock.patch.object(pyroute2, 'NetNS')
|
||||
@mock.patch.object(nslink, 'NetNS')
|
||||
def test_add_entry_nonexistent_namespace(self, mock_netns):
|
||||
mock_netns.side_effect = OSError(errno.ENOENT, None)
|
||||
with testtools.ExpectedException(ip_lib.NetworkNamespaceNotFound):
|
||||
self.neigh_cmd.add('192.168.45.100', 'cc:dd:ee:ff:ab:cd')
|
||||
|
||||
@mock.patch.object(pyroute2, 'NetNS')
|
||||
@mock.patch.object(nslink, 'NetNS')
|
||||
def test_add_entry_other_error(self, mock_netns):
|
||||
expected_exception = OSError(errno.EACCES, None)
|
||||
mock_netns.side_effect = expected_exception
|
||||
with testtools.ExpectedException(expected_exception.__class__):
|
||||
self.neigh_cmd.add('192.168.45.100', 'cc:dd:ee:ff:ab:cd')
|
||||
|
||||
@mock.patch.object(pyroute2, 'NetNS')
|
||||
@mock.patch.object(nslink, 'NetNS')
|
||||
def test_delete_entry(self, mock_netns):
|
||||
mock_netns_instance = mock_netns.return_value
|
||||
mock_netns_enter = mock_netns_instance.__enter__.return_value
|
||||
@ -1002,10 +1002,11 @@ class TestIpNeighCommand(TestIPCmdBase):
|
||||
@mock.patch.object(priv_lib, '_run_iproute_neigh')
|
||||
def test_delete_entry_not_exist(self, mock_run_iproute):
|
||||
# trying to delete a non-existent entry shouldn't raise an error
|
||||
mock_run_iproute.side_effect = NetlinkError(errno.ENOENT, None)
|
||||
mock_run_iproute.side_effect = netlink_exceptions.NetlinkError(
|
||||
errno.ENOENT, None)
|
||||
self.neigh_cmd.delete('192.168.45.100', 'cc:dd:ee:ff:ab:cd')
|
||||
|
||||
@mock.patch.object(pyroute2, 'NetNS')
|
||||
@mock.patch.object(nslink, 'NetNS')
|
||||
def test_dump_entries(self, mock_netns):
|
||||
mock_netns_instance = mock_netns.return_value
|
||||
mock_netns_enter = mock_netns_instance.__enter__.return_value
|
||||
|
@ -15,9 +15,10 @@
|
||||
import errno
|
||||
from unittest import mock
|
||||
|
||||
import pyroute2
|
||||
from pyroute2 import iproute
|
||||
from pyroute2 import netlink
|
||||
from pyroute2.netlink import exceptions as netlink_exceptions
|
||||
from pyroute2.nslink import nslink
|
||||
|
||||
from neutron.privileged.agent.linux import ip_lib as priv_lib
|
||||
from neutron.tests import base
|
||||
@ -27,7 +28,8 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
|
||||
def _test_run_iproute_link(self, namespace=None):
|
||||
ip_obj = "NetNS" if namespace else "IPRoute"
|
||||
with mock.patch.object(pyroute2, ip_obj) as ip_mock_cls:
|
||||
_mod = nslink if namespace else iproute
|
||||
with mock.patch.object(_mod, ip_obj) as ip_mock_cls:
|
||||
ip_mock = ip_mock_cls()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
priv_lib._run_iproute_link("test_cmd", "eth0", namespace,
|
||||
@ -45,7 +47,7 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
self._test_run_iproute_link(namespace="testns")
|
||||
|
||||
def test_run_iproute_link_interface_not_exists(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ret_values = [
|
||||
[], # No interface found.
|
||||
@ -67,29 +69,29 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
priv_lib.get_link_id('device', 'namespace'))
|
||||
|
||||
def test_run_iproute_link_interface_removed_during_call(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
ip_mock.__enter__().link.side_effect = pyroute2.NetlinkError(
|
||||
code=errno.ENODEV)
|
||||
ip_mock.__enter__().link.side_effect = (
|
||||
netlink_exceptions.NetlinkError(code=errno.ENODEV))
|
||||
self.assertRaises(
|
||||
priv_lib.NetworkInterfaceNotFound,
|
||||
priv_lib._run_iproute_link,
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_link_op_not_supported(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
ip_mock.__enter__().link.side_effect = pyroute2.NetlinkError(
|
||||
code=errno.EOPNOTSUPP)
|
||||
ip_mock.__enter__().link.side_effect = (
|
||||
netlink_exceptions.NetlinkError(code=errno.EOPNOTSUPP))
|
||||
self.assertRaises(
|
||||
priv_lib.InterfaceOperationNotSupported,
|
||||
priv_lib._run_iproute_link,
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_link_namespace_not_exists(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
iproute_mock.side_effect = OSError(
|
||||
errno.ENOENT, "Test no netns exception")
|
||||
self.assertRaises(
|
||||
@ -98,7 +100,7 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_link_error(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
iproute_mock.side_effect = OSError(
|
||||
errno.EINVAL, "Test invalid argument exception")
|
||||
try:
|
||||
@ -110,7 +112,8 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
|
||||
def _test_run_iproute_neigh(self, namespace=None):
|
||||
ip_obj = "NetNS" if namespace else "IPRoute"
|
||||
with mock.patch.object(pyroute2, ip_obj) as ip_mock_cls:
|
||||
_mod = nslink if namespace else iproute
|
||||
with mock.patch.object(_mod, ip_obj) as ip_mock_cls:
|
||||
ip_mock = ip_mock_cls()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
priv_lib._run_iproute_neigh("test_cmd", "eth0", namespace,
|
||||
@ -128,7 +131,7 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
self._test_run_iproute_neigh(namespace="testns")
|
||||
|
||||
def test_run_iproute_neigh_interface_not_exists(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ip_mock.__enter__().link_lookup.return_value = []
|
||||
self.assertRaises(
|
||||
@ -137,18 +140,18 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_neigh_interface_removed_during_call(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
ip_mock.__enter__().neigh.side_effect = pyroute2.NetlinkError(
|
||||
code=errno.ENODEV)
|
||||
ip_mock.__enter__().neigh.side_effect = (
|
||||
netlink_exceptions.NetlinkError(code=errno.ENODEV))
|
||||
self.assertRaises(
|
||||
priv_lib.NetworkInterfaceNotFound,
|
||||
priv_lib._run_iproute_neigh,
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_neigh_namespace_not_exists(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
iproute_mock.side_effect = OSError(
|
||||
errno.ENOENT, "Test no netns exception")
|
||||
self.assertRaises(
|
||||
@ -157,7 +160,7 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_neigh_error(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
iproute_mock.side_effect = OSError(
|
||||
errno.EINVAL, "Test invalid argument exception")
|
||||
try:
|
||||
@ -169,7 +172,8 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
|
||||
def _test_run_iproute_addr(self, namespace=None):
|
||||
ip_obj = "NetNS" if namespace else "IPRoute"
|
||||
with mock.patch.object(pyroute2, ip_obj) as ip_mock_cls:
|
||||
_mod = nslink if namespace else iproute
|
||||
with mock.patch.object(_mod, ip_obj) as ip_mock_cls:
|
||||
ip_mock = ip_mock_cls()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
priv_lib._run_iproute_addr("test_cmd", "eth0", namespace,
|
||||
@ -187,7 +191,7 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
self._test_run_iproute_addr(namespace="testns")
|
||||
|
||||
def test_run_iproute_addr_interface_not_exists(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ip_mock.__enter__().link_lookup.return_value = []
|
||||
self.assertRaises(
|
||||
@ -196,18 +200,18 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_addr_interface_removed_during_call(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
ip_mock = iproute_mock()
|
||||
ip_mock.__enter__().link_lookup.return_value = [2]
|
||||
ip_mock.__enter__().addr.side_effect = pyroute2.NetlinkError(
|
||||
code=errno.ENODEV)
|
||||
ip_mock.__enter__().addr.side_effect = (
|
||||
netlink_exceptions.NetlinkError(code=errno.ENODEV))
|
||||
self.assertRaises(
|
||||
priv_lib.NetworkInterfaceNotFound,
|
||||
priv_lib._run_iproute_addr,
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_addr_namespace_not_exists(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
iproute_mock.side_effect = OSError(
|
||||
errno.ENOENT, "Test no netns exception")
|
||||
self.assertRaises(
|
||||
@ -216,7 +220,7 @@ class IpLibTestCase(base.BaseTestCase):
|
||||
"test_cmd", "eth0", None, test_param="test_value")
|
||||
|
||||
def test_run_iproute_addr_error(self):
|
||||
with mock.patch.object(pyroute2, "IPRoute") as iproute_mock:
|
||||
with mock.patch.object(iproute, "IPRoute") as iproute_mock:
|
||||
iproute_mock.side_effect = OSError(
|
||||
errno.EINVAL, "Test invalid argument exception")
|
||||
try:
|
||||
|
@ -53,7 +53,7 @@ ovs>=2.10.0 # Apache-2.0
|
||||
ovsdbapp>=1.16.0 # Apache-2.0
|
||||
packaging>=20.4 # Apache-2.0
|
||||
psutil>=5.3.0 # BSD
|
||||
pyroute2>=0.6.6;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
|
||||
pyroute2>=0.7.3;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
|
||||
pyOpenSSL>=17.1.0 # Apache-2.0
|
||||
|
||||
python-novaclient>=9.1.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user