Skip to content

Commit 4258287

Browse files
nazariigqiluo-msft
authored andcommitted
Added argument forwarder for platform reboot. (sonic-net#333)
* Added argument forwarder for platform reboot. * Removed code duplication.
1 parent e2b4bd5 commit 4258287

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

scripts/fast-reboot

+13-16
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,19 @@ sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
3838

3939
# Install new FW for mellanox platforms before control plane goes down
4040
# So on boot switch will not spend time to upgrade FW increasing the CP downtime
41-
if [[ "$sonic_asic_type" == "mellanox" ]];
42-
then
43-
CURRENT_SONIC_IMAGE=$(sonic_installer list | grep "Current: " | cut -d ' ' -f 2)
44-
if [[ "${CURRENT_SONIC_IMAGE}" != "${NEXT_SONIC_IMAGE}" ]]; then
45-
echo "Prepare ASIC to fast reboot: install new FW if requiered"
46-
NEXT_IMAGE_FS_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs"
47-
FS_MOUNTPOINT="/tmp/image-${NEXT_SONIC_IMAGE#SONiC-OS-}-fs"
48-
mkdir -p "$FS_MOUNTPOINT"
49-
mount -t squashfs "$NEXT_IMAGE_FS_PATH" "$FS_MOUNTPOINT"
50-
/usr/bin/mlnx-fw-upgrade.sh "$FS_MOUNTPOINT/etc/mlnx/fw-SPC.mfa"
51-
EXIT_CODE=$?
52-
umount "$FS_MOUNTPOINT"
53-
if [[ $EXIT_CODE != 0 ]]; then
54-
echo "Failed to burn FW"
55-
exit 1
56-
fi
41+
if [[ "$sonic_asic_type" == "mellanox" ]]; then
42+
echo "Prepare MLNX ASIC to fast reboot: install new FW if required"
43+
44+
MLNX_EXIT_SUCCESS="0"
45+
MLNX_EXIT_ERROR="1"
46+
47+
MLNX_FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh"
48+
49+
${MLNX_FW_UPGRADE_SCRIPT} --upgrade
50+
MLNX_EXIT_CODE="$?"
51+
if [[ "${MLNX_EXIT_CODE}" != "${MLNX_EXIT_SUCCESS}" ]]; then
52+
echo "Failed to burn MLNX FW: errno=${MLNX_EXIT_CODE}"
53+
exit "${MLNX_EXIT_ERROR}"
5754
fi
5855
fi
5956

scripts/reboot

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /bin/bash
1+
#!/bin/bash
22

33
REBOOT_USER=$(logname)
44
REBOOT_TIME=$(date)
@@ -14,7 +14,6 @@ function stop_sonic_services()
1414
sleep 3
1515
}
1616

17-
1817
# Exit if not superuser
1918
if [[ "$EUID" -ne 0 ]]; then
2019
echo "This command must be run as root" >&2
@@ -33,7 +32,7 @@ sleep 3
3332

3433
if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
3534
echo "Rebooting with platform ${PLATFORM} specific tool ..."
36-
exec ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT}
35+
exec ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} $@
3736
else
3837
# If no platform-specific reboot tool, just run /sbin/reboot
3938
exec /sbin/reboot $@

0 commit comments

Comments
 (0)