ensure inventory plugin loading rel to play (#51177)

Ensure inventory plugin loading rel to play

  fixes #51033

*  clarify paths
* now adding dirs funciton in loader
* better warnings
* each cli should handle adding dirs depending on context
This commit is contained in:
Brian Coca 2019-04-22 19:32:50 -04:00 committed by GitHub
parent 66493e47cf
commit 780ee45819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 196 additions and 2 deletions

View file

@ -51,7 +51,7 @@ def add_all_plugin_dirs(path):
if os.path.isdir(plugin_path):
obj.add_directory(to_text(plugin_path))
else:
display.warning("Ignoring invalid path provided to plugin path: %s is not a directory" % to_native(path))
display.warning("Ignoring invalid path provided to plugin path: '%s' is not a directory" % to_native(path))
def get_shell_plugin(shell_type=None, executable=None):
@ -87,6 +87,13 @@ def get_shell_plugin(shell_type=None, executable=None):
return shell
def add_dirs_to_loader(which_loader, paths):
loader = getattr(sys.modules[__name__], '%s_loader' % which_loader)
for path in paths:
loader.add_directory(path, with_subdir=True)
class PluginLoader:
'''
PluginLoader loads plugins from the configured plugin directories.
@ -435,6 +442,7 @@ class PluginLoader:
# looks like _get_paths() never forces a cache refresh so if we expect
# additional directories to be added later, it is buggy.
for path in (p for p in self._get_paths() if p not in self._searched_paths and os.path.isdir(p)):
display.debug('trying %s' % path)
try:
full_paths = (os.path.join(path, f) for f in os.listdir(path))
except OSError as e: