Skip to content

Commit

Permalink
Fix the handle_smart_switch() function
Browse files Browse the repository at this point in the history
  • Loading branch information
vvolam committed Oct 23, 2024
1 parent ff8068b commit ba4755c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions scripts/reboot
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,6 @@ function handle_smart_switch() {
fi
fi

is_dpu=$(python3 -c "import reboot_helper; reboot_helper.is_dpu()")
if [[ "$is_dpu" == "True" && "$PRE_SHUTDOWN" != "yes" ]]; then
echo "Invalid, '-p' option not specified for a DPU"
exit ${EXIT_ERROR}
elif [[ "$is_dpu" != "True" && "$PRE_SHUTDOWN" == "yes" ]]; then
echo "Invalid '-p' option specified for a non-DPU"
exit ${EXIT_ERROR}
fi

if [[ "$REBOOT_DPU" == "yes" ]]; then
if [[ "$SMART_SWITCH" == "yes" ]]; then
echo "User requested to reboot the device ${DPU_MODULE_NAME}"
Expand All @@ -390,7 +381,21 @@ function handle_smart_switch() {
fi

if [[ "$SMART_SWITCH" == "yes" ]]; then
reboot_all_dpus "$NUM_DPU"
is_dpu=$(python3 -c "import reboot_helper; reboot_helper.is_dpu()")

# Check if system is a DPU and handle -p option accordingly
if [[ "$is_dpu" == "True" && "$PRE_SHUTDOWN" != "yes" ]]; then
echo "Invalid, '-p' option not specified for a DPU"
exit ${EXIT_ERROR}
elif [[ "$is_dpu" != "True" && "$PRE_SHUTDOWN" == "yes" ]]; then
echo "Invalid '-p' option specified for a non-DPU"
exit ${EXIT_ERROR}
fi

# If not a DPU, reboot all DPUs in parallel
if [[ "$is_dpu" != "True" ]]; then
reboot_all_dpus "$NUM_DPU"
fi
fi
}

Expand Down

0 comments on commit ba4755c

Please sign in to comment.