Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yagami-Jiang committed Aug 3, 2023
1 parent 0a0641a commit 5c04cf4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dev-address> <dev-type> > <path>/new_device' method",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dev-address> <dev-type> > <path>/new_device' method",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5c04cf4

Please sign in to comment.