proxy_ping_test
This commit is contained in:
@@ -42,7 +42,7 @@ DOCUMENTATION = """
|
||||
description: timeout for libvirt to connect to access the virtual machine
|
||||
required: false
|
||||
type: int
|
||||
default: 5
|
||||
default: 10
|
||||
"""
|
||||
|
||||
import base64
|
||||
@@ -98,7 +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)
|
||||
self._timeout = self.get_option('timeout', 10)
|
||||
|
||||
def _connect(self):
|
||||
''' connect to the virtual machine; nothing to do here '''
|
||||
@@ -122,7 +122,7 @@ class Connection(ConnectionBase):
|
||||
raise AnsibleConnectionFailure(to_native(err))
|
||||
|
||||
request_cap = json.dumps({'execute': 'guest-info'})
|
||||
response_cap = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_cap, 5, 0))
|
||||
response_cap = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_cap, self._timeout, 0))
|
||||
self.capabilities = response_cap['return']['supported_commands']
|
||||
self._display.vvvvv(u"GUEST CAPABILITIES: {0}".format(self.capabilities), host=self._host)
|
||||
missing_caps = []
|
||||
@@ -201,7 +201,9 @@ class Connection(ConnectionBase):
|
||||
result_status = {
|
||||
'return': dict(exited=False),
|
||||
}
|
||||
while not result_status['return']['exited']:
|
||||
i=0
|
||||
while not result_status['return']['exited'] and i < 20:
|
||||
i = i + 1
|
||||
# Wait for 5% of the time already elapsed
|
||||
sleep_time = (time.clock_gettime(time.CLOCK_MONOTONIC) - command_start) * (5 / 100)
|
||||
if sleep_time < 0.0002:
|
||||
@@ -209,7 +211,7 @@ class Connection(ConnectionBase):
|
||||
elif sleep_time > 1:
|
||||
sleep_time = 1
|
||||
time.sleep(sleep_time)
|
||||
result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, 5, 0))
|
||||
result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, self._timeout, 0))
|
||||
if time.clock_gettime(time.CLOCK_MONOTONIC) > max_time:
|
||||
err = 'timeout'
|
||||
self._display.vv(u"ERROR: libvirtError EXEC TO {0}\n{1}".format(self._virt_uri, to_native(err)), host=self._host)
|
||||
@@ -220,7 +222,7 @@ class Connection(ConnectionBase):
|
||||
display.vvv(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, 5, 0))
|
||||
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)
|
||||
|
||||
@@ -263,7 +265,7 @@ class Connection(ConnectionBase):
|
||||
|
||||
display.vvv(u"GA send: {0}".format(request_handle_json), host=self._host)
|
||||
|
||||
result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, 5, 0))
|
||||
result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, self._timeout, 0))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_handle), host=self._host)
|
||||
|
||||
@@ -283,7 +285,7 @@ class Connection(ConnectionBase):
|
||||
|
||||
display.vvvvv(u"GA send: {0}".format(request_write_json), host=self._host)
|
||||
|
||||
result_write = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_write_json, 5, 0))
|
||||
result_write = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_write_json, self._timeout, 0))
|
||||
|
||||
display.vvvvv(u"GA return: {0}".format(result_write), host=self._host)
|
||||
|
||||
@@ -301,7 +303,7 @@ class Connection(ConnectionBase):
|
||||
|
||||
display.vvv(u"GA send: {0}".format(request_close_json), host=self._host)
|
||||
|
||||
result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, 5, 0))
|
||||
result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, self._timeout, 0))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_close), host=self._host)
|
||||
|
||||
@@ -321,7 +323,7 @@ class Connection(ConnectionBase):
|
||||
|
||||
display.vvv(u"GA send: {0}".format(request_handle_json), host=self._host)
|
||||
|
||||
result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, 5, 0))
|
||||
result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, self._timeout, 0))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_handle), host=self._host)
|
||||
|
||||
@@ -338,11 +340,11 @@ class Connection(ConnectionBase):
|
||||
|
||||
with open(to_bytes(out_path, errors='surrogate_or_strict'), 'wb+') as out_file:
|
||||
try:
|
||||
result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, 5, 0))
|
||||
result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, self._timeout, 0))
|
||||
display.vvvvv(u"GA return: {0}".format(result_read), host=self._host)
|
||||
out_file.write(base64.b64decode(result_read['return']['buf-b64']))
|
||||
while not result_read['return']['eof']:
|
||||
result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, 5, 0))
|
||||
result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, self._timeout, 0))
|
||||
display.vvvvv(u"GA return: {0}".format(result_read), host=self._host)
|
||||
out_file.write(base64.b64decode(result_read['return']['buf-b64']))
|
||||
|
||||
@@ -360,7 +362,7 @@ class Connection(ConnectionBase):
|
||||
|
||||
display.vvv(u"GA send: {0}".format(request_close_json), host=self._host)
|
||||
|
||||
result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, 5, 0))
|
||||
result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, self._timeout, 0))
|
||||
|
||||
display.vvv(u"GA return: {0}".format(result_close), host=self._host)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user