This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
sonic-buildimage/device/celestica/x86_64-cel_ds1000-r0/plugins/psuutil.py
Jemston Fernando 7302132103 Fix for Celestica platform issue and new WB support
- Support for new platform Questone
- Belgite renamed to DS1000
- Hardened bug fixes and unified CLI O/P for Celestica platforms
2024-02-09 17:32:36 +00:00

79 lines
2.4 KiB
Python

#
# psuutil.py
# Platform-specific PSU status interface for SONiC
#
import os
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):
"""
Retrieves the number of PSUs available on the device
:return: An integer, the number of PSUs available on the device
"""
return 2
def get_psu_status(self, index):
"""
Retrieves the oprational status of power supply unit (PSU) defined
by 1-based index <index>
:param index: An integer, 1-based index of the PSU of which to query status
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
"""
if index is None:
return False
if index == 1:
status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0058/psu_power_good"
elif index == 2:
status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0059/psu_power_good"
else:
return False
try:
with open(status_path, 'r') as fd:
status = fd.read().rstrip('\r\n')
if status == '0':
return True
else:
return False
except IOError:
return False
def get_psu_presence(self, index):
"""
Retrieves the presence status of power supply unit (PSU) defined
by 1-based index <index>
:param index: An integer, 1-based index of the PSU of which to query status
:return: Boolean, True if PSU is plugged, False if not
"""
if index is None:
return False
if index == 1:
status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0058/psu_present"
elif index == 2:
status_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-4/4-0059/psu_present"
else:
return False
try:
with open(status_path, 'r') as fd:
status = fd.read().rstrip('\r\n')
if status == '1':
return True
else:
return False
except IOError:
return False