@@ -5,6 +5,8 @@ declare -r EXIT_ERROR=1
5
5
declare -r WATCHDOG_UTIL=" /usr/local/bin/watchdogutil"
6
6
declare -r PRE_REBOOT_HOOK=" pre_reboot_hook"
7
7
8
+ source reboot_smartswitch_helper
9
+
8
10
DEVPATH=" /usr/share/sonic/device"
9
11
PLAT_REBOOT=" platform_reboot"
10
12
PLATFORM_UPDATE_REBOOT_CAUSE=" platform_update_reboot_cause"
@@ -37,10 +39,16 @@ EXIT_NEXT_IMAGE_NOT_EXISTS=4
37
39
EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21
38
40
EXIT_PLATFORM_FW_AU_FAILURE=22
39
41
PLATFORM_FWUTIL_AU_REBOOT_HANDLE=" platform_fw_au_reboot_handle"
42
+ PLATFORM_JSON_FILE=" platform.json"
43
+ PLATFORM_JSON_PATH=" ${DEVPATH} /${PLATFORM} /${PLATFORM_JSON_FILE} "
40
44
REBOOT_SCRIPT_NAME=$( basename $0 )
41
45
REBOOT_TYPE=" ${REBOOT_SCRIPT_NAME} "
42
46
TAG_LATEST=no
43
47
REBOOT_FLAGS=" "
48
+ SMART_SWITCH=" no"
49
+ DPU_MODULE_NAME=" "
50
+ REBOOT_DPU=" no"
51
+ PRE_SHUTDOWN=" no"
44
52
45
53
function debug()
46
54
{
@@ -64,6 +72,9 @@ function stop_pmon_service()
64
72
{
65
73
CONTAINER_STOP_RC=0
66
74
debug " Stopping pmon docker"
75
+ if [[ " ${PRE_SHUTDOWN} " == " yes" ]]; then
76
+ systemctl disable pmon
77
+ fi
67
78
systemctl stop pmon || debug " Ignore stopping pmon error $? "
68
79
docker kill pmon & > /dev/null || CONTAINER_STOP_RC=$?
69
80
if [[ CONTAINER_STOP_RC -ne 0 ]]; then
@@ -128,6 +139,8 @@ function show_help_and_exit()
128
139
echo " "
129
140
echo " Available options:"
130
141
echo " -h, -? : getting this help"
142
+ echo " -d : DPU module name on a smart switch, option is invalid when on DPU"
143
+ echo " -p : Pre-shutdown steps on DPU, invalid on NPU"
131
144
132
145
exit ${EXIT_SUCCESS}
133
146
}
@@ -154,7 +167,7 @@ function reboot_pre_check()
154
167
${DEVPATH} /${PLATFORM} /${PLATFORM_REBOOT_PRE_CHECK}
155
168
[[ $? -ne 0 ]] && exit $?
156
169
fi
157
-
170
+
158
171
# Verify the next image by sonic-installer
159
172
local message=$( sonic-installer verify-next-image 2>&1 )
160
173
if [ $? -ne 0 ]; then
@@ -178,7 +191,7 @@ function check_conflict_boot_in_fw_update()
178
191
179
192
function parse_options()
180
193
{
181
- while getopts " h?vf " opt; do
194
+ while getopts " h?vfpd: " opt; do
182
195
case ${opt} in
183
196
h|\? )
184
197
show_help_and_exit
@@ -192,6 +205,13 @@ function parse_options()
192
205
f )
193
206
REBOOT_FLAGS+=" -f"
194
207
;;
208
+ d )
209
+ REBOOT_DPU=" yes"
210
+ DPU_MODULE_NAME=" $OPTARG "
211
+ ;;
212
+ p )
213
+ PRE_SHUTDOWN=" yes"
214
+ ;;
195
215
esac
196
216
done
197
217
}
225
245
226
246
debug " User requested rebooting device ..."
227
247
248
+ handle_smart_switch " $REBOOT_DPU " " $PRE_SHUTDOWN " " $DPU_MODULE_NAME "
249
+ smart_switch_result=$?
250
+ if [[ $smart_switch_result -ne 0 ]]; then
251
+ exit $smart_switch_result
252
+ fi
253
+
254
+ # On a smartswitch, complete the DPU reboot and exit
255
+ smartswitch=$( is_smartswitch)
256
+ if [ " $smartswitch " == " True" ] && [ " $REBOOT_DPU " == " yes" ]; then
257
+ exit $smart_switch_result
258
+ fi
259
+
228
260
check_conflict_boot_in_fw_update
229
261
230
262
setup_reboot_variables
@@ -287,6 +319,11 @@ if [ -x ${WATCHDOG_UTIL} ]; then
287
319
${WATCHDOG_UTIL} arm
288
320
fi
289
321
322
+ if [[ " ${PRE_SHUTDOWN} " == " yes" ]]; then
323
+ echo " ${DPU_MODULE_NAME} pre-shutdown steps are completed"
324
+ exit ${EXIT_SUCCESS}
325
+ fi
326
+
290
327
if [ -x ${DEVPATH} /${PLATFORM} /${PLAT_REBOOT} ]; then
291
328
VERBOSE=yes debug " Rebooting with platform ${PLATFORM} specific tool ..."
292
329
${DEVPATH} /${PLATFORM} /${PLAT_REBOOT} $@
0 commit comments