From 19b96628378357b9df2b8bb9285f71b7c7b66ca4 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Thu, 16 Dec 2021 16:56:42 +0100 Subject: [PATCH] Remove _safe_plug_new method from the interface driver It was added temporary to have compatybility with 3rd party code which uses Neutron interface driver but it was said that since "W" release that old, deprecated way of calling "plug_new" method will be removed. Now we are far after "W" release so it's time to do some cleaning there. Related-Bug: #1879307 Change-Id: I03214079f752c7efe6611f2e928f32652fe681bc --- neutron/agent/linux/interface.py | 21 ++------------ .../tests/unit/agent/linux/test_interface.py | 28 ------------------- ...iver-plug_new-method-3377ce0b776df6b2.yaml | 9 ++++++ 3 files changed, 11 insertions(+), 47 deletions(-) create mode 100644 releasenotes/notes/Remove-deprecated-way-of-calling-interface-driver-plug_new-method-3377ce0b776df6b2.yaml diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index 39d7a1f3e7c..4b18fb58ad2 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -267,9 +267,8 @@ class LinuxInterfaceDriver(object, metaclass=abc.ABCMeta): bridge=None, namespace=None, prefix=None, mtu=None, link_up=True): if not ip_lib.device_exists(device_name, namespace=namespace): - self._safe_plug_new( - network_id, port_id, device_name, mac_address, bridge, - namespace, prefix, mtu, link_up) + self.plug_new(network_id, port_id, device_name, mac_address, + bridge, namespace, prefix, mtu, link_up) else: LOG.info("Device %s already exists", device_name) if mtu: @@ -278,22 +277,6 @@ class LinuxInterfaceDriver(object, metaclass=abc.ABCMeta): else: LOG.warning("No MTU configured for port %s", port_id) - def _safe_plug_new(self, network_id, port_id, device_name, mac_address, - bridge=None, namespace=None, prefix=None, mtu=None, link_up=True): - try: - self.plug_new( - network_id, port_id, device_name, mac_address, bridge, - namespace, prefix, mtu, link_up) - except TypeError: - LOG.warning("Interface driver's plug_new() method should now " - "accept additional optional parameter 'link_up'. " - "Usage of plug_new() method which takes from 5 to 9 " - "positional arguments is now deprecated and will not " - "be possible in W release.") - self.plug_new( - network_id, port_id, device_name, mac_address, bridge, - namespace, prefix, mtu) - @abc.abstractmethod def unplug(self, device_name, bridge=None, namespace=None, prefix=None): """Unplug the interface.""" diff --git a/neutron/tests/unit/agent/linux/test_interface.py b/neutron/tests/unit/agent/linux/test_interface.py index ed8f3597e64..bd9492f73c7 100644 --- a/neutron/tests/unit/agent/linux/test_interface.py +++ b/neutron/tests/unit/agent/linux/test_interface.py @@ -61,17 +61,6 @@ class FakePort(object): network_id = network.id -class FakeLegacyInterfaceDriver(interface.LinuxInterfaceDriver): - - def plug_new(self, network_id, port_id, device_name, mac_address, - bridge=None, namespace=None, prefix=None, mtu=None): - """This is legacy method which don't accepts link_up argument.""" - pass - - def unplug(self, device_name, bridge=None, namespace=None, prefix=None): - pass - - class TestBase(base.BaseTestCase): def setUp(self): super(TestBase, self).setUp() @@ -685,20 +674,3 @@ class TestBridgeInterfaceDriver(TestBase): self.ip_dev.assert_has_calls([mock.call('tap0', namespace=None), mock.call().link.delete()]) - - -class TestLegacyDriver(TestBase): - - def test_plug(self): - self.device_exists.return_value = False - with mock.patch('neutron.agent.linux.interface.LOG.warning') as log: - driver = FakeLegacyInterfaceDriver(self.conf) - try: - driver.plug( - '01234567-1234-1234-99', 'port-1234', 'tap0', - 'aa:bb:cc:dd:ee:ff') - except TypeError: - self.fail("LinuxInterfaceDriver class can not call properly " - "plug_new method from the legacy drivers that " - "do not accept 'link_up' parameter.") - log.assert_called_once() diff --git a/releasenotes/notes/Remove-deprecated-way-of-calling-interface-driver-plug_new-method-3377ce0b776df6b2.yaml b/releasenotes/notes/Remove-deprecated-way-of-calling-interface-driver-plug_new-method-3377ce0b776df6b2.yaml new file mode 100644 index 00000000000..feea6801744 --- /dev/null +++ b/releasenotes/notes/Remove-deprecated-way-of-calling-interface-driver-plug_new-method-3377ce0b776df6b2.yaml @@ -0,0 +1,9 @@ +--- +other: + - | + Abstract method ``plug_new`` from the + neutron.agent.linux.interface.LinuxInterfaceDriver now has additional + positional argument ``link_up``. Usage of this method without ``link_up`` + is now not possible. + Third-party drivers which inherit from this base class now have to update + the implementation of their ``plug_new`` method.