Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mellanox] Enhance mlnx-fw-upgrade.sh #1994

Merged
merged 1 commit into from
Aug 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions platform/mellanox/mlnx-fw-upgrade.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,46 @@ while [[ (${query_retry_count} -lt ${query_retry_count_max}) && ($? -ne "0") ]];
${query_cmd} > /dev/null
done

run_or_fail "${query_cmd}" > /tmp/mlnxfwmanager-query.txt

# get current firmware version and required version
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
fw_current=$(echo $fw_info | cut -f2 -d' ')

if [[ -z ${fw_current} ]]; then
echo "Could not retreive current FW version."
exit 1
fi

if [[ -z ${fw_required} ]]; then
echo "Could not retreive required FW version."
exit 1
fi

if [[ ${fw_current} == ${fw_required} ]]; then
echo "Mellanox firmware is up to date."
else
echo "Mellanox firmware required version is ${fw_required}. Installing compatible version..."
run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y"
fi
function upgrade() {
if [ ! -z "$1" ]; then
fw_file="$1"
if [ ! -f "$fw_file" ]; then
>&2 echo "No such file: $fw_file"
exit 1
fi

run_or_fail "${query_cmd} -i ${fw_file}" > /tmp/mlnxfwmanager-query.txt

# get current firmware version and available version from $fw_file
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
fw_current=$(echo $fw_info | cut -f2 -d' ')
fw_available=$(echo $fw_info | cut -f3 -d' ')

fw_required=$fw_available
else
run_or_fail "${query_cmd}" > /tmp/mlnxfwmanager-query.txt

# get current firmware version and required version
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
fw_current=$(echo $fw_info | cut -f2 -d' ')
fi

if [[ -z ${fw_current} ]]; then
echo "Could not retreive current FW version."
exit 1
fi

if [[ -z ${fw_required} ]]; then
echo "Could not retreive required FW version."
exit 1
fi

if [[ ${fw_current} == ${fw_required} ]]; then
echo "Mellanox firmware is up to date."
else
echo "Mellanox firmware required version is ${fw_required}. Installing compatible version..."
run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y"
fi
}

upgrade "$1"