Merge "Add wait method for the Neutron API"

This commit is contained in:
Zuul 2024-09-09 17:29:06 +00:00 committed by Gerrit Code Review
commit 91666e5937

View File

@ -273,3 +273,20 @@ def retry_on_assert_fail(max_retries,
raise AssertionError(f"Assert failed after {max_retries} retries.")
return inner
return decor
def wait_for_neutron_api(neutron_client, timeout=100):
"""Waits until the Neutron API replies
:param neutron_client: a Neutron client; it could have or not admin
permissions.
:param timeout: maximum time (in seconds) to wait for the Neutron API.
"""
def _list_agents():
try:
neutron_client.list_extensions()
return True
except exceptions.RestClientException:
return False
common_utils.wait_until_true(_list_agents, timeout=timeout, sleep=1)