Browse Source

Merge "Relocate _delete_expired_default_network_segment_ranges"

changes/15/739915/1
Zuul 2 years ago committed by Gerrit Code Review
parent
commit
d7bb009372
  1. 8
      neutron/plugins/ml2/drivers/helpers.py
  2. 13
      neutron/plugins/ml2/drivers/type_tunnel.py
  3. 13
      neutron/plugins/ml2/drivers/type_vlan.py

8
neutron/plugins/ml2/drivers/helpers.py

@ -15,6 +15,7 @@
import functools
from neutron_lib import context
from neutron_lib.db import api as db_api
from neutron_lib import exceptions
from neutron_lib.plugins import constants as plugin_constants
@ -151,3 +152,10 @@ class SegmentTypeDriver(BaseTypeDriver):
return alloc
raise db_exc.RetryRequest(
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)

13
neutron/plugins/ml2/drivers/type_tunnel.py

@ -163,19 +163,6 @@ class _TunnelTypeDriverBase(helpers.SegmentTypeDriver, metaclass=abc.ABCMeta):
range_obj.NetworkSegmentRange(ctx, **res))
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
def _get_network_segment_ranges_from_db(self):
ranges = []

13
neutron/plugins/ml2/drivers/type_vlan.py

@ -77,19 +77,6 @@ class VlanTypeDriver(helpers.SegmentTypeDriver):
range_obj.NetworkSegmentRange(ctx, **res))
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):
try:
self.network_vlan_ranges = plugin_utils.parse_network_vlan_ranges(

Loading…
Cancel
Save