Skip to content

Commit

Permalink
Merge pull request ansible#14976 from xiaket/devel
Browse files Browse the repository at this point in the history
use __mro__ for plugin loading when we search for its base class.
  • Loading branch information
abadger committed Mar 21, 2016
2 parents 636871c + 38092dc commit 407f8f9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ansible/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,13 @@ def get(self, name, *args, **kwargs):
obj = getattr(self._module_cache[path], self.class_name)
else:
obj = getattr(self._module_cache[path], self.class_name)(*args, **kwargs)
if self.base_class and self.base_class not in [base.__name__ for base in obj.__class__.__bases__]:
return None
if self.base_class:
# The import path is hardcoded and should be the right place,
# so we are not expecting an ImportError.
module = __import__(self.package, fromlist=[self.base_class])
# Check whether this obj has the required base class.
if not issubclass(obj.__class__, getattr(module, self.base_class, None)):
return None

return obj

Expand Down

0 comments on commit 407f8f9

Please sign in to comment.