Switch DB _utils to new engine facade

Switch DB _utils to new engine facade

Partially-Implements blueprint: enginefacade-switch

Change-Id: Idcaa224b3bc4a06126f2e1dc72d331a925d8d7f5
This commit is contained in:
Miguel Lavalle 2019-05-28 18:30:13 -05:00
parent 51dd91df5b
commit c7bf1a4e8d
1 changed files with 2 additions and 1 deletions

View File

@ -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()