Browse Source

Merge "Improve Subnet create performance"

changes/42/318542/29
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
0fb97c909e
3 changed files with 11 additions and 6 deletions
  1. +7
    -3
      neutron/db/db_base_plugin_v2.py
  2. +2
    -1
      neutron/plugins/ml2/plugin.py
  3. +2
    -2
      neutron/services/segments/plugin.py

+ 7
- 3
neutron/db/db_base_plugin_v2.py View File

@ -16,6 +16,7 @@
import functools
import netaddr
from neutron_lib.api.definitions import external_net as extnet_def
from neutron_lib.api.definitions import ip_allocation as ipalloc_apidef
from neutron_lib.api.definitions import port as port_def
from neutron_lib.api.definitions import portbindings as portbindings_def
@ -739,11 +740,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
@db_api.retry_if_session_inactive()
def _create_subnet_postcommit(self, context, result,
network=None, ipam_subnet=None):
if not network:
# need to get db net obj with full subnet info either if no network
# is passed or if passed network is an external net dict from
# ml2 plugin (with only IDs in 'subnets')
if not network or network.get(extnet_def.EXTERNAL):
network = self._get_network(context,
result['network_id'])
if not ipam_subnet:
ipam_subnet = self.ipam.get_subnet(context, result['id'])
if hasattr(network, 'external') and network.external:
self._update_router_gw_ports(context,
@ -752,6 +754,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
# If this subnet supports auto-addressing, then update any
# internal ports on the network with addresses for this subnet.
if ipv6_utils.is_auto_address_subnet(result):
if not ipam_subnet:
ipam_subnet = self.ipam.get_subnet(context, result['id'])
updated_ports = self.ipam.add_auto_addrs_on_network_ports(
context, result, ipam_subnet)
for port_id in updated_ports:


+ 2
- 1
neutron/plugins/ml2/plugin.py View File

@ -1292,7 +1292,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
def _after_create_subnet(self, context, result, mech_context):
# db base plugin post commit ops
self._create_subnet_postcommit(context, result)
self._create_subnet_postcommit(context, result,
network=mech_context.network.current)
# add network to subnet dict to save a DB call on dhcp notification
result['network'] = mech_context.network.current


+ 2
- 2
neutron/services/segments/plugin.py View File

@ -658,8 +658,8 @@ class SegmentHostRoutes(object):
# If there are other subnets on the network and subnet has segment_id
# ensure host routes for all subnets are updated.
if (self._count_subnets(context, subnet['network_id']) > 1 and
subnet.get('segment_id')):
if (subnet.get('segment_id') and
self._count_subnets(context, subnet['network_id']) > 1):
self._update_routed_network_host_routes(context,
subnet['network_id'])


Loading…
Cancel
Save