1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

better handling of vmware-vm-shell timeout (#48100)

This commit is contained in:
James E. King III 2018-11-12 08:41:46 -05:00 committed by ansibot
parent 89bcd3ff1e
commit 2bc915f58a

View file

@ -291,14 +291,13 @@ class VMwareShellManager(PyVmomi):
def process_exists_in_guest(self, vm, pid, creds):
res = self.pm.ListProcessesInGuest(vm, creds, pids=[pid])
if not res:
return False, ''
self.module.fail_json(
changed=False, msg='ListProcessesInGuest: None (unexpected)')
res = res[0]
if res.exitCode is None:
return True, ''
elif res.exitCode >= 0:
return False, res
return True, None
else:
return True, res
return False, res
def wait_for_process(self, vm, pid, creds):
start_time = time.time()
@ -308,7 +307,13 @@ class VMwareShellManager(PyVmomi):
if not process_status:
return res_data
elif current_time - start_time >= self.timeout:
break
self.module.fail_json(
msg="Timeout waiting for process to complete.",
vm=vm._moId,
pid=pid,
start_time=start_time,
current_time=current_time,
timeout=self.timeout)
else:
time.sleep(5)