8325500560
Why I did it Added support for the device N3248TE How I did it Implemented the support for the platform N3248TE Switch Vendor: DellEMC Switch SKU: N3248TE ASIC Vendor: Broadcom SONiC Image: sonic-broadcom.bin How to verify it Verified the show platform commands
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
#
|
|
# fanutil.py
|
|
# Platform-specific FAN status interface for SONiC
|
|
#
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
SENSORS_CMD = "docker exec -i pmon /usr/bin/sensors"
|
|
DOCKER_SENSORS_CMD = "/usr/bin/sensors"
|
|
|
|
|
|
try:
|
|
from sonic_fan.fan_base import FanBase
|
|
except ImportError as e:
|
|
raise ImportError(str(e) + "- required module not found")
|
|
|
|
|
|
class FanUtil(FanBase):
|
|
"""Platform-specific FanUtil class"""
|
|
_fan_mapping = {
|
|
1 : '0',
|
|
2 : '1',
|
|
3 : '2'
|
|
}
|
|
|
|
def __init__(self):
|
|
FanBase.__init__(self)
|
|
|
|
def isDockerEnv(self):
|
|
num_docker = open('/proc/self/cgroup', 'r').read().count(":/docker")
|
|
if num_docker > 0:
|
|
return True
|
|
|
|
def get_num_fans(self):
|
|
N3248TE_MAX_FANTRAYS = 3
|
|
return N3248TE_MAX_FANTRAYS
|
|
|
|
def get_presence(self, idx):
|
|
sysfs_path = "/sys/devices/platform/dell-n3248te-cpld.0/fan" + self._fan_mapping[idx] + "_prs"
|
|
return int(open(sysfs_path).read(), 16)
|
|
|
|
def get_direction(self, idx):
|
|
sysfs_path = "/sys/devices/platform/dell-n3248te-cpld.0/fan" + self._fan_mapping[idx] + "_dir"
|
|
return open(sysfs_path).read()
|
|
|
|
def get_speed(self, idx):
|
|
dockerenv = self.isDockerEnv()
|
|
if not dockerenv:
|
|
status, cmd_output = subprocess.getstatusoutput(SENSORS_CMD)
|
|
else :
|
|
status, cmd_output = subprocess.getstatusoutput(DOCKER_SENSORS_CMD)
|
|
|
|
if status:
|
|
print('Failed to execute sensors command')
|
|
sys.exit(0)
|
|
fan_id = 'Fan ' + str(idx)
|
|
found = False
|
|
for line in cmd_output.splitlines():
|
|
if line.startswith('emc2305-i2c-7-2c'):
|
|
found = True
|
|
if found and line.startswith(fan_id):
|
|
return line.split()[3]
|
|
return 0.0
|
|
|
|
def get_status(self, idx):
|
|
sysfs_path = "/sys/devices/platform/dell-n3248te-cpld.0/fan" + self._fan_mapping[idx] + "_prs"
|
|
return int(open(sysfs_path).read(), 16)
|
|
|
|
|
|
def set_speed(self, idx):
|
|
return False
|