add
This commit is contained in:
parent
e1c072cf16
commit
346682eedb
31 changed files with 12094 additions and 132 deletions
|
@ -38,6 +38,11 @@ DOCUMENTATION = """
|
|||
default: qemu:///system
|
||||
vars:
|
||||
- name: ansible_libvirt_uri
|
||||
timeout:
|
||||
description: timeout for libvirt to connect to access the virtual machine
|
||||
required: false
|
||||
type: int
|
||||
default: 5
|
||||
"""
|
||||
|
||||
import base64
|
||||
|
@ -93,6 +98,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', 5)
|
||||
|
||||
def _connect(self):
|
||||
''' connect to the virtual machine; nothing to do here '''
|
||||
|
@ -130,11 +136,13 @@ class Connection(ConnectionBase):
|
|||
display.vvv(u"ESTABLISH {0} CONNECTION".format(self.transport), host=self._host)
|
||||
self._connected = True
|
||||
|
||||
def exec_command(self, cmd, in_data=None, sudoable=True):
|
||||
def exec_command(self, cmd, in_data=None, sudoable=True, timeout=None):
|
||||
""" execute a command on the virtual machine host """
|
||||
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||
|
||||
self._display.vvv(u"EXEC {0}".format(cmd), host=self._host)
|
||||
if timeout is None:
|
||||
timeout = self._timeout
|
||||
|
||||
cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
|
||||
|
||||
|
@ -166,8 +174,9 @@ class Connection(ConnectionBase):
|
|||
command_start = time.clock_gettime(time.CLOCK_MONOTONIC)
|
||||
# TODO(odyssey4me):
|
||||
# Add timeout parameter
|
||||
flags = 0
|
||||
try:
|
||||
result_exec = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_exec_json, 5, 0))
|
||||
result_exec = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_exec_json, timeout, flags))
|
||||
except libvirt.libvirtError as err:
|
||||
self._display.vv(u"ERROR: libvirtError EXEC TO {0}\n{1}".format(self._virt_uri, to_native(err)), host=self._host)
|
||||
sys.stderr.write(u"ERROR: libvirtError EXEC TO {0}\n{1}\n".format(self._virt_uri, to_native(err)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue