@@ -327,6 +327,35 @@ def _absent_interface(self):
327
327
patches = {self : {"spec" : {"desiredState" : {"interfaces" : self .desired_state ["interfaces" ]}}}}
328
328
).update ()
329
329
330
+ def update (self , resource_dict = None ):
331
+ initial_transition_time = self ._get_nncp_configured_last_transition_time ()
332
+ super ().update (resource_dict = resource_dict )
333
+ self ._wait_for_nncp_status_update (initial_transition_time = initial_transition_time )
334
+
335
+ def _get_nncp_configured_last_transition_time (self ):
336
+ for condition in self .instance .status .conditions :
337
+ if (
338
+ condition ["type" ] == NodeNetworkConfigurationPolicy .Conditions .Type .AVAILABLE
339
+ and condition ["status" ] == "True"
340
+ and condition ["reason" ] == NodeNetworkConfigurationPolicy .Conditions .Reason .SUCCESSFULLY_CONFIGURED
341
+ ):
342
+ return condition ["lastTransitionTime" ]
343
+
344
+ @retry (
345
+ wait_timeout = TIMEOUT_1MINUTE ,
346
+ sleep = TIMEOUT_5SEC ,
347
+ )
348
+ def _wait_for_nncp_status_update (self , initial_transition_time ):
349
+ date_format = "%Y-%m-%dT%H:%M:%SZ"
350
+ formatted_initial_transition_time = datetime .strptime (initial_transition_time , date_format )
351
+ if any (
352
+ condition ["type" ] == NodeNetworkConfigurationPolicy .Conditions .Type .AVAILABLE
353
+ and datetime .strptime (condition ["lastTransitionTime" ], date_format ) > formatted_initial_transition_time
354
+ for condition in self .instance .get ("status" , {}).get ("conditions" , [])
355
+ ):
356
+ return True
357
+ return False
358
+
330
359
@property
331
360
def status (self ):
332
361
for condition in self .instance .status .conditions :
@@ -448,34 +477,3 @@ def _get_failed_nnce(self):
448
477
for nnce_cond in nnce .instance .status .conditions :
449
478
if nnce_cond .type == "Failing" and nnce_cond .status == Resource .Condition .Status .TRUE :
450
479
yield nnce
451
-
452
- def _get_nncp_configured_last_transition_time (self ):
453
- for condition in self .instance .status .conditions :
454
- if (
455
- condition ["type" ] == NodeNetworkConfigurationPolicy .Conditions .Type .AVAILABLE
456
- and condition ["status" ] == "True"
457
- and condition ["reason" ] == NodeNetworkConfigurationPolicy .Conditions .Reason .SUCCESSFULLY_CONFIGURED
458
- ):
459
- return condition ["lastTransitionTime" ]
460
-
461
- @retry (
462
- wait_timeout = TIMEOUT_1MINUTE ,
463
- sleep = TIMEOUT_5SEC ,
464
- )
465
- def _wait_for_nncp_with_different_transition_time (self , initial_transition_time ):
466
- date_format = "%Y-%m-%dT%H:%M:%SZ"
467
- formatted_initial_transition_time = datetime .strptime (initial_transition_time , date_format )
468
- for condition in self .instance .get ("status" , {}).get ("conditions" , []):
469
- if (
470
- condition
471
- and condition ["type" ] == NodeNetworkConfigurationPolicy .Conditions .Type .AVAILABLE
472
- and datetime .strptime (condition ["lastTransitionTime" ], date_format )
473
- > formatted_initial_transition_time
474
- ):
475
- return True
476
- return False
477
-
478
- def update (self , resource_dict = None ):
479
- initial_transition_time = self ._get_nncp_configured_last_transition_time ()
480
- super ().update (resource_dict = resource_dict )
481
- self ._wait_for_nncp_with_different_transition_time (initial_transition_time = initial_transition_time )
0 commit comments