ansible: restructure to avoid intermediate imports

pull/79/head
David Wilson 7 years ago
parent 1a119cb08b
commit 8598ff07b3

@ -31,7 +31,7 @@ import os
import ansible
import ansible.plugins
import ansible.plugins.action.normal
import mitogen.ansible.helpers
import ansible_mitogen.helpers
ANSIBLE_BASEDIR = os.path.dirname(ansible.__file__)
@ -57,7 +57,7 @@ class ActionModule(ansible.plugins.action.normal.ActionModule):
#####################################################################
py_module_name = self.get_py_module_name(module_name)
js = self._connection.py_call(mitogen.ansible.helpers.run_module, py_module_name,
js = self._connection.py_call(ansible_mitogen.helpers.run_module, py_module_name,
args=json.loads(json.dumps(module_args)))
#####################################################################

@ -42,12 +42,12 @@ Enable it by:
EOF
"""
import mitogen.master
import mitogen.unix
from mitogen.ansible import helpers
from __future__ import absolute_import
import ansible.errors
import ansible.plugins.connection
import ansible_mitogen.helpers
import mitogen.unix
class Connection(ansible.plugins.connection.ConnectionBase):
@ -78,15 +78,15 @@ class Connection(ansible.plugins.connection.ConnectionBase):
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
if in_data:
raise ansible.errors.AnsibleError("does not support module pipelining")
return self.py_call(helpers.exec_command, cmd, in_data)
return self.py_call(ansible_mitogen.helpers.exec_command, cmd, in_data)
def fetch_file(self, in_path, out_path):
output = self.py_call(helpers.read_path, in_path)
helpers.write_path(out_path, output)
output = self.py_call(ansible_mitogen.helpers.read_path, in_path)
ansible_mitogen.helpers.write_path(out_path, output)
def put_file(self, in_path, out_path):
self.py_call(helpers.write_path, out_path,
helpers.read_path(in_path))
self.py_call(ansible_mitogen.helpers.write_path, out_path,
ansible_mitogen.helpers.read_path(in_path))
def close(self):
self.router.broker.shutdown()

@ -38,8 +38,6 @@ import json
import subprocess
import time
import mitogen
# Prevent accidental import of an Ansible module from hanging on stdin read.
import ansible.module_utils.basic
ansible.module_utils.basic._ANSIBLE_ARGS = '{}'

@ -25,12 +25,14 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import absolute_import
import mitogen
import mitogen.master
import mitogen.service
import mitogen.unix
import mitogen.utils
import mitogen.ansible.action
import ansible_mitogen.action.mitogen
import ansible.errors
import ansible.plugins.strategy.linear
@ -71,7 +73,7 @@ class StrategyModule(ansible.plugins.strategy.linear.StrategyModule):
real_get = action_loader.get
def get(name, *args, **kwargs):
if name == 'normal':
return mitogen.ansible.action.ActionModule(*args, **kwargs)
return ansible_mitogen.action.mitogen.ActionModule(*args, **kwargs)
return real_get(name, *args, **kwargs)
action_loader.get = get

@ -407,7 +407,6 @@ class Importer(object):
def __init__(self, router, context, core_src):
self._context = context
self._present = {'mitogen': [
'mitogen.ansible',
'mitogen.compat',
'mitogen.compat.pkgutil',
'mitogen.fakessh',

@ -35,7 +35,7 @@ setup(
author = 'David Wilson',
license = 'New BSD',
url = 'https://github.com/dw/mitogen/',
packages = ['mitogen'],
packages = ['mitogen', 'ansible_mitogen'],
zip_safe = False,
classifiers = [
'Development Status :: 3 - Alpha',

Loading…
Cancel
Save