From a5d996e381bd342f0204fcd99e8548cf28b20e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89douard=20Thuleau?= Date: Mon, 18 Nov 2013 15:31:25 +0000 Subject: [PATCH] Fix OVS agent reclaims local VLAN If a port disappears on an OVS agent, the port is removed of the lvm vif_ports list. And if it's the last port of the network on this agent, the network local VLAN is reclaim. Change-Id: I07e03107eb86a84eeb8e4d06f27a1d2fbd7cea57 Closes-Bug: #1252284 --- .../openvswitch/agent/ovs_neutron_agent.py | 15 +++++---------- .../unit/openvswitch/test_ovs_neutron_agent.py | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index b093d0a2d3..3e34b7b208 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -972,21 +972,16 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, for device in devices: LOG.info(_("Attachment %s removed"), device) try: - details = self.plugin_rpc.update_device_down(self.context, - device, - self.agent_id, - cfg.CONF.host) + self.plugin_rpc.update_device_down(self.context, + device, + self.agent_id, + cfg.CONF.host) except Exception as e: LOG.debug(_("port_removed failed for %(device)s: %(e)s"), {'device': device, 'e': e}) resync = True continue - if details['exists']: - LOG.info(_("Port %s updated."), device) - # Nothing to do regarding local networking - else: - LOG.debug(_("Device %s not defined on plugin"), device) - self.port_unbound(device) + self.port_unbound(device) return resync def treat_ancillary_devices_removed(self, devices): diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index 874ef2011d..569e6a2a24 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -222,7 +222,7 @@ class TestOvsNeutronAgent(base.BaseTestCase): return_value=details): with mock.patch.object(self.agent, 'port_unbound') as port_unbound: self.assertFalse(self.agent.treat_devices_removed([{}])) - self.assertEqual(port_unbound.called, not port_exists) + self.assertTrue(port_unbound.called) def test_treat_devices_removed_unbinds_port(self): self._mock_treat_devices_removed(True)