From dde91631f617701f75580760f6e8bdfc42170057 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Fri, 3 Feb 2017 07:34:02 -0800 Subject: [PATCH] Use same session object for ml2 dict extend functions This adjusts the ML2 dict extend functions to pass the same session to the drivers that was used to generate the sqlalchemy object that will be passed to them. This will prevent reloading objects in a separate session that can result in a performance hit or reads to an entirely different server than the one that the object was generated from. Partially-Implements blueprint: enginefacade-switch Change-Id: Id2dbb13e8aa5fcb86fab8e815033e57e6f0e98e8 --- neutron/plugins/ml2/plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index f00c147db62..d34a5268455 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -26,6 +26,7 @@ from oslo_serialization import jsonutils from oslo_utils import excutils from oslo_utils import importutils from oslo_utils import uuidutils +import sqlalchemy from sqlalchemy.orm import exc as sa_exc from neutron._i18n import _, _LE, _LI, _LW @@ -592,15 +593,15 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, attributes.SUBNETS, ['_ml2_md_extend_subnet_dict']) def _ml2_md_extend_network_dict(self, result, netdb): - session = db_api.get_reader_session() + session = sqlalchemy.inspect(netdb).session self.extension_manager.extend_network_dict(session, netdb, result) def _ml2_md_extend_port_dict(self, result, portdb): - session = db_api.get_reader_session() + session = sqlalchemy.inspect(portdb).session self.extension_manager.extend_port_dict(session, portdb, result) def _ml2_md_extend_subnet_dict(self, result, subnetdb): - session = db_api.get_reader_session() + session = sqlalchemy.inspect(subnetdb).session self.extension_manager.extend_subnet_dict(session, subnetdb, result) # Note - The following hook methods have "ml2" in their names so