mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
1fa83fa584
commit
637370089a
1 changed files with 12 additions and 4 deletions
|
@ -32,15 +32,19 @@ class AsyncPoller(object):
|
||||||
|
|
||||||
# Get job id and which hosts to poll again in the future
|
# Get job id and which hosts to poll again in the future
|
||||||
jid = None
|
jid = None
|
||||||
|
# True to work with & below
|
||||||
|
skipped = True
|
||||||
for (host, res) in results['contacted'].iteritems():
|
for (host, res) in results['contacted'].iteritems():
|
||||||
if res.get('started', False):
|
if res.get('started', False):
|
||||||
self.hosts_to_poll.append(host)
|
self.hosts_to_poll.append(host)
|
||||||
jid = res.get('ansible_job_id', None)
|
jid = res.get('ansible_job_id', None)
|
||||||
else:
|
else:
|
||||||
|
skipped = skipped & res.get('skipped', False)
|
||||||
self.results['contacted'][host] = res
|
self.results['contacted'][host] = res
|
||||||
for (host, res) in results['dark'].iteritems():
|
for (host, res) in results['dark'].iteritems():
|
||||||
self.results['dark'][host] = res
|
self.results['dark'][host] = res
|
||||||
|
|
||||||
|
if not skipped:
|
||||||
if jid is None:
|
if jid is None:
|
||||||
raise errors.AnsibleError("unexpected error: unable to determine jid")
|
raise errors.AnsibleError("unexpected error: unable to determine jid")
|
||||||
if len(self.hosts_to_poll)==0:
|
if len(self.hosts_to_poll)==0:
|
||||||
|
@ -86,6 +90,10 @@ class AsyncPoller(object):
|
||||||
|
|
||||||
def wait(self, seconds, poll_interval):
|
def wait(self, seconds, poll_interval):
|
||||||
""" Wait a certain time for job completion, check status every poll_interval. """
|
""" Wait a certain time for job completion, check status every poll_interval. """
|
||||||
|
# jid is None when all hosts were skipped
|
||||||
|
if self.jid is None:
|
||||||
|
return self.results
|
||||||
|
|
||||||
clock = seconds - poll_interval
|
clock = seconds - poll_interval
|
||||||
while (clock >= 0 and not self.completed):
|
while (clock >= 0 and not self.completed):
|
||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
|
|
Loading…
Add table
Reference in a new issue