2020-11-12 12:22:38 -06:00
|
|
|
import os.path
|
|
|
|
import sys
|
|
|
|
sys.path.append('/usr/share/sonic/platform/plugins')
|
|
|
|
import pddfparse
|
|
|
|
import json
|
|
|
|
|
2020-11-25 12:28:36 -06:00
|
|
|
|
2020-11-12 12:22:38 -06:00
|
|
|
class SYSStatusUtil():
|
|
|
|
"""Platform-specific SYSStatus class"""
|
2020-11-25 12:28:36 -06:00
|
|
|
|
2020-11-12 12:22:38 -06:00
|
|
|
def __init__(self):
|
|
|
|
global pddf_obj
|
|
|
|
global plugin_data
|
|
|
|
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)) + '/../pddf/pd-plugin.json')) as pd:
|
|
|
|
plugin_data = json.load(pd)
|
|
|
|
|
|
|
|
pddf_obj = pddfparse.PddfParse()
|
|
|
|
|
|
|
|
def get_board_info(self):
|
|
|
|
device = "SYSSTATUS"
|
2020-11-25 12:28:36 -06:00
|
|
|
node = pddf_obj.get_path(device, "board_info")
|
2020-11-12 12:22:38 -06:00
|
|
|
if node is None:
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
with open(node, 'r') as f:
|
|
|
|
status = f.read()
|
2020-11-25 12:28:36 -06:00
|
|
|
print("board_info : %s" % status)
|
2020-11-12 12:22:38 -06:00
|
|
|
except IOError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_cpld_versio(self):
|
|
|
|
device = "SYSSTATUS"
|
2020-11-25 12:28:36 -06:00
|
|
|
node = pddf_obj.get_path(device, "cpld1_version")
|
2020-11-12 12:22:38 -06:00
|
|
|
if node is None:
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
with open(node, 'r') as f:
|
|
|
|
status = f.read()
|
2020-11-25 12:28:36 -06:00
|
|
|
print("cpld1_version : %s" % status)
|
2020-11-12 12:22:38 -06:00
|
|
|
except IOError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_power_module_status(self):
|
2020-11-25 12:28:36 -06:00
|
|
|
device = "SYSSTATUS"
|
|
|
|
node = pddf_obj.get_path(device, "power_module_status")
|
|
|
|
if node is None:
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
with open(node, 'r') as f:
|
|
|
|
status = f.read()
|
|
|
|
print("power_module_status : %s" % status)
|
|
|
|
except IOError:
|
|
|
|
return False
|
2020-11-12 12:22:38 -06:00
|
|
|
|
|
|
|
def get_system_reset_status(self):
|
|
|
|
device = "SYSSTATUS"
|
2020-11-25 12:28:36 -06:00
|
|
|
for i in range(1, 8):
|
|
|
|
node = pddf_obj.get_path(device, "system_reset"+str(i))
|
|
|
|
if node is None:
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
with open(node, 'r') as f:
|
|
|
|
status = f.read()
|
|
|
|
print("system_reset%s : %s" % (i, status))
|
|
|
|
except IOError:
|
|
|
|
print("system_reset%s not supported" % i)
|
2020-11-12 12:22:38 -06:00
|
|
|
|
|
|
|
def get_misc_status(self):
|
|
|
|
device = "SYSSTATUS"
|
2020-11-25 12:28:36 -06:00
|
|
|
for i in range(1, 3):
|
|
|
|
node = pddf_obj.get_path(device, "misc"+str(i))
|
|
|
|
if node is None:
|
|
|
|
return False
|
|
|
|
try:
|
|
|
|
with open(node, 'r') as f:
|
|
|
|
status = f.read()
|
|
|
|
print("misc%s : %s" % (i, status))
|
|
|
|
except IOError:
|
|
|
|
print("system_reset%s not supported" % i)
|
2020-11-12 12:22:38 -06:00
|
|
|
|
|
|
|
def dump_sysfs(self):
|
|
|
|
return pddf_obj.cli_dump_dsysfs('sys-status')
|