Merge "Relocate _delete_expired_default_network_segment_ranges"

This commit is contained in:
Zuul 2020-07-08 03:30:55 +00:00 committed by Gerrit Code Review
commit d7bb009372
3 changed files with 8 additions and 26 deletions

View File

@ -15,6 +15,7 @@
import functools import functools
from neutron_lib import context
from neutron_lib.db import api as db_api from neutron_lib.db import api as db_api
from neutron_lib import exceptions from neutron_lib import exceptions
from neutron_lib.plugins import constants as plugin_constants from neutron_lib.plugins import constants as plugin_constants
@ -151,3 +152,10 @@ class SegmentTypeDriver(BaseTypeDriver):
return alloc return alloc
raise db_exc.RetryRequest( raise db_exc.RetryRequest(
exceptions.NoNetworkFoundInMaximumAllowedAttempts()) exceptions.NoNetworkFoundInMaximumAllowedAttempts())
@db_api.retry_db_errors
def _delete_expired_default_network_segment_ranges(self):
ctx = context.get_admin_context()
with db_api.CONTEXT_WRITER.using(ctx):
filters = {'default': True, 'network_type': self.get_type()}
ns_range.NetworkSegmentRange.delete_objects(ctx, **filters)

View File

@ -163,19 +163,6 @@ class _TunnelTypeDriverBase(helpers.SegmentTypeDriver, metaclass=abc.ABCMeta):
range_obj.NetworkSegmentRange(ctx, **res)) range_obj.NetworkSegmentRange(ctx, **res))
new_default_range_obj.create() new_default_range_obj.create()
@db_api.retry_db_errors
def _delete_expired_default_network_segment_ranges(self):
ctx = context.get_admin_context()
with db_api.CONTEXT_WRITER.using(ctx):
filters = {
'default': True,
'network_type': self.get_type(),
}
old_default_range_objs = range_obj.NetworkSegmentRange.get_objects(
ctx, **filters)
for obj in old_default_range_objs:
obj.delete()
@db_api.retry_db_errors @db_api.retry_db_errors
def _get_network_segment_ranges_from_db(self): def _get_network_segment_ranges_from_db(self):
ranges = [] ranges = []

View File

@ -77,19 +77,6 @@ class VlanTypeDriver(helpers.SegmentTypeDriver):
range_obj.NetworkSegmentRange(ctx, **res)) range_obj.NetworkSegmentRange(ctx, **res))
new_default_range_obj.create() new_default_range_obj.create()
@db_api.retry_db_errors
def _delete_expired_default_network_segment_ranges(self):
ctx = context.get_admin_context()
with db_api.CONTEXT_WRITER.using(ctx):
filters = {
'default': True,
'network_type': p_const.TYPE_VLAN,
}
old_default_range_objs = range_obj.NetworkSegmentRange.get_objects(
ctx, **filters)
for obj in old_default_range_objs:
obj.delete()
def _parse_network_vlan_ranges(self): def _parse_network_vlan_ranges(self):
try: try:
self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges( self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(