@@ -371,6 +371,27 @@ def get_interfaces_to_flap_after_sfp_reset(self, port_index_to_info_dict, duthos
371371 interfaces_to_flap .append (intf )
372372 return interfaces_to_flap
373373
374+ def _shutdown_and_no_shutdown_ports (self , duthost , intf_list ):
375+ intf_to_flap_joined = "," .join (intf_list )
376+ try :
377+ if duthost .is_multi_asic :
378+ for intf in intf_list :
379+ duthost .shutdown_interface (intf )
380+ else :
381+ duthost .shutdown_interface (intf_to_flap_joined )
382+ except Exception as e :
383+ logger .error ("Failed to shutdown interfaces: {}" .format (e ))
384+
385+ shutdown_wait_scale_factor = max (1 , len (intf_list )* 0.01 )
386+ time .sleep (WAIT_TIME_AFTER_INTF_SHUTDOWN * shutdown_wait_scale_factor )
387+ try :
388+ if duthost .is_multi_asic :
389+ for intf in intf_list :
390+ duthost .no_shutdown_interface (intf )
391+ else :
392+ duthost .no_shutdown_interface (intf_to_flap_joined )
393+ except Exception as e :
394+ logger .error ("Failed to startup interfaces: {}" .format (e ))
374395 #
375396 # Functions to test methods inherited from DeviceBase class
376397 #
@@ -740,18 +761,8 @@ def test_reset(self, request, duthosts, enum_rand_one_per_hwsku_hostname, localh
740761 time .sleep (I2C_WAIT_TIME_AFTER_SFP_RESET )
741762 intf_list = self .get_interfaces_to_flap_after_sfp_reset (port_index_to_info_dict , duthost )
742763 if intf_list :
743- intf_to_flap_joined = "," .join (intf_list )
744- logger .info ("Flapping interfaces: {}" .format (intf_to_flap_joined ))
745- try :
746- duthost .shutdown_interface (intf_to_flap_joined )
747- except Exception as e :
748- logger .error ("Failed to shutdown interfaces: {}" .format (e ))
749- shutdown_wait_scale_factor = max (1 , len (intf_list )* 0.01 )
750- time .sleep (WAIT_TIME_AFTER_INTF_SHUTDOWN * shutdown_wait_scale_factor )
751- try :
752- duthost .no_shutdown_interface (intf_to_flap_joined )
753- except Exception as e :
754- logger .error ("Failed to startup interfaces: {}" .format (e ))
764+ logger .info ("Flapping interfaces: {}" .format (intf_list ))
765+ self ._shutdown_and_no_shutdown_ports (duthost , intf_list )
755766 _ , port_up_wait_time = default_port_toggle_wait_time (duthost , len (intf_list ))
756767 if not wait_until (port_up_wait_time , 10 , 0 ,
757768 check_interface_status_of_up_ports , duthost ):
0 commit comments