]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
[ML2] l2-pop MD handle multi create/delete ports
authorÉdouard Thuleau <edouard.thuleau@cloudwatt.com>
Tue, 24 Dec 2013 10:48:46 +0000 (11:48 +0100)
committerÉdouard Thuleau <edouard.thuleau@cloudwatt.com>
Tue, 24 Dec 2013 12:23:12 +0000 (13:23 +0100)
If more than one port is added or removed simultaneously, port db entry
have status BUILD or DOWN and pass to ACTIVE when agent have finish to
configured it.
l2-pop mechanism driver use events port pass to ACTIVE or DOWN to send
fdb entries. In case of port is the first or the last network port on
an agent, the flooding entry need to be add or removed.

This patch fix the method to determine how many ports are active on a
agent by adding filter on status port to be ACTIVE.

Closes-bug: #1263881
Change-Id: I9c1f8bd69dee37bc01a5d42327aa5f737998c5aa

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

index e7bf92d3b9d196478f12752f7a2a7b54566b7016..6490028293a402398e6cee5963f9be4ed9a5c86c 100644 (file)
@@ -17,6 +17,7 @@
 # @author: Francois Eleouet, Orange
 # @author: Mathieu Rohon, Orange
 
+from neutron.common import constants as const
 from neutron.db import agents_db
 from neutron.db import db_base_plugin_v2 as base_db
 from neutron.db import models_v2
@@ -67,11 +68,14 @@ class L2populationDbMixin(base_db.CommonDbMixin):
                                      l2_const.SUPPORTED_AGENT_TYPES))
             return query
 
-    def get_agent_network_port_count(self, session, agent_host, network_id):
+    def get_agent_network_active_port_count(self, session, agent_host,
+                                            network_id):
         with session.begin(subtransactions=True):
             query = session.query(models_v2.Port)
 
             query = query.join(ml2_models.PortBinding)
             query = query.filter(models_v2.Port.network_id == network_id,
+                                 models_v2.Port.status ==
+                                 const.PORT_STATUS_ACTIVE,
                                  ml2_models.PortBinding.host == agent_host)
             return query.count()
index c67f0c453a3d2bd51dd847b0bcae8ffe3453092b..a22df7b40d9626ce097d161b9427856d053d3eb7 100644 (file)
@@ -143,17 +143,17 @@ class L2populationMechanismDriver(api.MechanismDriver,
         network_id = port_context['network_id']
 
         session = db_api.get_session()
-        agent_ports = self.get_agent_network_port_count(session, agent_host,
-                                                        network_id)
+        agent_active_ports = self.get_agent_network_active_port_count(
+            session, agent_host, network_id)
 
         other_fdb_entries = {network_id:
                              {'segment_id': segment['segmentation_id'],
                               'network_type': segment['network_type'],
                               'ports': {agent_ip: []}}}
 
-        if agent_ports == 1 or (
+        if agent_active_ports == 1 or (
                 self.get_agent_uptime(agent) < cfg.CONF.l2pop.agent_boot_time):
-            # First port plugged on current agent in this network,
+            # First port activated on current agent in this network,
             # we have to provide it with the whole list of fdb entries
             agent_fdb_entries = {network_id:
                                  {'segment_id': segment['segmentation_id'],
@@ -203,16 +203,16 @@ class L2populationMechanismDriver(api.MechanismDriver,
         network_id = port_context['network_id']
 
         session = db_api.get_session()
-        agent_ports = self.get_agent_network_port_count(session, agent_host,
-                                                        network_id)
+        agent_active_ports = self.get_agent_network_active_port_count(
+            session, agent_host, network_id)
 
         other_fdb_entries = {network_id:
                              {'segment_id': segment['segmentation_id'],
                               'network_type': segment['network_type'],
                               'ports': {agent_ip: []}}}
 
-        if agent_ports == 1:
-            # Agent is removing its last port in this network,
+        if agent_active_ports == 1:
+            # Agent is removing its last activated port in this network,
             # other agents needs to be notified to delete their flooding entry.
             other_fdb_entries[network_id]['ports'][agent_ip].append(
                 const.FLOODING_ENTRY)
index 44a686e61455375dc99ff3ab4de0ba790454f6ea..c02cd6b2770cd5bcd3a17233ad5f3a046935f6af 100644 (file)
@@ -164,7 +164,8 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
                                 {'fdb_entries':
                                  {p1['network_id']:
                                   {'ports':
-                                   {'20.0.0.1': [[p1['mac_address'],
+                                   {'20.0.0.1': [constants.FLOODING_ENTRY,
+                                                 [p1['mac_address'],
                                                   p1_ips[0]]]},
                                    'network_type': 'vxlan',
                                    'segment_id': 1}}},
@@ -396,7 +397,8 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
                             {'fdb_entries':
                              {p1['network_id']:
                               {'ports':
-                               {'20.0.0.1': [[p1['mac_address'],
+                               {'20.0.0.1': [constants.FLOODING_ENTRY,
+                                             [p1['mac_address'],
                                               p1_ips[0]]]},
                                'network_type': 'vxlan',
                                'segment_id': 1}}},