Merge "Suppress annoying "Could not load" stevedore warnings"

This commit is contained in:
Jenkins 2017-01-13 07:39:28 +00:00 committed by Gerrit Code Review
commit b4a7e05bb7

View File

@ -327,6 +327,24 @@ def replace_file(file_name, data, file_mode=0o644):
file_utils.replace_file(file_name, data, file_mode=file_mode)
class _SilentDriverManager(driver.DriverManager):
"""The lamest of hacks to allow us to pass a kwarg to DriverManager parent.
DriverManager doesn't accept the warn_on_missing_entrypoint param
to pass to its parent on __init__ so we mirror the __init__ here and bypass
the one in DriverManager in order to silence the warnings.
TODO(kevinbenton): remove once Ia6f5f749fc2f73ca6091fa6d58506fddb058902a
is released or we stop supporting loading by class path.
"""
def __init__(self, namespace, name):
p = super(driver.DriverManager, self) # pylint: disable=bad-super-call
p.__init__(
namespace=namespace, names=[name],
on_load_failure_callback=self._default_on_load_failure,
warn_on_missing_entrypoint=False
)
def load_class_by_alias_or_classname(namespace, name):
"""Load class using stevedore alias or the class name
:param namespace: namespace where the alias is defined
@ -340,7 +358,7 @@ def load_class_by_alias_or_classname(namespace, name):
raise ImportError(_("Class not found."))
try:
# Try to resolve class by alias
mgr = driver.DriverManager(namespace, name)
mgr = _SilentDriverManager(namespace, name)
class_to_load = mgr.driver
except RuntimeError:
e1_info = sys.exc_info()