]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove second call to get_subnets in delete_subnet
authorSam Betts <sam@code-smash.net>
Fri, 5 Sep 2014 15:16:01 +0000 (16:16 +0100)
committerSam Betts <sam@code-smash.net>
Tue, 9 Sep 2014 08:38:45 +0000 (09:38 +0100)
delete_subnet made calls to both get_subnet and _get_subnet,
get_subnet uses _get_subnet so multiple database requests were being
made, this patch removes the call to get_subnet and directly calls
_make_subnet_dict using the result of _get_subnet

Change-Id: I9982821dbb9447e35a4b6e50bc5ad31cec417ca5
Closes-Bug: 1366056

neutron/plugins/ml2/plugin.py

index 0de4e26d2a9f64ed1ecc54e587f5f3eddc137fc5..86100e02ffb74f41a4dd75f20815410db073c32a 100644 (file)
@@ -708,7 +708,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
             # wait timeout' errors.
             with contextlib.nested(lockutils.lock('db-access'),
                                    session.begin(subtransactions=True)):
-                subnet = self.get_subnet(context, id)
+                record = self._get_subnet(context, id)
+                subnet = self._make_subnet_dict(record, None)
                 # Get ports to auto-deallocate
                 allocated = (session.query(models_v2.IPAllocation).
                              filter_by(subnet_id=id).
@@ -731,7 +732,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                         mech_context)
 
                     LOG.debug(_("Deleting subnet record"))
-                    record = self._get_subnet(context, id)
                     session.delete(record)
 
                     LOG.debug(_("Committing transaction"))