Avoid unnecessary db calls with l2pop
When processing ports that are incompatible with l2_population, certain methods do unnecessary db calls to retrieve agent port info from the db. This info is used only if the processed port is of the correct network type. The check is done after the db call, but before the info is used. This commit moves the check earlier in the method. The db will be called only when the port is supposed to be set up with the l2pop. Closes-Bug: #1983558 Change-Id: I5a83bfce60a933af781b1fd96037c7de6b2b1f38
This commit is contained in:
@@ -281,6 +281,10 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
agent_host)
|
||||
return
|
||||
|
||||
segment = context.bottom_bound_segment
|
||||
if not self._validate_segment(segment, port['id'], agent):
|
||||
return
|
||||
|
||||
network_id = port['network_id']
|
||||
|
||||
agent_active_ports = l2pop_db.get_agent_network_active_port_count(
|
||||
@@ -288,9 +292,6 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
LOG.debug("host: %s, agent_active_ports: %s, refresh_tunnels: %s",
|
||||
agent_host, agent_active_ports, refresh_tunnels)
|
||||
agent_ip = l2pop_db.get_agent_ip(agent)
|
||||
segment = context.bottom_bound_segment
|
||||
if not self._validate_segment(segment, port['id'], agent):
|
||||
return
|
||||
other_fdb_entries = self._get_fdb_entries_template(
|
||||
segment, agent_ip, network_id)
|
||||
other_fdb_ports = other_fdb_entries[network_id]['ports']
|
||||
@@ -327,11 +328,6 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
if not agent_host:
|
||||
return
|
||||
|
||||
network_id = port['network_id']
|
||||
|
||||
agent_active_ports = l2pop_db.get_agent_network_active_port_count(
|
||||
context, agent_host, network_id)
|
||||
|
||||
agent = l2pop_db.get_agent_by_host(context,
|
||||
agent_host)
|
||||
if not agent:
|
||||
@@ -341,6 +337,11 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
||||
if not self._validate_segment(segment, port['id'], agent):
|
||||
return
|
||||
|
||||
network_id = port['network_id']
|
||||
|
||||
agent_active_ports = l2pop_db.get_agent_network_active_port_count(
|
||||
context, agent_host, network_id)
|
||||
|
||||
agent_ip = l2pop_db.get_agent_ip(agent)
|
||||
other_fdb_entries = self._get_fdb_entries_template(
|
||||
segment, agent_ip, port['network_id'])
|
||||
|
Reference in New Issue
Block a user