From c5fda08d4010f91487d1336852ec94b275fdbd8d Mon Sep 17 00:00:00 2001 From: Jan Gutter Date: Tue, 16 Oct 2018 17:27:00 +0200 Subject: [PATCH] Do not call linux_net.delete_net_dev on Windows The current ovs unplug codepath for Windows triggers an OVSDB port delete command, which is applicable, and a linux netdev delete command, which is not. This changes the unplug logic to skip the delete step. Change-Id: Id7f81ae174d354e593d919813bdf7b3b97cbcd8b Closes-Bug: #1798051 Signed-off-by: Jan Gutter --- vif_plug_ovs/ovs.py | 3 ++- vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py | 7 +++++++ vif_plug_ovs/tests/unit/test_plugin.py | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vif_plug_ovs/ovs.py b/vif_plug_ovs/ovs.py index 3d7352fe..bc94b4da 100644 --- a/vif_plug_ovs/ovs.py +++ b/vif_plug_ovs/ovs.py @@ -253,7 +253,8 @@ class OvsPlugin(plugin.PluginBase): def _unplug_vif_windows(self, vif, instance_info): """Remove port from OVS.""" - self.ovsdb.delete_ovs_vif_port(vif.network.bridge, vif.id) + self.ovsdb.delete_ovs_vif_port(vif.network.bridge, vif.id, + delete_netdev=False) def _unplug_vf_passthrough(self, vif, instance_info): """Remove port from OVS.""" diff --git a/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py b/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py index 322f857e..198f1ea5 100644 --- a/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py +++ b/vif_plug_ovs/tests/unit/ovsdb/test_ovsdb_lib.py @@ -131,6 +131,13 @@ class BaseOVSTest(testtools.TestCase): [mock.call('device', bridge='bridge', if_exists=True)]) mock_delete_net_dev.assert_has_calls([mock.call('device')]) + @mock.patch.object(linux_net, 'delete_net_dev') + def test_delete_ovs_vif_port_no_delete_netdev(self, mock_delete_net_dev): + self.br.delete_ovs_vif_port('bridge', 'device', delete_netdev=False) + self.mock_del_port.assert_has_calls( + [mock.call('device', bridge='bridge', if_exists=True)]) + mock_delete_net_dev.assert_not_called() + def test_ensure_ovs_bridge(self): self.br.ensure_ovs_bridge('bridge', constants.OVS_DATAPATH_SYSTEM) self.mock_add_br('bridge', may_exist=True, diff --git a/vif_plug_ovs/tests/unit/test_plugin.py b/vif_plug_ovs/tests/unit/test_plugin.py index 82fb0f6b..70069fc9 100644 --- a/vif_plug_ovs/tests/unit/test_plugin.py +++ b/vif_plug_ovs/tests/unit/test_plugin.py @@ -278,7 +278,8 @@ class PluginTest(testtools.TestCase): mock_sys.platform = constants.PLATFORM_WIN32 plugin = ovs.OvsPlugin.load(constants.PLUGIN_NAME) plugin.unplug(vif, self.instance) - delete_ovs_vif_port.assert_called_once_with('br0', vif.id) + delete_ovs_vif_port.assert_called_once_with('br0', vif.id, + delete_netdev=False) def test_unplug_ovs_windows(self): self._check_unplug_ovs_windows(self.vif_ovs)