From 9b1abb06840da74e241a123d1715774244b02f8a Mon Sep 17 00:00:00 2001 From: Meni Yakove <441263+myakove@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:11:26 +0200 Subject: [PATCH] UDN: add wait_for_network_ready (#2265) * UDN: add wait_for_network_ready * Add missing typing and docstring --- ocp_resources/user_defined_network.py | 16 ++++++++++++++++ ocp_resources/utils/resource_constants.py | 1 + 2 files changed, 17 insertions(+) diff --git a/ocp_resources/user_defined_network.py b/ocp_resources/user_defined_network.py index 7d7f87e934..7951bb51f5 100644 --- a/ocp_resources/user_defined_network.py +++ b/ocp_resources/user_defined_network.py @@ -68,6 +68,22 @@ def to_dict(self) -> None: # End of generated code + def wait_for_network_ready(self, timeout: int = 30) -> None: + """ + Wait for the network to be ready. + + Args: + timeout (int, optional): Maximum time to wait in seconds. Defaults to 30. + + Raises: + TimeoutExpiredError: If the network is not ready within the specified timeout. + """ + self.wait_for_condition( + condition=self.Condition.NETWORK_READY, + status=self.Condition.Status.TRUE, + timeout=timeout, + ) + class Layer2UserDefinedNetwork(UserDefinedNetwork): """ diff --git a/ocp_resources/utils/resource_constants.py b/ocp_resources/utils/resource_constants.py index 8d0351a8e7..5f69a2e1d7 100644 --- a/ocp_resources/utils/resource_constants.py +++ b/ocp_resources/utils/resource_constants.py @@ -27,6 +27,7 @@ class Condition: RECONCILE_COMPLETE: str = "ReconcileComplete" READY: str = "Ready" FAILING: str = "Failing" + NETWORK_READY = "NetworkReady" class Status: TRUE: str = "True"