]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix to not send fdb updates when no port changes
authorSylvain Afchain <sylvain.afchain@enovance.com>
Fri, 18 Oct 2013 23:12:58 +0000 (01:12 +0200)
committerSylvain Afchain <sylvain.afchain@enovance.com>
Fri, 18 Oct 2013 23:34:30 +0000 (01:34 +0200)
Fixes bug: 1241874
Change-Id: Ibba11db0d7972dfba819347f7cb1397e1d34f218

neutron/plugins/ml2/drivers/l2pop/mech_driver.py
neutron/tests/unit/ml2/drivers/test_l2population.py

index a3f54849da08916fe96c7120c272508092ab3bdb..c67f0c453a3d2bd51dd847b0bcae8ffe3453092b 100644 (file)
@@ -94,8 +94,7 @@ class L2populationMechanismDriver(api.MechanismDriver,
 
         if port['status'] == orig['status']:
             self._fixed_ips_changed(context, orig, port)
-
-        if port['status'] == const.PORT_STATUS_ACTIVE:
+        elif port['status'] == const.PORT_STATUS_ACTIVE:
             self._update_port_up(context)
         elif port['status'] == const.PORT_STATUS_DOWN:
             fdb_entries = self._update_port_down(context)
index f32402d65eb1d3e9520dc35afde7efe260879cd6..44a686e61455375dc99ff3ab4de0ba790454f6ea 100644 (file)
@@ -26,6 +26,7 @@ from neutron.db import agents_db
 from neutron.db import api as db_api
 from neutron.extensions import portbindings
 from neutron.extensions import providernet as pnet
+from neutron import manager
 from neutron.openstack.common import timeutils
 from neutron.plugins.ml2 import config as config
 from neutron.plugins.ml2.drivers.l2pop import constants as l2_consts
@@ -83,7 +84,6 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
                                      'ml2')
         super(TestL2PopulationRpcTestCase, self).setUp(PLUGIN_NAME)
         self.addCleanup(config.cfg.CONF.reset)
-        self.port_create_status = 'DOWN'
 
         self.adminContext = context.get_admin_context()
 
@@ -449,6 +449,12 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
                            **host_arg) as port1:
                 p1 = port1['port']
 
+                device = 'tap' + p1['id']
+
+                self.callbacks.update_device_up(self.adminContext,
+                                                agent_id=HOST,
+                                                device=device)
+
                 self.mock_fanout.reset_mock()
 
                 data = {'port': {'fixed_ips': [{'ip_address': '10.0.0.2'},
@@ -515,3 +521,32 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
 
                 self.mock_fanout.assert_any_call(
                     mock.ANY, del_expected, topic=self.fanout_topic)
+
+    def test_no_fdb_updates_without_port_updates(self):
+        self._register_ml2_agents()
+
+        with self.subnet(network=self._network) as subnet:
+            host_arg = {portbindings.HOST_ID: HOST}
+            with self.port(subnet=subnet, cidr='10.0.0.0/24',
+                           arg_list=(portbindings.HOST_ID,),
+                           **host_arg) as port1:
+                p1 = port1['port']
+
+                device = 'tap' + p1['id']
+
+                self.callbacks.update_device_up(self.adminContext,
+                                                agent_id=HOST,
+                                                device=device)
+                p1['status'] = 'ACTIVE'
+                self.mock_fanout.reset_mock()
+
+                fanout = ('neutron.plugins.ml2.drivers.l2pop.rpc.'
+                          'L2populationAgentNotifyAPI._notification_fanout')
+                fanout_patch = mock.patch(fanout)
+                mock_fanout = fanout_patch.start()
+
+                plugin = manager.NeutronManager.get_plugin()
+                plugin.update_port(self.adminContext, p1['id'], port1)
+
+                self.assertFalse(mock_fanout.called)
+                fanout_patch.stop()