From 46bf3d1bc169c80422e18c1223d9746ffc628a9c Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 10 Sep 2015 10:39:32 -0700 Subject: [PATCH] Remove plugin._basedirs as we now use different data structures to achieve that functionality. --- lib/ansible/plugins/__init__.py | 28 ---------------------- lib/ansible/plugins/strategies/__init__.py | 3 +-- lib/ansible/template/__init__.py | 2 +- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/lib/ansible/plugins/__init__.py b/lib/ansible/plugins/__init__.py index 58c3e276ed0..cc97a89f600 100644 --- a/lib/ansible/plugins/__init__.py +++ b/lib/ansible/plugins/__init__.py @@ -40,18 +40,6 @@ except ImportError: MODULE_CACHE = {} PATH_CACHE = {} PLUGIN_PATH_CACHE = {} -_basedirs = [] - -# FIXME: the _basedirs code may be dead, and no longer needed, as -# we now use add_directory for all plugin types here instead -# of relying on this global variable (which also causes problems -# with forked processes). See the Playbook() and Role() classes -# for how we now ue get_all_plugin_loaders() below. -def push_basedir(basedir): - # avoid pushing the same absolute dir more than once - basedir = to_unicode(os.path.realpath(basedir)) - if basedir not in _basedirs: - _basedirs.insert(0, basedir) def get_all_plugin_loaders(): return [(name, obj) for (name, obj) in inspect.getmembers(sys.modules[__name__]) if isinstance(obj, PluginLoader)] @@ -165,22 +153,6 @@ class PluginLoader: return self._paths ret = self._extra_dirs[:] - for basedir in _basedirs: - fullpath = os.path.realpath(os.path.join(basedir, self.subdir)) - if os.path.isdir(fullpath): - files = glob.glob("%s/*" % fullpath) - - # allow directories to be two levels deep - files2 = glob.glob("%s/*/*" % fullpath) - - if files2 is not None: - files.extend(files2) - - for file in files: - if os.path.isdir(file) and file not in ret: - ret.append(file) - if fullpath not in ret: - ret.append(fullpath) # look in any configured plugin paths, allow one level deep for subcategories if self.config is not None: diff --git a/lib/ansible/plugins/strategies/__init__.py b/lib/ansible/plugins/strategies/__init__.py index f45e2e7d65e..d64700f618c 100644 --- a/lib/ansible/plugins/strategies/__init__.py +++ b/lib/ansible/plugins/strategies/__init__.py @@ -33,7 +33,7 @@ from ansible.playbook.handler import Handler from ansible.playbook.helpers import load_list_of_blocks from ansible.playbook.included_file import IncludedFile from ansible.playbook.role import hash_params -from ansible.plugins import _basedirs, action_loader, connection_loader, filter_loader, lookup_loader, module_loader +from ansible.plugins import action_loader, connection_loader, filter_loader, lookup_loader, module_loader from ansible.template import Templar try: @@ -53,7 +53,6 @@ class SharedPluginLoaderObj: the forked processes over the queue easier ''' def __init__(self): - self.basedirs = _basedirs[:] self.action_loader = action_loader self.connection_loader = connection_loader self.filter_loader = filter_loader diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index 9799c311259..dc74d2cb566 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -31,7 +31,7 @@ from jinja2.runtime import StrictUndefined from ansible import constants as C from ansible.errors import AnsibleError, AnsibleFilterError, AnsibleUndefinedVariable -from ansible.plugins import _basedirs, filter_loader, lookup_loader, test_loader +from ansible.plugins import filter_loader, lookup_loader, test_loader from ansible.template.safe_eval import safe_eval from ansible.template.template import AnsibleJ2Template from ansible.template.vars import AnsibleJ2Vars