Merge "Improve Subnet create performance"
This commit is contained in:
commit
0fb97c909e
|
@ -16,6 +16,7 @@
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
import netaddr
|
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 ip_allocation as ipalloc_apidef
|
||||||
from neutron_lib.api.definitions import port as port_def
|
from neutron_lib.api.definitions import port as port_def
|
||||||
from neutron_lib.api.definitions import portbindings as portbindings_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()
|
@db_api.retry_if_session_inactive()
|
||||||
def _create_subnet_postcommit(self, context, result,
|
def _create_subnet_postcommit(self, context, result,
|
||||||
network=None, ipam_subnet=None):
|
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,
|
network = self._get_network(context,
|
||||||
result['network_id'])
|
result['network_id'])
|
||||||
if not ipam_subnet:
|
|
||||||
ipam_subnet = self.ipam.get_subnet(context, result['id'])
|
|
||||||
|
|
||||||
if hasattr(network, 'external') and network.external:
|
if hasattr(network, 'external') and network.external:
|
||||||
self._update_router_gw_ports(context,
|
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
|
# If this subnet supports auto-addressing, then update any
|
||||||
# internal ports on the network with addresses for this subnet.
|
# internal ports on the network with addresses for this subnet.
|
||||||
if ipv6_utils.is_auto_address_subnet(result):
|
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(
|
updated_ports = self.ipam.add_auto_addrs_on_network_ports(
|
||||||
context, result, ipam_subnet)
|
context, result, ipam_subnet)
|
||||||
for port_id in updated_ports:
|
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):
|
def _after_create_subnet(self, context, result, mech_context):
|
||||||
# db base plugin post commit ops
|
# 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
|
# add network to subnet dict to save a DB call on dhcp notification
|
||||||
result['network'] = mech_context.network.current
|
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
|
# If there are other subnets on the network and subnet has segment_id
|
||||||
# ensure host routes for all subnets are updated.
|
# ensure host routes for all subnets are updated.
|
||||||
|
|
||||||
if (self._count_subnets(context, subnet['network_id']) > 1 and
|
if (subnet.get('segment_id') and
|
||||||
subnet.get('segment_id')):
|
self._count_subnets(context, subnet['network_id']) > 1):
|
||||||
self._update_routed_network_host_routes(context,
|
self._update_routed_network_host_routes(context,
|
||||||
subnet['network_id'])
|
subnet['network_id'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue