From 942bef4475fa6ce936a75a7240207422ce837479 Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran <52521751+ArunSaravananBalachandran@users.noreply.github.com> Date: Thu, 12 May 2022 21:54:06 +0530 Subject: [PATCH] DellEMC: S6100, Z9332f - Include ONIE version in 'show platform firmware status' (#10493) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why I did it To include ONIE version in show platform firmware status command output in DellEMC S6100 and Z9332f platforms. How I did it Include ‘ONIE’ in the list of components provided by platform APIs in DellEMC S6100 and Z9332f. Unmount ONIE-BOOT if mounted using fast/soft/warm-reboot plugins in DellEMC S6100. --- .../x86_64-dell_s6100_c2538-r0/platform.json | 3 ++ .../platform.json | 3 ++ .../common/onie_version | 28 +++++++++++++++++++ .../debian/platform-modules-s6100.install | 1 + .../debian/platform-modules-z9332f.install | 1 + .../s6100/scripts/fast-reboot_plugin | 7 +++++ .../s6100/sonic_platform/chassis.py | 2 +- .../s6100/sonic_platform/component.py | 9 +++++- .../z9332f/sonic_platform/chassis.py | 2 +- .../z9332f/sonic_platform/component.py | 11 ++++++++ 10 files changed, 64 insertions(+), 3 deletions(-) create mode 100755 platform/broadcom/sonic-platform-modules-dell/common/onie_version diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/platform.json b/device/dell/x86_64-dell_s6100_c2538-r0/platform.json index e9fbeaeff804..819f104aa53a 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/platform.json +++ b/device/dell/x86_64-dell_s6100_c2538-r0/platform.json @@ -18,6 +18,9 @@ }, { "name": "SSD" + }, + { + "name": "ONIE" } ], "fans": [ diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json b/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json index 98a3322bf334..694f3e41d7c4 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json @@ -30,6 +30,9 @@ }, { "name": "PCIe" + }, + { + "name": "ONIE" } ], "fans": [ diff --git a/platform/broadcom/sonic-platform-modules-dell/common/onie_version b/platform/broadcom/sonic-platform-modules-dell/common/onie_version new file mode 100755 index 000000000000..e30a041ba8a5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/common/onie_version @@ -0,0 +1,28 @@ +#!/bin/bash +# script to get the ONIE version from NOS + +ONIEPATH="/mnt/onie-boot" + +# Exit if not superuser +if [[ "$EUID" -ne 0 ]]; then + echo "This command must be run as root" >&2 + exit 1 +fi + +# Mount ONIE partition if not already mounted +if ! grep -qs ${ONIEPATH} /proc/mounts; then + mkdir -p ${ONIEPATH} + mount LABEL=ONIE-BOOT ${ONIEPATH} || ERR=$? + if [[ ${ERR} -ne 0 ]]; then + exit 1 + fi +fi + +# Get ONIE version +onie_version=$(${ONIEPATH}/onie/tools/bin/onie-version | grep "ONIE version") || ERR=$? +if [[ ${ERR} -ne 0 ]]; then + exit 1 +fi + +onie_version=$(echo ${onie_version} | awk '{print $NF}') +echo ${onie_version} diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install index 4770ac7c2caf..22378cf0eb8b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install @@ -37,3 +37,4 @@ s6100/systemd/s6100-platform-startup.service etc/systemd/system s6100/scripts/s6100_serial_getty_monitor etc/monit/conf.d common/fw-updater usr/local/bin common/onie_mode_set usr/local/bin +common/onie_version usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-z9332f.install b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-z9332f.install index d668116c7445..ad25015472da 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-z9332f.install +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-z9332f.install @@ -10,3 +10,4 @@ common/io_rd_wr.py usr/local/bin common/fw-updater usr/local/bin common/onie_mode_set usr/local/bin common/onie_stage_fwpkg usr/local/bin +common/onie_version usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin index 20a5d8cf5ac2..e38184ecff27 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin @@ -1,5 +1,12 @@ #!/bin/bash +ONIE_PATH="/mnt/onie-boot" + +# Unmount ONIE partition if mounted +if grep -qs ${ONIE_PATH} /proc/mounts; then + umount ${ONIE_PATH} +fi + if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then cd /sys/devices/platform/SMF.512/hwmon/* echo 0xcc > mb_poweron_reason diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index 47e63f52a17d..b3d258f32e8f 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -28,7 +28,7 @@ MAX_S6100_FANTRAY = 4 MAX_S6100_PSU = 2 MAX_S6100_THERMAL = 10 -MAX_S6100_COMPONENT = 4 +MAX_S6100_COMPONENT = 5 class Chassis(ChassisBase): diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py index a50028d3cb5a..0c605871b5a2 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py @@ -23,6 +23,7 @@ SSD_VERSION_COMMAND = "ssdutil -v" SSD_UPGRADE_SCHEDULE = "/usr/local/bin/ssd_upgrade_schedule" PCI_VERSION_COMMAND = "lspci -s 0:0.0" +ONIE_VERSION_COMMAND = "/usr/local/bin/onie_version" class Component(ComponentBase): @@ -38,7 +39,8 @@ class Component(ComponentBase): ["FPGA", ("Platform management controller for on-board temperature " "monitoring, in-chassis power, Fan and LED control")], ["CPLD", "Used for managing IO modules, SFP+ modules and system LEDs"], - ["SSD", "Solid State Drive that stores data persistently"] + ["SSD", "Solid State Drive that stores data persistently"], + ["ONIE", "Open Network Install Environment"] ] MODULE_COMPONENT = [ "IOM{}-CPLD", @@ -261,6 +263,11 @@ def get_firmware_version(self): return self._get_cpld_version() elif self.index == 3: #SSD return self._get_ssd_version() + elif self.index == 4: # ONIE + try: + return subprocess.check_output(ONIE_VERSION_COMMAND, text=True).strip() + except (FileNotFoundError, subprocess.CalledProcessError): + return 'NA' def get_available_firmware_version(self, image_path): """ diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py index 451a51f7b611..d59deb8b0a9e 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py @@ -28,7 +28,7 @@ MAX_Z9332F_FAN = 2 MAX_Z9332F_PSU = 2 MAX_Z9332F_THERMAL = 14 -MAX_Z9332F_COMPONENT = 8 # BIOS,FPGA,BMC,BB CPLD,2 Switch CPLDs,SSD and PCIe +MAX_Z9332F_COMPONENT = 9 # BIOS,FPGA,BMC,BB CPLD,2 Switch CPLDs,SSD,PCIe and ONIE media_part_num_list = set([ \ "8T47V","XTY28","MHVPK","GF76J","J6FGD","F1KMV","9DN5J","H4DHD","6MCNV","0WRX0","X7F70","5R2PT","WTRD1","WTRD1","WTRD1","WTRD1","5250G","WTRD1","C5RNH","C5RNH","FTLX8571D3BCL-FC", diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py index 214467f8c35d..24619a481c4b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py @@ -91,6 +91,12 @@ def get_pciephy_version(): return val +def get_onie_version(): + try: + return subprocess.check_output('/usr/local/bin/onie_version', text=True).strip() + except (FileNotFoundError, subprocess.CalledProcessError): + return 'NA' + class Component(ComponentBase): """DellEMC Platform-specific Component class""" @@ -134,6 +140,11 @@ class Component(ComponentBase): ['PCIe', 'ASIC PCIe firmware', get_pciephy_version + ], + + ['ONIE', + 'Open Network Install Environment', + get_onie_version ] ]