|
|
|
@ -26,6 +26,7 @@ import sys
|
|
|
|
|
import glob
|
|
|
|
|
import imp
|
|
|
|
|
from ansible import constants as C
|
|
|
|
|
from ansible.utils import warnings
|
|
|
|
|
from ansible import errors
|
|
|
|
|
|
|
|
|
|
MODULE_CACHE = {}
|
|
|
|
@ -160,15 +161,12 @@ class PluginLoader:
|
|
|
|
|
self._extra_dirs.append(directory)
|
|
|
|
|
self._paths = None
|
|
|
|
|
|
|
|
|
|
def find_plugin(self, name, suffixes=None, transport=''):
|
|
|
|
|
def find_plugin(self, name, suffixes=None):
|
|
|
|
|
''' Find a plugin named name '''
|
|
|
|
|
|
|
|
|
|
if not suffixes:
|
|
|
|
|
if self.class_name:
|
|
|
|
|
suffixes = ['.py']
|
|
|
|
|
else:
|
|
|
|
|
if transport == 'winrm':
|
|
|
|
|
suffixes = ['.ps1', '']
|
|
|
|
|
else:
|
|
|
|
|
suffixes = ['.py', '']
|
|
|
|
|
|
|
|
|
@ -180,10 +178,13 @@ class PluginLoader:
|
|
|
|
|
found = None
|
|
|
|
|
for path in [p for p in self._get_paths() if p not in self._searched_paths]:
|
|
|
|
|
if os.path.isdir(path):
|
|
|
|
|
for potential_file in os.listdir(path):
|
|
|
|
|
try:
|
|
|
|
|
full_paths = (os.path.join(path, f) for f in os.listdir(path))
|
|
|
|
|
except OSError,e:
|
|
|
|
|
warnings("Error accessing plugin paths: %s" % str(e))
|
|
|
|
|
for full_path in (f for f in full_paths if os.path.isfile(f)):
|
|
|
|
|
for suffix in suffixes:
|
|
|
|
|
if potential_file.endswith(suffix):
|
|
|
|
|
full_path = os.path.join(path, potential_file)
|
|
|
|
|
if full_path.endswith(suffix):
|
|
|
|
|
full_name = os.path.basename(full_path)
|
|
|
|
|
break
|
|
|
|
|
else: # Yes, this is a for-else: http://bit.ly/1ElPkyg
|
|
|
|
|