update to use time function

This commit is contained in:
sean-m-sullivan
2020-08-26 23:30:18 -05:00
parent 243c2cfe15
commit 0c18587851
4 changed files with 61 additions and 63 deletions

View File

@@ -143,6 +143,9 @@ def main():
verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]),
diff_mode=dict(type='bool'),
credential_passwords=dict(type='dict'),
wait=dict(default=False, type='bool'),
interval=dict(default=1.0, type='float'),
timeout=dict(default=None, type='int'),
)
# Create a module for ourselves
@@ -162,6 +165,9 @@ def main():
optional_args['verbosity'] = module.params.get('verbosity')
optional_args['diff_mode'] = module.params.get('diff_mode')
optional_args['credential_passwords'] = module.params.get('credential_passwords')
wait = module.params.get('wait')
interval = module.params.get('interval')
timeout = module.params.get('timeout')
# Create a datastructure to pass into our job launch
post_data = {}
@@ -216,12 +222,26 @@ def main():
if results['status_code'] != 201:
module.fail_json(msg="Failed to launch job, see response for details", **{'response': results})
if not wait:
module.exit_json(**{
'changed': True,
'id': results['json']['id'],
'status': results['json']['status'],
})
# Invoke wait function
results = module.wait_on_url(
object_name=name,
object_type='job',
url=results['json']['url'],
timeout=timeout, interval=interval
)
module.exit_json(**{
'changed': True,
'id': results['json']['id'],
'status': results['json']['status'],
})
if __name__ == '__main__':
main()