Merge "switch to stevedore for entry points"
This commit is contained in:
commit
42692264f7
|
@ -123,7 +123,7 @@ six==1.10.0
|
||||||
smmap==0.9.0
|
smmap==0.9.0
|
||||||
statsd==3.2.1
|
statsd==3.2.1
|
||||||
stestr==1.0.0
|
stestr==1.0.0
|
||||||
stevedore==1.20.0
|
stevedore==2.0.1
|
||||||
sushy==0.1.0
|
sushy==0.1.0
|
||||||
tempest==17.1.0
|
tempest==17.1.0
|
||||||
tenacity==3.2.1
|
tenacity==3.2.1
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
|
|
||||||
"""Manage access to the clients, including authenticating when needed."""
|
"""Manage access to the clients, including authenticating when needed."""
|
||||||
|
|
||||||
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from osc_lib import clientmanager
|
from osc_lib import clientmanager
|
||||||
from osc_lib import shell
|
from osc_lib import shell
|
||||||
import pkg_resources
|
import stevedore
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -143,17 +144,25 @@ class ClientManager(clientmanager.ClientManager):
|
||||||
def get_plugin_modules(group):
|
def get_plugin_modules(group):
|
||||||
"""Find plugin entry points"""
|
"""Find plugin entry points"""
|
||||||
mod_list = []
|
mod_list = []
|
||||||
for ep in pkg_resources.iter_entry_points(group):
|
mgr = stevedore.ExtensionManager(group)
|
||||||
|
for ep in mgr:
|
||||||
LOG.debug('Found plugin %s', ep.name)
|
LOG.debug('Found plugin %s', ep.name)
|
||||||
|
|
||||||
|
# Different versions of stevedore use different
|
||||||
|
# implementations of EntryPoint from other libraries, which
|
||||||
|
# are not API-compatible.
|
||||||
try:
|
try:
|
||||||
__import__(ep.module_name)
|
module_name = ep.entry_point.module_name
|
||||||
except Exception:
|
except AttributeError:
|
||||||
|
module_name = ep.entry_point.module
|
||||||
|
|
||||||
|
try:
|
||||||
|
module = importlib.import_module(module_name)
|
||||||
|
except Exception as err:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"WARNING: Failed to import plugin %s.\n" % ep.name)
|
"WARNING: Failed to import plugin %s: %s.\n" % (ep.name, err))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
module = sys.modules[ep.module_name]
|
|
||||||
mod_list.append(module)
|
mod_list.append(module)
|
||||||
init_func = getattr(module, 'Initialize', None)
|
init_func = getattr(module, 'Initialize', None)
|
||||||
if init_func:
|
if init_func:
|
||||||
|
@ -164,7 +173,7 @@ def get_plugin_modules(group):
|
||||||
clientmanager.ClientManager,
|
clientmanager.ClientManager,
|
||||||
module.API_NAME,
|
module.API_NAME,
|
||||||
clientmanager.ClientCache(
|
clientmanager.ClientCache(
|
||||||
getattr(sys.modules[ep.module_name], 'make_client', None)
|
getattr(sys.modules[module_name], 'make_client', None)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return mod_list
|
return mod_list
|
||||||
|
|
|
@ -12,3 +12,4 @@ oslo.utils>=3.33.0 # Apache-2.0
|
||||||
python-keystoneclient>=3.22.0 # Apache-2.0
|
python-keystoneclient>=3.22.0 # Apache-2.0
|
||||||
python-novaclient>=15.1.0 # Apache-2.0
|
python-novaclient>=15.1.0 # Apache-2.0
|
||||||
python-cinderclient>=3.3.0 # Apache-2.0
|
python-cinderclient>=3.3.0 # Apache-2.0
|
||||||
|
stevedore>=2.0.1 # Apache-2.0
|
||||||
|
|
|
@ -8,7 +8,6 @@ flake8-import-order>=0.13 # LGPLv3
|
||||||
oslotest>=3.2.0 # Apache-2.0
|
oslotest>=3.2.0 # Apache-2.0
|
||||||
requests>=2.14.2 # Apache-2.0
|
requests>=2.14.2 # Apache-2.0
|
||||||
requests-mock>=1.2.0 # Apache-2.0
|
requests-mock>=1.2.0 # Apache-2.0
|
||||||
stevedore>=1.20.0 # Apache-2.0
|
|
||||||
stestr>=1.0.0 # Apache-2.0
|
stestr>=1.0.0 # Apache-2.0
|
||||||
testtools>=2.2.0 # MIT
|
testtools>=2.2.0 # MIT
|
||||||
tempest>=17.1.0 # Apache-2.0
|
tempest>=17.1.0 # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue