File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2
+
3
+ from typing import Any
4
+
5
+ from timeout_sampler import TimeoutExpiredError , TimeoutSampler
6
+
7
+ from ocp_resources .resource import NamespacedResource
8
+
9
+
10
+ class BGPSessionState (NamespacedResource ):
11
+ """
12
+ BGPSessionState exposes the status of a BGP Session from the FRR instance running on the node.
13
+ """
14
+
15
+ api_group : str = NamespacedResource .ApiGroup .FRRK8S_METALLB_IO
16
+
17
+ def __init__ (
18
+ self ,
19
+ ** kwargs : Any ,
20
+ ) -> None :
21
+ super ().__init__ (** kwargs )
22
+
23
+ # End of generated code
24
+
25
+ def wait_for_session_established (self , timeout : int = 300 , sleep : int = 5 ) -> None :
26
+ """Waits until the BGP session status is 'Established'.
27
+
28
+ Args:
29
+ timeout (int): Maximum time to wait for the BGP session to be established, in seconds.
30
+ sleep (int): Time to wait between status checks, in seconds.
31
+
32
+ Raises:
33
+ TimeoutExpiredError: If the BGP session does not reach 'Established' status within the timeout period.
34
+ """
35
+ bgp_status = None
36
+ try :
37
+ for sample in TimeoutSampler (wait_timeout = timeout , sleep = sleep , func = lambda : self .instance ):
38
+ if sample :
39
+ bgp_status = sample .get ("status" , {}).get ("bgpStatus" )
40
+ if bgp_status == self .Status .ESTABLISHED :
41
+ self .logger .info (f"{ self .kind } { self .name } bgpStatus is now Established" )
42
+ return
43
+ except TimeoutExpiredError :
44
+ self .logger .error (
45
+ f"{ self .kind } { self .name } did not reach bgpStatus=Established within { timeout } s. "
46
+ f"Last bgpStatus: { bgp_status } "
47
+ )
48
+ raise
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class Status:
17
17
IMAGE_PULL_BACK_OFF : str = "ImagePullBackOff"
18
18
ERR_IMAGE_PULL : str = "ErrImagePull"
19
19
ACTIVE : str = "Active"
20
+ ESTABLISHED : str = "Established"
20
21
21
22
class Condition :
22
23
UPGRADEABLE : str = "Upgradeable"
You can’t perform that action at this time.
0 commit comments