mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 03:31:10 -03:30
update to use time function
This commit is contained in:
@@ -93,7 +93,6 @@ EXAMPLES = '''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
import json
|
||||
import time
|
||||
|
||||
|
||||
def main():
|
||||
@@ -177,27 +176,14 @@ def main():
|
||||
|
||||
if not wait:
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
# Grab our start time to compare against for the timeout
|
||||
start = time.time()
|
||||
|
||||
job_url = result['json']['url']
|
||||
while not result['json']['finished']:
|
||||
# If we are past our time out fail with a message
|
||||
if timeout and timeout < time.time() - start:
|
||||
module.json_output['msg'] = "Monitoring aborted due to timeout"
|
||||
module.fail_json(**module.json_output)
|
||||
|
||||
# Put the process to sleep for our interval
|
||||
time.sleep(interval)
|
||||
|
||||
result = module.get_endpoint(job_url)
|
||||
module.json_output['status'] = result['json']['status']
|
||||
|
||||
# If the job has failed, we want to raise a task failure for that so we get a non-zero response.
|
||||
if result['json']['failed']:
|
||||
module.json_output['msg'] = 'The workflow "{0}" failed'.format(name)
|
||||
module.fail_json(**module.json_output)
|
||||
|
||||
# Invoke wait function
|
||||
module.wait_on_url(
|
||||
object_name=name,
|
||||
object_type='workflow_job',
|
||||
url=result['json']['url'],
|
||||
timeout=timeout, interval=interval
|
||||
)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user