Skip to content

Commit d22356e

Browse files
committed
Fix oper status check
1 parent 2cdf0c9 commit d22356e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

scripts/reboot_smartswitch_helper

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ declare -r GNMI_PORT=8080 # Default GNMI port
44
declare -r MODULE_REBOOT_DPU="DPU"
55
declare -r MODULE_REBOOT_SMARTSWITCH="SMARTSWITCH"
66

7+
declare -r EXIT_DPU_DOWN=2
8+
79
# Function to print debug message
810
function log_message() {
911
local message=$1
@@ -170,14 +172,13 @@ function reboot_dpu()
170172
oper_status=$(show chassis modules status "${DPU_NAME^^}" | sed -n '/^ *DPU/ s/.*\s\+\(Online\|Offline\)\s\+.*/\1/p')
171173
if [ $? -ne 0 ]; then
172174
log_message "ERROR: Failed to retrieve DPU status."
173-
return ${EXIT_ERROR}
174-
fi
175-
176-
log_message "INFO: DPU ${DPU_NAME} is in '$oper_status' state before reboot."
177-
oper_status=$(echo "$oper_status" | tr '[:upper:]' '[:lower:]')
178-
if [ "$oper_status" != "online" ]; then
179-
log_message "INFO: ${DPU_NAME} is not online. Current status: $oper_status"
180-
return ${EXIT_ERROR}
175+
else
176+
log_message "INFO: DPU ${DPU_NAME} is in '$oper_status' state before reboot."
177+
oper_status=$(echo "$oper_status" | tr '[:upper:]' '[:lower:]')
178+
if [ "$oper_status" != "online" ]; then
179+
log_message "INFO: ${DPU_NAME} is not online. Current status: $oper_status"
180+
return ${EXIT_DPU_DOWN}
181+
fi
181182
fi
182183

183184
# Send reboot command to DPU

0 commit comments

Comments
 (0)