sonic-buildimage/device/ruijie/x86_64-ruijie_b6510-48vs8cq-r0/plugins/psuutil.py
ruijie.com.cn a582c13e98
[Ruijie] Add ruijie platform & device (#4954)
Add new platform x86_64-ruijie_b6510-48vs8cq-r0 (Trident 3)
    ASIC Vendor: Broadcom
    Switch ASIC: Trident 3
    Port Config: 48x25G+8x100G

Signed-off-by: tim-rj <sonic_rd@ruijie.com.cn>
2021-02-24 16:45:27 -08:00

64 lines
1.3 KiB
Python
Executable File

#
# psuutil.py
# Platform-specific PSU status interface for SONiC
#
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)
def get_num_psus(self):
return 2
def get_psu_status(self, index):
if index != 1 and index != 2:
return False
psu_path = "/sys/bus/i2c/devices/2-0037/psu_status"
try:
data = open(psu_path, "rb")
except IOError:
return False
result = int(data.read(2), 16)
data.close()
if index == 1 and (result & 0x2):
return True
if index == 2 and (result & 0x20):
return True
return False
def get_psu_presence(self, index):
if index != 1 and index != 2:
return False
psu_path = "/sys/bus/i2c/devices/2-0037/psu_status"
try:
data = open(psu_path, "rb")
except IOError:
return False
result = int(data.read(2), 16)
data.close()
if index == 1 and (result & 0x1) == 0:
return True
if index == 2 and (result & 0x10) == 0:
return True
return False