issue #106: working/semantically compatible binary support.
This commit is contained in:
parent
23366b4580
commit
df6daaf3c4
|
@ -94,7 +94,7 @@ def run_module(kwargs):
|
|||
runner_name = kwargs.pop('runner_name')
|
||||
klass = getattr(ansible_mitogen.runner, runner_name)
|
||||
impl = klass(**kwargs)
|
||||
return json.dumps(impl.run())
|
||||
return impl.run()
|
||||
|
||||
|
||||
def _async_main(job_id, runner_name, kwargs):
|
||||
|
|
|
@ -315,18 +315,22 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
|
|||
)
|
||||
)
|
||||
|
||||
def _postprocess_response(self, js):
|
||||
def _postprocess_response(self, result):
|
||||
"""
|
||||
Apply fixups mimicking ActionBase._execute_module(); this is copied
|
||||
verbatim from action/__init__.py, the guts of _parse_returned_data are
|
||||
garbage and should be removed or reimplemented once tests exist.
|
||||
|
||||
:param dict result:
|
||||
Dictionary with format::
|
||||
|
||||
{
|
||||
"rc": int,
|
||||
"stdout": "stdout data",
|
||||
"stderr": "stderr data"
|
||||
}
|
||||
"""
|
||||
data = self._parse_returned_data({
|
||||
'rc': 0,
|
||||
'stdout': js,
|
||||
'stdout_lines': [js],
|
||||
'stderr': ''
|
||||
})
|
||||
data = self._parse_returned_data(result)
|
||||
|
||||
# Cutpasted from the base implementation.
|
||||
if 'stdout' in data and 'stdout_lines' not in data:
|
||||
|
|
|
@ -87,6 +87,16 @@ class Runner(object):
|
|||
self._env.revert()
|
||||
|
||||
def _run(self):
|
||||
"""
|
||||
The _run() method is expected to return a dictionary in the form of
|
||||
ActionBase._low_level_execute_command() output, i.e. having::
|
||||
|
||||
{
|
||||
"rc": int,
|
||||
"stdout": "stdout data",
|
||||
"stderr": "stderr data"
|
||||
}
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def run(self):
|
||||
|
@ -224,11 +234,16 @@ class NativeRunner(Runner):
|
|||
# to invoke main explicitly.
|
||||
mod.main()
|
||||
except NativeModuleExit, e:
|
||||
return e.dct
|
||||
return {
|
||||
'rc': 0,
|
||||
'stdout': json.dumps(e.dct),
|
||||
'stderr': '',
|
||||
}
|
||||
|
||||
return {
|
||||
'failed': True,
|
||||
'msg': 'ansible_mitogen: module did not exit normally.'
|
||||
'rc': 1,
|
||||
'stdout': '',
|
||||
'stderr': 'ansible_mitogen: module did not exit normally.',
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,8 +314,9 @@ class BinaryRunner(Runner):
|
|||
)
|
||||
except Exception, e:
|
||||
return {
|
||||
'failed': True,
|
||||
'msg': '%s: %s' % (type(e), e),
|
||||
'rc': 1,
|
||||
'stdout': '',
|
||||
'stderr': '%s: %s' % (type(e), e),
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue