From 3b9ba1d3a78ebe32ea6953a24a4c7cd630b83979 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Wed, 29 Jan 2020 15:02:26 +0100 Subject: [PATCH] Introduce noop interface driver In a Manila deployment using the Generic driver, it is possible that the administrator has deployed manila-share on a machine that already has access to the admin network used by Manila by being on the same VLAN for example. This means that it's not necessary for it to attempt to plug the ports and do all the wiring due to the fact that it's already reachable, therefore this patch introduces a new `interface_driver` which is does nothing in order to avoid plugging/unplugging ports and avoiding the requirement of running neutron-(openvswitch|linuxbridge)-agent on the same node as manila-share. The tests are pretty trivial because there's not much logic, but we at least make sure that we don't call any ip_lib functions which means we're not touching anything in host networking. Change-Id: I2c3d6e4234bf7185b8da3c8e1701069c3a165ffc (cherry picked from commit 6aec28f11f2ae7504d776b932800433263fd82da) --- manila/network/linux/interface.py | 14 ++++++++++++++ manila/tests/network/linux/test_interface.py | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/manila/network/linux/interface.py b/manila/network/linux/interface.py index a4acc2ee04..f254849ccf 100644 --- a/manila/network/linux/interface.py +++ b/manila/network/linux/interface.py @@ -144,6 +144,20 @@ class LinuxInterfaceDriver(object): """Unplug the interface.""" +class NoopInterfaceDriver(LinuxInterfaceDriver): + """Noop driver when manila-share is already connected to admin network""" + + def init_l3(self, device_name, ip_cidrs, namespace=None, clear_cidrs=[]): + pass + + def plug(self, device_name, port_id, mac_address, + bridge=None, namespace=None, prefix=None): + pass + + def unplug(self, device_name, bridge=None, namespace=None, prefix=None): + pass + + class OVSInterfaceDriver(LinuxInterfaceDriver): """Driver for creating an internal interface on an OVS bridge.""" diff --git a/manila/tests/network/linux/test_interface.py b/manila/tests/network/linux/test_interface.py index 867d589a60..9897cd80a1 100644 --- a/manila/tests/network/linux/test_interface.py +++ b/manila/tests/network/linux/test_interface.py @@ -141,6 +141,21 @@ class TestABCDriver(TestBase): self.assertEqual(set(), result) +class TestNoopInterfaceDriver(TestBase): + + def test_init_l3(self): + self.ip.assert_not_called() + self.ip_dev.assert_not_called() + + def test_plug(self): + self.ip.assert_not_called() + self.ip_dev.assert_not_called() + + def test_unplug(self): + self.ip.assert_not_called() + self.ip_dev.assert_not_called() + + class TestOVSInterfaceDriver(TestBase): def test_get_device_name(self):