Fix logic getting access to stevedore loaded plugin instance
The code was directly using the stevedore Extension class instance, instead of accessing its 'obj' attribute to get the actual loaded plugin class. Change-Id: Ib4d9cdf4fe8fe88f13dbc4e81e0742521e6eb645
This commit is contained in:
parent
992b409d9a
commit
7ae8163bc9
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user