diff --git a/cinder/keymgr/__init__.py b/cinder/keymgr/__init__.py index e7111afd21e..9ebb72f2860 100644 --- a/cinder/keymgr/__init__.py +++ b/cinder/keymgr/__init__.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from castellan import key_manager from castellan import options as castellan_opts from oslo_config import cfg from oslo_log import log as logging -from oslo_utils import importutils LOG = logging.getLogger(__name__) @@ -26,5 +26,4 @@ castellan_opts.set_defaults(CONF) def API(conf=CONF): - cls = importutils.import_class(conf.key_manager.backend) - return cls(conf) + return key_manager.API(conf) diff --git a/cinder/tests/unit/keymgr/test_init.py b/cinder/tests/unit/keymgr/test_init.py index 7f87edb14d7..69f8155196d 100644 --- a/cinder/tests/unit/keymgr/test_init.py +++ b/cinder/tests/unit/keymgr/test_init.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from castellan.key_manager import barbican_key_manager from castellan import options as castellan_opts from oslo_config import cfg @@ -34,6 +35,14 @@ class InitTestCase(test.TestCase): kmgr = keymgr.API(self.config) self.assertEqual(type(kmgr), keymgr.conf_key_mgr.ConfKeyManager) + def test_barbican_backend(self): + self.config.set_override( + 'backend', + 'barbican', + group='key_manager') + kmgr = keymgr.API(self.config) + self.assertEqual(type(kmgr), barbican_key_manager.BarbicanKeyManager) + def test_set_conf_key_manager(self): self.config.set_override( 'backend',