[mlnx-fw-upgrade] Add FW reactivation in case 2 FW upgrades were done without reboot (#17092) (#17286)

This commit is contained in:
mssonicbld 2023-11-24 00:55:34 +08:00 committed by GitHub
parent afe382a5f9
commit a32c370b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,7 @@ declare -r VERBOSE_MIN="${VERBOSE_ERROR}"
declare -r EXIT_SUCCESS="0"
declare -r EXIT_FAILURE="1"
declare -r FW_ALREADY_UPDATED_FAILURE="2"
declare -r QUERY_CMD="mlxfwmanager --query"
declare -r LIST_CONTENT_CMD="mlxfwmanager --list-content"
@ -233,6 +234,22 @@ function RunFwUpdateCmd() {
fi
ERROR_CODE="$?"
if [[ "${ERROR_CODE}" == "${FW_ALREADY_UPDATED_FAILURE}" ]]; then
LogInfo "FW reactivation is required. Reactivating and updating FW ..."
local -r _MST_DEVICE="$(GetMstDevice)"
local -r _CMD="flint -d ${_MST_DEVICE} ir"
output=$(eval "${_CMD}")
if [[ "${VERBOSE_LEVEL}" -eq "${VERBOSE_MAX}" ]]; then
output=$(eval "${COMMAND}")
else
output=$(eval "${COMMAND}") >/dev/null 2>&1
fi
fi
ERROR_CODE="$?"
if [[ "${ERROR_CODE}" != "${EXIT_SUCCESS}" ]]; then
failure_msg="${output#*Fail : }"
ExitFailure "FW Update command: ${COMMAND} failed with error: ${failure_msg}"