More useful message when using direct driver import
In the Liberty release, we switched to using entrypoints for specifying the driver or auth plugin. The deprecation message didn't mention the driver name that was specified, nor did it mention where to look for the expected names, so it was not user friendly. Closes-Bug: 1513102 Change-Id: I02e265684b26686523da9d648b37675feb052978
This commit is contained in:
parent
93239e455c
commit
c73907485a
@ -45,8 +45,8 @@ AUTH_PLUGINS_LOADED = False
|
||||
|
||||
def load_auth_method(method):
|
||||
plugin_name = CONF.auth.get(method) or 'default'
|
||||
namespace = 'keystone.auth.%s' % method
|
||||
try:
|
||||
namespace = 'keystone.auth.%s' % method
|
||||
driver_manager = stevedore.DriverManager(namespace, plugin_name,
|
||||
invoke_on_load=True)
|
||||
return driver_manager.driver
|
||||
@ -55,13 +55,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