Use names() method of ExtensionManager insted of keys()

There is no keys() method for ExtensionManager.
The names() method [1] must be used.

[1] http://docs.openstack.org/developer/stevedore/managers.html#stevedore.extension.ExtensionManager.names

Change-Id: I4177d076733abe6b855d8fbf1c2633097de1fe84
This commit is contained in:
Sergey Belous 2016-02-19 16:38:23 +03:00
parent 678c34e287
commit c32d2a6e67
2 changed files with 9 additions and 5 deletions

View File

@ -37,7 +37,7 @@ def initialize(reset=False):
if reset or (_EXT_MANAGER is None):
_EXT_MANAGER = extension.ExtensionManager(namespace='os_vif',
invoke_on_load=False)
for plugin_name in _EXT_MANAGER.keys():
for plugin_name in _EXT_MANAGER.names():
cls = _EXT_MANAGER[plugin_name].plugin
obj = cls.load(plugin_name)
_EXT_MANAGER[plugin_name].obj = obj

View File

@ -103,8 +103,10 @@ class TestOSVIF(base.TestCase):
entry_point="os-vif",
plugin=DemoPlugin,
obj=None)
with mock.patch('stevedore.extension.ExtensionManager',
return_value={'foobar': plg}):
with mock.patch('stevedore.extension.ExtensionManager.names',
return_value=['foobar']),\
mock.patch('stevedore.extension.ExtensionManager.__getitem__',
return_value=plg):
os_vif.initialize()
info = objects.instance_info.InstanceInfo()
vif = objects.vif.VIFBridge(id='uniq',
@ -118,8 +120,10 @@ class TestOSVIF(base.TestCase):
entry_point="os-vif",
plugin=DemoPlugin,
obj=None)
with mock.patch('stevedore.extension.ExtensionManager',
return_value={'foobar': plg}):
with mock.patch('stevedore.extension.ExtensionManager.names',
return_value=['foobar']),\
mock.patch('stevedore.extension.ExtensionManager.__getitem__',
return_value=plg):
os_vif.initialize()
info = objects.instance_info.InstanceInfo()
vif = objects.vif.VIFBridge(id='uniq',