Merge "[ML2] l2-pop MD handle multi create/delete ports"

This commit is contained in:
Jenkins 2014-02-06 19:49:20 +00:00 committed by Gerrit Code Review
commit b2816eb8e2
3 changed files with 17 additions and 11 deletions

View File

@ -17,6 +17,7 @@
# @author: Francois Eleouet, Orange # @author: Francois Eleouet, Orange
# @author: Mathieu Rohon, Orange # @author: Mathieu Rohon, Orange
from neutron.common import constants as const
from neutron.db import agents_db from neutron.db import agents_db
from neutron.db import db_base_plugin_v2 as base_db from neutron.db import db_base_plugin_v2 as base_db
from neutron.db import models_v2 from neutron.db import models_v2
@ -67,11 +68,14 @@ class L2populationDbMixin(base_db.CommonDbMixin):
l2_const.SUPPORTED_AGENT_TYPES)) l2_const.SUPPORTED_AGENT_TYPES))
return query 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): with session.begin(subtransactions=True):
query = session.query(models_v2.Port) query = session.query(models_v2.Port)
query = query.join(ml2_models.PortBinding) query = query.join(ml2_models.PortBinding)
query = query.filter(models_v2.Port.network_id == network_id, query = query.filter(models_v2.Port.network_id == network_id,
models_v2.Port.status ==
const.PORT_STATUS_ACTIVE,
ml2_models.PortBinding.host == agent_host) ml2_models.PortBinding.host == agent_host)
return query.count() return query.count()

View File

@ -143,17 +143,17 @@ class L2populationMechanismDriver(api.MechanismDriver,
network_id = port_context['network_id'] network_id = port_context['network_id']
session = db_api.get_session() session = db_api.get_session()
agent_ports = self.get_agent_network_port_count(session, agent_host, agent_active_ports = self.get_agent_network_active_port_count(
network_id) session, agent_host, network_id)
other_fdb_entries = {network_id: other_fdb_entries = {network_id:
{'segment_id': segment['segmentation_id'], {'segment_id': segment['segmentation_id'],
'network_type': segment['network_type'], 'network_type': segment['network_type'],
'ports': {agent_ip: []}}} '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): 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 # we have to provide it with the whole list of fdb entries
agent_fdb_entries = {network_id: agent_fdb_entries = {network_id:
{'segment_id': segment['segmentation_id'], {'segment_id': segment['segmentation_id'],
@ -203,16 +203,16 @@ class L2populationMechanismDriver(api.MechanismDriver,
network_id = port_context['network_id'] network_id = port_context['network_id']
session = db_api.get_session() session = db_api.get_session()
agent_ports = self.get_agent_network_port_count(session, agent_host, agent_active_ports = self.get_agent_network_active_port_count(
network_id) session, agent_host, network_id)
other_fdb_entries = {network_id: other_fdb_entries = {network_id:
{'segment_id': segment['segmentation_id'], {'segment_id': segment['segmentation_id'],
'network_type': segment['network_type'], 'network_type': segment['network_type'],
'ports': {agent_ip: []}}} 'ports': {agent_ip: []}}}
if agent_ports == 1: if agent_active_ports == 1:
# Agent is removing its last port in this network, # Agent is removing its last activated port in this network,
# other agents needs to be notified to delete their flooding entry. # other agents needs to be notified to delete their flooding entry.
other_fdb_entries[network_id]['ports'][agent_ip].append( other_fdb_entries[network_id]['ports'][agent_ip].append(
const.FLOODING_ENTRY) const.FLOODING_ENTRY)

View File

@ -164,7 +164,8 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
{'fdb_entries': {'fdb_entries':
{p1['network_id']: {p1['network_id']:
{'ports': {'ports':
{'20.0.0.1': [[p1['mac_address'], {'20.0.0.1': [constants.FLOODING_ENTRY,
[p1['mac_address'],
p1_ips[0]]]}, p1_ips[0]]]},
'network_type': 'vxlan', 'network_type': 'vxlan',
'segment_id': 1}}}, 'segment_id': 1}}},
@ -396,7 +397,8 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
{'fdb_entries': {'fdb_entries':
{p1['network_id']: {p1['network_id']:
{'ports': {'ports':
{'20.0.0.1': [[p1['mac_address'], {'20.0.0.1': [constants.FLOODING_ENTRY,
[p1['mac_address'],
p1_ips[0]]]}, p1_ips[0]]]},
'network_type': 'vxlan', 'network_type': 'vxlan',
'segment_id': 1}}}, 'segment_id': 1}}},