Improve Subnet create performance
- pass network dict from ml2 plugin to _create_subnet_postcommit - skip ipam subnet fetch for non ipv6 auto-address subnets - don't count subnets (DB request) if subnet has no segment Change-Id: Iaecfda2700c5316cb25a93496d24ece366e40a4a
This commit is contained in:
parent
4882fa34bb
commit
f52280287f
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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…
Reference in New Issue