mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
cloud: ovirt: Ignore 404 error when getting entity (#20386)
This commit is contained in:
committed by
Ryan Brown
parent
b519ee9bb3
commit
d9d1194c80
@@ -247,6 +247,20 @@ def search_by_name(service, name, **kwargs):
|
||||
return res[0]
|
||||
|
||||
|
||||
def get_entity(service):
|
||||
"""
|
||||
Ignore SDK Error in case of getting an entity from service.
|
||||
"""
|
||||
entity = None
|
||||
try:
|
||||
entity = service.get()
|
||||
except sdk.Error:
|
||||
# We can get here 404, we should ignore it, in case
|
||||
# of removing entity for example.
|
||||
pass
|
||||
return entity
|
||||
|
||||
|
||||
def wait(
|
||||
service,
|
||||
condition,
|
||||
@@ -270,7 +284,7 @@ def wait(
|
||||
start = time.time()
|
||||
while time.time() < start + timeout:
|
||||
# Exit if the condition of entity is valid:
|
||||
entity = service.get()
|
||||
entity = get_entity(service)
|
||||
if condition(entity):
|
||||
return
|
||||
elif fail_condition(entity):
|
||||
|
||||
Reference in New Issue
Block a user