Merge "More useful message when using direct driver import"
This commit is contained in:
commit
a2040587c9
@ -44,8 +44,8 @@ AUTH_PLUGINS_LOADED = False
|
||||
|
||||
def load_auth_method(method):
|
||||
plugin_name = CONF.auth.get(method) or 'default'
|
||||
try:
|
||||
namespace = 'keystone.auth.%s' % method
|
||||
try:
|
||||
driver_manager = stevedore.DriverManager(namespace, plugin_name,
|
||||
invoke_on_load=True)
|
||||
return driver_manager.driver
|
||||
@ -54,13 +54,16 @@ def load_auth_method(method):
|
||||
'attempt to load using import_object instead.',
|
||||
method, plugin_name)
|
||||
|
||||
@versionutils.deprecated(as_of=versionutils.deprecated.LIBERTY,
|
||||
in_favor_of='entrypoints',
|
||||
what='direct import of driver')
|
||||
def _load_using_import(plugin_name):
|
||||
return importutils.import_object(plugin_name)
|
||||
driver = importutils.import_object(plugin_name)
|
||||
|
||||
return _load_using_import(plugin_name)
|
||||
msg = (_(
|
||||
'Direct import of auth plugin %(name)r is deprecated as of Liberty in '
|
||||
'favor of its entrypoint from %(namespace)r and may be removed in '
|
||||
'N.') %
|
||||
{'name': plugin_name, 'namespace': namespace})
|
||||
versionutils.report_deprecated_feature(LOG, msg)
|
||||
|
||||
return driver
|
||||
|
||||
|
||||
def load_auth_methods():
|
||||
|
@ -19,6 +19,8 @@ from oslo_log import versionutils
|
||||
from oslo_utils import importutils
|
||||
import stevedore
|
||||
|
||||
from keystone.i18n import _
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@ -70,15 +72,16 @@ def load_driver(namespace, driver_name, *args):
|
||||
LOG.debug('Failed to load %r using stevedore: %s', driver_name, e)
|
||||
# Ignore failure and continue on.
|
||||
|
||||
@versionutils.deprecated(as_of=versionutils.deprecated.LIBERTY,
|
||||
in_favor_of='entrypoints',
|
||||
what='direct import of driver')
|
||||
def _load_using_import(driver_name, *args):
|
||||
return importutils.import_object(driver_name, *args)
|
||||
driver = importutils.import_object(driver_name, *args)
|
||||
|
||||
# For backwards-compatibility, an unregistered class reference can
|
||||
# still be used.
|
||||
return _load_using_import(driver_name, *args)
|
||||
msg = (_(
|
||||
'Direct import of driver %(name)r is deprecated as of Liberty in '
|
||||
'favor of its entrypoint from %(namespace)r and may be removed in '
|
||||
'N.') %
|
||||
{'name': driver_name, 'namespace': namespace})
|
||||
versionutils.report_deprecated_feature(LOG, msg)
|
||||
|
||||
return driver
|
||||
|
||||
|
||||
class Manager(object):
|
||||
|
Loading…
Reference in New Issue
Block a user