mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
ovirt_templates: wait for OK state when importing (#31634)
This commit is contained in:
parent
1c0dd5406b
commit
ee26ecfcfd
2 changed files with 6 additions and 3 deletions
|
@ -746,14 +746,14 @@ class BaseModule(object):
|
||||||
'diff': self._diff,
|
'diff': self._diff,
|
||||||
}
|
}
|
||||||
|
|
||||||
def wait_for_import(self):
|
def wait_for_import(self, condition=lambda e: True):
|
||||||
if self._module.params['wait']:
|
if self._module.params['wait']:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
timeout = self._module.params['timeout']
|
timeout = self._module.params['timeout']
|
||||||
poll_interval = self._module.params['poll_interval']
|
poll_interval = self._module.params['poll_interval']
|
||||||
while time.time() < start + timeout:
|
while time.time() < start + timeout:
|
||||||
entity = self.search_entity()
|
entity = self.search_entity()
|
||||||
if entity:
|
if entity and condition(entity):
|
||||||
return entity
|
return entity
|
||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,10 @@ def main():
|
||||||
) if module.params['cluster'] else None,
|
) if module.params['cluster'] else None,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
template = templates_module.wait_for_import()
|
# Wait for template to appear in system:
|
||||||
|
template = templates_module.wait_for_import(
|
||||||
|
condition=lambda t: t.status == otypes.TemplateStatus.OK
|
||||||
|
)
|
||||||
ret = {
|
ret = {
|
||||||
'changed': True,
|
'changed': True,
|
||||||
'id': template.id,
|
'id': template.id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue