able to load collection but the mitogen master proc was unable to serve it

This commit is contained in:
Steven Robertson 2020-05-08 12:56:07 -07:00
parent e99d63f4fc
commit ddc1eebec8
2 changed files with 451 additions and 454 deletions

View File

@ -75,7 +75,14 @@ except ImportError:
LOG = logging.getLogger(__name__)
try:
class ActionModuleMixin(ansible.plugins.action.ActionBase):
BaseActionClass = ansible.plugins.action.ActionBase
except AttributeError:
# collections were added in https://github.com/ansible/ansible/pull/52194/files
# monkeypatching collections since they don't have an actionBase
BaseActionClass = type('DummyActionBase', (object,), {})
class ActionModuleMixin(BaseActionClass):
"""
The Mitogen-patched PluginLoader dynamically mixes this into every action
class that Ansible attempts to load. It exists to override all the
@ -519,8 +526,3 @@ try:
'stdout_lines': stdout_text.splitlines(),
'stderr': stderr,
}
except AttributeError:
# if we're loading collections, there is no ActionBase
# collections are implemented via an import hook
# https://github.com/ansible/ansible/pull/52194/files
pass

View File

@ -138,12 +138,7 @@ def wrap_action_loader__get(name, *args, **kwargs):
klass = ansible_mitogen.loaders.action_loader__get(name, **get_kwargs)
if klass:
try:
bases = (ansible_mitogen.mixins.ActionModuleMixin, klass)
except AttributeError:
# if we're loading a collection, there's no ActionModuleMixin
bases = (klass,)
adorned_klass = type(str(name), bases, {})
if kwargs.get('class_only'):
return adorned_klass