11import logging
22import re
33from tests .common .errors import RunAnsibleModuleFail
4+ from tests .common .helpers .multi_thread_utils import SafeThreadPoolExecutor
45from tests .common .helpers .upgrade_helpers import install_sonic , reboot , check_sonic_version
56
67logger = logging .getLogger (__name__ )
78
89
910def boot_into_base_image (duthost , localhost , base_image , tbinfo ):
11+ target_version = _install_base_image (duthost , base_image , tbinfo )
12+ # Perform a cold reboot
13+ logger .info ("Cold reboot the DUT to make the base image as current" )
14+ # for 6100 devices, sometimes cold downgrade will not work, use soft-reboot here
15+ reboot_type = 'soft' if "s6100" in duthost .facts ["platform" ] else 'cold'
16+ reboot (duthost , localhost , reboot_type = reboot_type , safe_reboot = True )
17+ check_sonic_version (duthost , target_version )
18+
19+
20+ def boot_into_base_image_t2 (duthosts , localhost , base_image , tbinfo ):
21+ target_vers = {}
22+ with SafeThreadPoolExecutor (max_workers = 8 ) as executor :
23+ for duthost in duthosts :
24+ future = executor .submit (_install_base_image , duthost , base_image , tbinfo )
25+ target_vers [duthost ] = future .get () # Should all be the same, but following best practice
26+
27+ # Rebooting the supervisor host will reboot all T2 DUTs
28+ suphost = duthosts .supervisor_nodes [0 ]
29+ reboot (suphost , localhost , reboot_type = 'cold' , safe_reboot = True )
30+
31+ for duthost in duthosts :
32+ check_sonic_version (duthost , target_vers [duthost ])
33+
34+
35+ def _install_base_image (duthost , base_image , tbinfo ):
1036 logger .info ("Installing {}" .format (base_image ))
1137 try :
1238 target_version = install_sonic (duthost , base_image , tbinfo )
@@ -26,12 +52,8 @@ def boot_into_base_image(duthost, localhost, base_image, tbinfo):
2652 if duthost .shell ("ls /host/old_config/minigraph.xml" , module_ignore_errors = True )['rc' ] == 0 :
2753 duthost .shell ("rm -f /host/old_config/config_db.json" )
2854 duthost .shell ("rm -f /host/old_config/golden_config_db.json" )
29- # Perform a cold reboot
30- logger .info ("Cold reboot the DUT to make the base image as current" )
31- # for 6100 devices, sometimes cold downgrade will not work, use soft-reboot here
32- reboot_type = 'soft' if "s6100" in duthost .facts ["platform" ] else 'cold'
33- reboot (duthost , localhost , reboot_type = reboot_type , safe_reboot = True )
34- check_sonic_version (duthost , target_version )
55+
56+ return target_version
3557
3658
3759def cleanup_prev_images (duthost ):
0 commit comments