From c7bf1a4e8d53b3daa23c2dcd1c95759eb2b0eea9 Mon Sep 17 00:00:00 2001 From: Miguel Lavalle Date: Tue, 28 May 2019 18:30:13 -0500 Subject: [PATCH] Switch DB _utils to new engine facade Switch DB _utils to new engine facade Partially-Implements blueprint: enginefacade-switch Change-Id: Idcaa224b3bc4a06126f2e1dc72d331a925d8d7f5 --- neutron/db/_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neutron/db/_utils.py b/neutron/db/_utils.py index 1a5d449cc3a..7d0850b5f10 100644 --- a/neutron/db/_utils.py +++ b/neutron/db/_utils.py @@ -17,6 +17,7 @@ NOTE: This module shall not be used by external projects. It will be moved import contextlib +from neutron_lib.db import api as db_api from neutron_lib.db import utils as db_utils from oslo_log import log as logging from oslo_utils import excutils @@ -54,7 +55,7 @@ def safe_creation(context, create_fn, delete_fn, create_bindings, :param transaction: if true the whole operation will be wrapped in a transaction. if false, no transaction will be used. ''' - cm = (context.session.begin(subtransactions=True) + cm = (db_api.CONTEXT_WRITER.using(context) if transaction else _noop_context_manager()) with cm: obj = create_fn()