Skip to content

Commit

Permalink
ovirt_templates: wait for OK state when importing (ansible#31634)
Browse files Browse the repository at this point in the history
  • Loading branch information
machacekondra authored and ryansb committed Nov 2, 2017
1 parent 1c0dd54 commit ee26ecf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/ansible/module_utils/ovirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,14 @@ def action(
'diff': self._diff,
}

def wait_for_import(self):
def wait_for_import(self, condition=lambda e: True):
if self._module.params['wait']:
start = time.time()
timeout = self._module.params['timeout']
poll_interval = self._module.params['poll_interval']
while time.time() < start + timeout:
entity = self.search_entity()
if entity:
if entity and condition(entity):
return entity
time.sleep(poll_interval)

Expand Down
5 changes: 4 additions & 1 deletion lib/ansible/modules/cloud/ovirt/ovirt_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@ def main():
) if module.params['cluster'] else None,
**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 = {
'changed': True,
'id': template.id,
Expand Down

0 comments on commit ee26ecf

Please sign in to comment.