This change introduces PDDF which is described here: https://github.com/Azure/SONiC/pull/536 Most of the platform bring up effort goes in developing the platform device drivers, SONiC platform APIs and validating them. Typically each platform vendor writes their own drivers and platform APIs which is very tailor made to that platform. This involves writing code, building, installing it on the target platform devices and testing. Many of the details of the platform are hard coded into these drivers, from the HW spec. They go through this cycle repetitively till everything works fine, and is validated before upstreaming the code. PDDF aims to make this platform driver and platform APIs development process much simpler by providing a data driven development framework. This is enabled by: JSON descriptor files for platform data Generic data-driven drivers for various devices Generic SONiC platform APIs Vendor specific extensions for customisation and extensibility Signed-off-by: Fuzail Khan <fuzail.khan@broadcom.com>
86 lines
2.4 KiB
Python
Executable File
86 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os.path
|
|
import sys
|
|
sys.path.append('/usr/share/sonic/platform/plugins')
|
|
import pddfparse
|
|
import json
|
|
|
|
class SYSStatusUtil():
|
|
"""Platform-specific SYSStatus class"""
|
|
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"
|
|
node = pddf_obj.get_path(device,"board_info")
|
|
if node is None:
|
|
return False
|
|
try:
|
|
with open(node, 'r') as f:
|
|
status = f.read()
|
|
print "board_info : %s" %status
|
|
except IOError:
|
|
return False
|
|
|
|
def get_cpld_versio(self):
|
|
device = "SYSSTATUS"
|
|
node = pddf_obj.get_path(device,"cpld1_version")
|
|
if node is None:
|
|
return False
|
|
try:
|
|
with open(node, 'r') as f:
|
|
status = f.read()
|
|
print "cpld1_version : %s" %status
|
|
except IOError:
|
|
return False
|
|
|
|
def get_power_module_status(self):
|
|
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
|
|
|
|
|
|
def get_system_reset_status(self):
|
|
device = "SYSSTATUS"
|
|
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
|
|
|
|
|
|
def get_misc_status(self):
|
|
device = "SYSSTATUS"
|
|
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
|
|
|
|
|
|
def dump_sysfs(self):
|
|
return pddf_obj.cli_dump_dsysfs('sys-status')
|