diff --git a/os_vif/__init__.py b/os_vif/__init__.py index 1df65c82..5d0d6208 100644 --- a/os_vif/__init__.py +++ b/os_vif/__init__.py @@ -86,7 +86,7 @@ def plug(vif, instance_info): plugin_name = vif.plugin try: - plugin = _EXT_MANAGER[plugin_name] + plugin = _EXT_MANAGER[plugin_name].obj except KeyError: raise os_vif.exception.NoMatchingPlugin(plugin_name=plugin_name) @@ -119,7 +119,7 @@ def unplug(vif, instance_info): plugin_name = vif.plugin try: - plugin = _EXT_MANAGER[plugin_name] + plugin = _EXT_MANAGER[plugin_name].obj except KeyError: raise os_vif.exception.NoMatchingPlugin(plugin_name=plugin_name) diff --git a/os_vif/tests/test_os_vif.py b/os_vif/tests/test_os_vif.py index ea0caab7..7aee3ccf 100644 --- a/os_vif/tests/test_os_vif.py +++ b/os_vif/tests/test_os_vif.py @@ -11,6 +11,7 @@ # under the License. import mock +from stevedore import extension import os_vif from os_vif import exception @@ -58,7 +59,10 @@ class TestOSVIF(base.TestCase): @mock.patch.object(DemoPlugin, "plug") def test_plug(self, mock_plug): - plg = DemoPlugin() + plg = extension.Extension(name="demo", + entry_point="os-vif", + plugin="DemoPlugin", + obj=DemoPlugin()) with mock.patch('stevedore.extension.ExtensionManager', return_value={'foobar': plg}): os_vif.initialize() @@ -70,7 +74,10 @@ class TestOSVIF(base.TestCase): @mock.patch.object(DemoPlugin, "unplug") def test_unplug(self, mock_unplug): - plg = DemoPlugin() + plg = extension.Extension(name="demo", + entry_point="os-vif", + plugin="DemoPlugin", + obj=DemoPlugin()) with mock.patch('stevedore.extension.ExtensionManager', return_value={'foobar': plg}): os_vif.initialize()