From 5c04cf4e65a7ee94f0bab099585a2e007cb0d751 Mon Sep 17 00:00:00 2001 From: Yagami Jiang Date: Thu, 3 Aug 2023 03:24:25 +0000 Subject: [PATCH] update --- .../pddf/pddf-device.json-bmc | 1 + .../pddf/pddf-device.json-nonebmc | 1 + .../pddf/sonic_platform/helper.py | 18 +++++++++++++----- .../silverstone-v2/scripts/pre_pddf_init.py | 3 +-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-bmc b/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-bmc index bc55accefff4..9bf0a14f4f6c 100644 --- a/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-bmc +++ b/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-bmc @@ -7,6 +7,7 @@ "num_ports": 34, "num_temps": 14, "num_component": 10, + "bmc_present": "True", "pddf_dev_types": { "description":" - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", diff --git a/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-nonebmc b/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-nonebmc index 48ed098cb952..c2dba4e9eee5 100644 --- a/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-nonebmc +++ b/device/celestica/x86_64-cel_silverstone_v2-r0/pddf/pddf-device.json-nonebmc @@ -7,6 +7,7 @@ "num_ports": 34, "num_temps": 6, "num_component": 8, + "bmc_present": "False", "pddf_dev_types": { "description":" - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", diff --git a/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/pddf/sonic_platform/helper.py b/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/pddf/sonic_platform/helper.py index 1f73c8dd1847..9d3d202325a1 100644 --- a/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/pddf/sonic_platform/helper.py +++ b/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/pddf/sonic_platform/helper.py @@ -4,6 +4,7 @@ # @Mail : yajiang@celestica.com # @Author : jiang tao import os +import json import struct import subprocess from sonic_py_common import device_info @@ -144,8 +145,15 @@ def ipmi_set_ss_thres(id, threshold_key, value): except Exception: status = False return status, result - - def get_bmc_status(self): - bmc_present_path = r"/host/bmc_present" - bmc_status = self.read_txt_file(bmc_present_path) - return True if bmc_status == "True" else False + + @staticmethod + def get_bmc_status(): + """ + get bmc present by pddf-device.json + return: True(present), False(absent) + """ + pddf_device_path = '/usr/share/sonic/platform/pddf/pddf-device.json' + with open(pddf_device_path) as f: + json_data = json.load(f) + bmc_present = json_data["PLATFORM"]["bmc_present"] + return True if bmc_present == "True" else False diff --git a/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/scripts/pre_pddf_init.py b/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/scripts/pre_pddf_init.py index 2f96ce4594ff..e4a9be5e579c 100755 --- a/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/scripts/pre_pddf_init.py +++ b/platform/broadcom/sonic-platform-modules-cel/silverstone-v2/scripts/pre_pddf_init.py @@ -61,14 +61,13 @@ def uninstall_lpc_basecpld(self): def get_bmc_status(self): """ - get bmc status and save bmc status to '/usr/local/bin/bmc_present' + get bmc status """ self.install_lpc_basecpld() if os.path.exists(self.bmc_exist_cmd): # "1": "absent", "0": "present" sta, res = self.run_command("cat %s" % self.bmc_exist_cmd) self.bmc_present = True if res == "0" else False - self.run_command("echo '%s' > /host/bmc_present" % self.bmc_present) self.uninstall_lpc_basecpld() def choose_pddf_device_json(self):