summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-05-07 12:56:41 +0000
committerGerrit Code Review <review@openstack.org>2021-05-07 12:56:41 +0000
commit0f18d406a4134cf769fdf6f2a004c98cbe409215 (patch)
tree34cadc8ea2ebc9f0fe43ad9da8a5360ef75ba5b5
parentd1fac9e19db8b11aa4044c7775a8103dcaaa555b (diff)
parente50ecfb4d0a037b249f095b24ed1a6267fa8936b (diff)
downloadneutron-15.3.4.tar.gz
Merge "Improve Subnet update performance" into stable/traintrain-em15.3.4
-rw-r--r--neutron/db/db_base_plugin_v2.py4
-rw-r--r--neutron/db/ipam_backend_mixin.py5
-rw-r--r--neutron/db/ipam_pluggable_backend.py6
3 files changed, 8 insertions, 7 deletions
diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py
index ac7010a978..98a7997a20 100644
--- a/neutron/db/db_base_plugin_v2.py
+++ b/neutron/db/db_base_plugin_v2.py
@@ -937,8 +937,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
self, **kwargs)
with db_api.CONTEXT_WRITER.using(context):
- subnet, changes = self.ipam.update_db_subnet(context, id, s,
- db_pools)
+ subnet, changes = self.ipam.update_db_subnet(
+ context, id, s, db_pools, subnet_obj=subnet_obj)
return self._make_subnet_dict(subnet, context=context), orig
@property
diff --git a/neutron/db/ipam_backend_mixin.py b/neutron/db/ipam_backend_mixin.py
index 34c785e6c0..8148f8700b 100644
--- a/neutron/db/ipam_backend_mixin.py
+++ b/neutron/db/ipam_backend_mixin.py
@@ -196,7 +196,8 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
new_type.create()
return updated_types
- def update_db_subnet(self, context, subnet_id, s, oldpools):
+ def update_db_subnet(self, context, subnet_id, s, oldpools,
+ subnet_obj=None):
changes = {}
if "dns_nameservers" in s:
changes['dns_nameservers'] = (
@@ -214,7 +215,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
changes['service_types'] = (
self._update_subnet_service_types(context, subnet_id, s))
- subnet_obj = self._get_subnet_object(context, subnet_id)
+ subnet_obj = subnet_obj or self._get_subnet_object(context, subnet_id)
subnet_obj.update_fields(s)
subnet_obj.update()
return subnet_obj, changes
diff --git a/neutron/db/ipam_pluggable_backend.py b/neutron/db/ipam_pluggable_backend.py
index 6c379a1c74..f1dc7e005d 100644
--- a/neutron/db/ipam_pluggable_backend.py
+++ b/neutron/db/ipam_pluggable_backend.py
@@ -494,8 +494,8 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
self._ipam_deallocate_ips(context, ipam_driver, port,
port['fixed_ips'])
- def update_db_subnet(self, context, id, s, old_pools):
- subnet = obj_subnet.Subnet.get_object(context, id=id)
+ def update_db_subnet(self, context, id, s, old_pools, subnet_obj=None):
+ subnet = subnet_obj or obj_subnet.Subnet.get_object(context, id=id)
old_segment_id = subnet.segment_id if subnet else None
if 'segment_id' in s:
self._validate_segment(
@@ -506,7 +506,7 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
# so create unchanged copy for ipam driver
subnet_copy = copy.deepcopy(s)
subnet, changes = super(IpamPluggableBackend, self).update_db_subnet(
- context, id, s, old_pools)
+ context, id, s, old_pools, subnet_obj=subnet_obj)
ipam_driver = driver.Pool.get_instance(None, context)
# Set old allocation pools if no new pools are provided by user.