mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
better handling of vmware-vm-shell timeout (#48100)
This commit is contained in:
parent
89bcd3ff1e
commit
2bc915f58a
1 changed files with 11 additions and 6 deletions
|
@ -291,14 +291,13 @@ class VMwareShellManager(PyVmomi):
|
||||||
def process_exists_in_guest(self, vm, pid, creds):
|
def process_exists_in_guest(self, vm, pid, creds):
|
||||||
res = self.pm.ListProcessesInGuest(vm, creds, pids=[pid])
|
res = self.pm.ListProcessesInGuest(vm, creds, pids=[pid])
|
||||||
if not res:
|
if not res:
|
||||||
return False, ''
|
self.module.fail_json(
|
||||||
|
changed=False, msg='ListProcessesInGuest: None (unexpected)')
|
||||||
res = res[0]
|
res = res[0]
|
||||||
if res.exitCode is None:
|
if res.exitCode is None:
|
||||||
return True, ''
|
return True, None
|
||||||
elif res.exitCode >= 0:
|
|
||||||
return False, res
|
|
||||||
else:
|
else:
|
||||||
return True, res
|
return False, res
|
||||||
|
|
||||||
def wait_for_process(self, vm, pid, creds):
|
def wait_for_process(self, vm, pid, creds):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
@ -308,7 +307,13 @@ class VMwareShellManager(PyVmomi):
|
||||||
if not process_status:
|
if not process_status:
|
||||||
return res_data
|
return res_data
|
||||||
elif current_time - start_time >= self.timeout:
|
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:
|
else:
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue