ebea937a7a
* Update sonic-platform-modules-accton to lastest Signed-off-by: roylee123 <roy_lee@accton.com> * Install sonic-platform-common package in platform-monitor docker for ledd (#1330) * Install sonic-platform-common package in platform-monitor docker for ledd * Specify Python wheel dependencies in docker-platform-monitor.mk; Remove explicit specifications from Dockerfile.j2 * Add related files for new platfrom as7326_56x. Signed-off-by: roy_lee <roy_lee@accton.com> * Validate sfputil.py and verified. Signed-off-by: roy_lee <roy_lee@accton.com> * Push submodule sonic-platform-modules-accton for as7326-56x validation. Signed-off-by: roy_lee <roy_lee@accton.com>
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
|
|
#############################################################################
|
|
# Accton
|
|
#
|
|
# Module contains an implementation of SONiC PSU Base API and
|
|
# provides the PSUs status which are available in the platform
|
|
#
|
|
#############################################################################
|
|
|
|
import os.path
|
|
|
|
try:
|
|
from sonic_psu.psu_base import PsuBase
|
|
except ImportError as e:
|
|
raise ImportError (str(e) + "- required module not found")
|
|
|
|
class PsuUtil(PsuBase):
|
|
"""Platform-specific PSUutil class"""
|
|
|
|
def __init__(self):
|
|
PsuBase.__init__(self)
|
|
|
|
self.psu_path = "/sys/bus/i2c/devices/"
|
|
self.psu_presence = "/psu_present"
|
|
self.psu_oper_status = "/psu_power_good"
|
|
self.psu_mapping = {
|
|
2: "13-0053",
|
|
1: "17-0051",
|
|
}
|
|
|
|
def get_num_psus(self):
|
|
return len(self.psu_mapping)
|
|
|
|
def get_psu_status(self, index):
|
|
if index is None:
|
|
return False
|
|
|
|
status = 0
|
|
node = self.psu_path + self.psu_mapping[index]+self.psu_oper_status
|
|
try:
|
|
with open(node, 'r') as power_status:
|
|
status = int(power_status.read())
|
|
except IOError:
|
|
return False
|
|
|
|
return status == 1
|
|
|
|
def get_psu_presence(self, index):
|
|
if index is None:
|
|
return False
|
|
|
|
status = 0
|
|
node = self.psu_path + self.psu_mapping[index] + self.psu_presence
|
|
try:
|
|
with open(node, 'r') as presence_status:
|
|
status = int(presence_status.read())
|
|
except IOError:
|
|
return False
|
|
|
|
return status == 1
|