diff --git a/neutron_lib/context.py b/neutron_lib/context.py index 95bfaaa57..922d8e4ee 100644 --- a/neutron_lib/context.py +++ b/neutron_lib/context.py @@ -15,18 +15,15 @@ import collections import copy import datetime +import warnings from oslo_context import context as oslo_context from oslo_db.sqlalchemy import enginefacade -from oslo_log import log as logging from neutron_lib.db import api as db_api from neutron_lib.policy import _engine as policy_engine -LOG = logging.getLogger(__name__) - - class ContextBase(oslo_context.RequestContext): """Security context and request information. @@ -150,9 +147,11 @@ class Context(ContextBaseWithSession): # TODO(akamyshnikova): checking for session attribute won't be needed # when reader and writer will be used if hasattr(super(Context, self), 'session'): - LOG.debug('context.session is used with and without new ' - 'enginefacade. Please update the code to use new ' - 'enginefacede consistently.') + if self._session: + warnings.warn('context.session is used with and without ' + 'new enginefacade. Please update the code to ' + 'use new enginefacede consistently.', + DeprecationWarning) return super(Context, self).session if self._session is None: self._session = db_api.get_writer_session()