Remove loading drivers outside of their expected namespaces

Direct import of drivers was deprecated in the Liberty release and
planned for removal during Newton.

In other words, identity drivers must be imported from the
`keystone.identity` namespace, assignment drivers from the
`keystone.assignment` namespace, etc.

Also this catches a more specific exception from stevedore
rather than just RuntimeError.

blueprint removed-as-of-pike

Change-Id: If5e581b249700d8e4683ecfab15ba86da85f1052
This commit is contained in:
Kristi Nikolla 2017-05-18 12:12:32 -04:00
parent ab2928f2cd
commit 711855cd9e
3 changed files with 11 additions and 17 deletions

View File

@ -18,8 +18,6 @@ import time
import types import types
from oslo_log import log from oslo_log import log
from oslo_log import versionutils
from oslo_utils import importutils
import six import six
import stevedore import stevedore
@ -72,20 +70,9 @@ def load_driver(namespace, driver_name, *args):
invoke_on_load=True, invoke_on_load=True,
invoke_args=args) invoke_args=args)
return driver_manager.driver return driver_manager.driver
except RuntimeError as e: except stevedore.exception.NoMatches:
LOG.debug('Failed to load %r using stevedore: %s', driver_name, e) msg = (_('Unable to find %(name)r driver in %(namespace)r.'))
# Ignore failure and continue on. raise ImportError(msg, {'name': driver_name, 'namespace': namespace})
driver = importutils.import_object(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 _TraceMeta(type): class _TraceMeta(type):

View File

@ -762,7 +762,7 @@ class TestTokenProvider(unit.TestCase):
def test_unsupported_token_provider(self): def test_unsupported_token_provider(self):
self.config_fixture.config(group='token', self.config_fixture.config(group='token',
provider='my.package.MyProvider') provider='MyProvider')
self.assertRaises(ImportError, self.assertRaises(ImportError,
token.provider.Manager) token.provider.Manager)

View File

@ -36,3 +36,10 @@ other:
The ``keystone-manage pki_setup`` was added to aid developer setup by hiding the sometimes cryptic The ``keystone-manage pki_setup`` was added to aid developer setup by hiding the sometimes cryptic
openssl commands. This is no longer needed since keystone no longer supports PKI tokens and can no openssl commands. This is no longer needed since keystone no longer supports PKI tokens and can no
longer serve SSL. This was deprecated in the Mitaka release. longer serve SSL. This was deprecated in the Mitaka release.
- >
[`blueprint removed-as-of-pike <https://blueprints.launchpad.net/keystone/+spec/removed-as-of-pike>`_]
Direct import of drivers outside of their `keystone` namespace has been
removed. Ex. identity drivers are loaded from the `keystone.identity`
namespace and assignment drivers from the `keystone.assignment` namespace.
Loading drivers outside of their keystone namespaces was deprecated in the
Liberty release.