From 42582872ac0285fed53141d9e4b9a1a5652bb132 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 5 Oct 2018 20:36:08 +0300 Subject: [PATCH] Added argument forwarder for platform reboot. (#333) * Added argument forwarder for platform reboot. * Removed code duplication. --- scripts/fast-reboot | 29 +++++++++++++---------------- scripts/reboot | 5 ++--- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/scripts/fast-reboot b/scripts/fast-reboot index db9ae7bb2ee8..8b81ba1519c6 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -38,22 +38,19 @@ sonic_asic_type=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type) # Install new FW for mellanox platforms before control plane goes down # So on boot switch will not spend time to upgrade FW increasing the CP downtime -if [[ "$sonic_asic_type" == "mellanox" ]]; -then - CURRENT_SONIC_IMAGE=$(sonic_installer list | grep "Current: " | cut -d ' ' -f 2) - if [[ "${CURRENT_SONIC_IMAGE}" != "${NEXT_SONIC_IMAGE}" ]]; then - echo "Prepare ASIC to fast reboot: install new FW if requiered" - NEXT_IMAGE_FS_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs" - FS_MOUNTPOINT="/tmp/image-${NEXT_SONIC_IMAGE#SONiC-OS-}-fs" - mkdir -p "$FS_MOUNTPOINT" - mount -t squashfs "$NEXT_IMAGE_FS_PATH" "$FS_MOUNTPOINT" - /usr/bin/mlnx-fw-upgrade.sh "$FS_MOUNTPOINT/etc/mlnx/fw-SPC.mfa" - EXIT_CODE=$? - umount "$FS_MOUNTPOINT" - if [[ $EXIT_CODE != 0 ]]; then - echo "Failed to burn FW" - exit 1 - fi +if [[ "$sonic_asic_type" == "mellanox" ]]; then + echo "Prepare MLNX ASIC to fast reboot: install new FW if required" + + MLNX_EXIT_SUCCESS="0" + MLNX_EXIT_ERROR="1" + + MLNX_FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh" + + ${MLNX_FW_UPGRADE_SCRIPT} --upgrade + MLNX_EXIT_CODE="$?" + if [[ "${MLNX_EXIT_CODE}" != "${MLNX_EXIT_SUCCESS}" ]]; then + echo "Failed to burn MLNX FW: errno=${MLNX_EXIT_CODE}" + exit "${MLNX_EXIT_ERROR}" fi fi diff --git a/scripts/reboot b/scripts/reboot index 0bcab065fcd1..9083aebd4833 100755 --- a/scripts/reboot +++ b/scripts/reboot @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash REBOOT_USER=$(logname) REBOOT_TIME=$(date) @@ -14,7 +14,6 @@ function stop_sonic_services() sleep 3 } - # Exit if not superuser if [[ "$EUID" -ne 0 ]]; then echo "This command must be run as root" >&2 @@ -33,7 +32,7 @@ sleep 3 if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then echo "Rebooting with platform ${PLATFORM} specific tool ..." - exec ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} + exec ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} $@ else # If no platform-specific reboot tool, just run /sbin/reboot exec /sbin/reboot $@