add roles/toxcore
This commit is contained in:
parent
c8610f9ded
commit
7e491f4b8c
51 changed files with 1665 additions and 770 deletions
|
@ -39,10 +39,17 @@ DOCUMENTATION = """
|
|||
vars:
|
||||
- name: ansible_libvirt_uri
|
||||
timeout:
|
||||
description: timeout for libvirt to connect to access the virtual machine
|
||||
required: false
|
||||
description: timeout for libvirt to connect to access the VM
|
||||
ini:
|
||||
- section: defaults
|
||||
key: libvirt_timeout
|
||||
env:
|
||||
- name: ANSIBLE_LIBVIRT_TIMEOUT
|
||||
vars:
|
||||
- name: timeout
|
||||
type: int
|
||||
default: 10
|
||||
default: 5
|
||||
required: false
|
||||
"""
|
||||
|
||||
import base64
|
||||
|
@ -64,7 +71,7 @@ from os.path import exists, getsize
|
|||
|
||||
display = Display()
|
||||
|
||||
iMAX_WAIT = 10 # sec.
|
||||
iMAX_WAIT = 15 # sec.
|
||||
|
||||
REQUIRED_CAPABILITIES = [
|
||||
{'enabled': True, 'name': 'guest-exec', 'success-response': True},
|
||||
|
@ -89,6 +96,7 @@ class Connection(ConnectionBase):
|
|||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
||||
self._host = self._play_context.remote_addr
|
||||
self._play_context = play_context
|
||||
|
||||
# Windows operates differently from a POSIX connection/shell plugin,
|
||||
# we need to set various properties to ensure SSH on Windows continues
|
||||
|
@ -98,7 +106,7 @@ class Connection(ConnectionBase):
|
|||
self.always_pipeline_modules = True
|
||||
self.module_implementation_preferences = ('.ps1', '.exe', '')
|
||||
self.allow_executable = False
|
||||
self._timeout = self.get_option('timeout', 10)
|
||||
self._timeout = self.get_option('timeout', iMAX_WAIT)
|
||||
|
||||
def _connect(self):
|
||||
''' connect to the virtual machine; nothing to do here '''
|
||||
|
@ -156,6 +164,15 @@ class Connection(ConnectionBase):
|
|||
cmd_args_list = self._shell._encode_script(cmd, as_list=True, strict_mode=False, preserve_rc=False)
|
||||
|
||||
# TODO(odyssey4me):
|
||||
cmd_list = cmd_args_list[0]
|
||||
if self._play_context.become and \
|
||||
self._play_context.become_user not in ['', 'root']:
|
||||
cmd_args_list = [self._play_context.become_exe, '-u',
|
||||
self._play_context.become_user] + \
|
||||
self._play_context.become_flags.split(' ') + \
|
||||
cmd_args_list
|
||||
# pl = f"cmd_args_list={cmd_args_list} become_flags={self._play_context.become_flags}"
|
||||
# display.vv(u"BECOMME {0} CONNECTION".format(pl), host=self._host)
|
||||
# Implement buffering much like the other connection plugins
|
||||
# Implement 'env' for the environment settings
|
||||
# Implement 'input-data' for whatever it might be useful for
|
||||
|
@ -169,7 +186,7 @@ class Connection(ConnectionBase):
|
|||
}
|
||||
request_exec_json = json.dumps(request_exec)
|
||||
|
||||
display.vvv("GA send: {0}".format(request_exec_json), host=self._host)
|
||||
display.vvvv("GA send: {0}".format(request_exec_json), host=self._host)
|
||||
# sys.stderr.write("GA send: {0}\n".format(request_exec_json))
|
||||
command_start = time.clock_gettime(time.CLOCK_MONOTONIC)
|
||||
# TODO(odyssey4me):
|
||||
|
@ -183,7 +200,7 @@ class Connection(ConnectionBase):
|
|||
self._connected = False
|
||||
raise AnsibleConnectionFailure(to_native(err))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_exec), host=self._host)
|
||||
display.vvvv(u"GA return: {0}".format(result_exec), host=self._host)
|
||||
|
||||
request_status = {
|
||||
'execute': 'guest-exec-status',
|
||||
|
@ -193,11 +210,11 @@ class Connection(ConnectionBase):
|
|||
}
|
||||
request_status_json = json.dumps(request_status)
|
||||
|
||||
display.vvv(u"GA send: {0}".format(request_status_json), host=self._host)
|
||||
display.vvvv(u"GA send: {0}".format(request_status_json), host=self._host)
|
||||
|
||||
# TODO(odyssey4me):
|
||||
# Work out a better way to wait until the command has exited
|
||||
max_time = iMAX_WAIT + time.clock_gettime(time.CLOCK_MONOTONIC)
|
||||
max_time = timeout + time.clock_gettime(time.CLOCK_MONOTONIC)
|
||||
result_status = {
|
||||
'return': dict(exited=False),
|
||||
}
|
||||
|
@ -219,12 +236,12 @@ class Connection(ConnectionBase):
|
|||
self._connected = False
|
||||
raise AnsibleConnectionFailure(to_native(err))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_status), host=self._host)
|
||||
display.vvvv(u"GA return: {0}".format(result_status), host=self._host)
|
||||
|
||||
while not result_status['return']['exited']:
|
||||
result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, self._timeout, 0))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_status), host=self._host)
|
||||
display.vvvv(u"GA return: {0}".format(result_status), host=self._host)
|
||||
|
||||
if result_status['return'].get('out-data'):
|
||||
stdout = base64.b64decode(result_status['return']['out-data'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue