sonic-buildimage/platform/marvell-arm64/sonic-platform-nokia/7215/utils/sonic_ssd.py
Pavan-Nokia 393c6911c5 [Nokia-7215-A1] Update Nokia-7215-A1 platform (#15342)
Update Nokia-7215-A1 platform to address UT and OC test failures
2023-09-05 00:35:18 +08:00

48 lines
1.3 KiB
Python

import os
# pylint: disable=import-error
from sonic_platform_base.sonic_ssd.ssd_base import SsdBase
from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil as SsdUtilDefault
class EmmcUtil(SsdBase):
def __init__(self, diskdev):
self.diskdev = diskdev
self.path = os.path.join('/sys/block', os.path.basename(diskdev))
def _readDeviceEntry(self, entry, default=None):
path = os.path.join(self.path, 'device', entry)
try:
with open(path, encoding='utf8') as f:
return f.read().rstrip()
except OSError:
return default
def _isSlc(self):
return bool(self._readDeviceEntry('enhanced_area_offset'))
def get_health(self):
data = self._readDeviceEntry('life_time')
if data is None:
raise NotImplementedError
value = int(data.split()[0 if self._isSlc() else 1], 0)
return float(100 - (10 * (value - 1)))
def get_temperature(self):
return 'N/A'
def get_model(self):
return self._readDeviceEntry('name')
def get_firmware(self):
return self._readDeviceEntry('fwrev')
def get_serial(self):
return self._readDeviceEntry('serial')
def get_vendor_output(self):
return ''
def SsdUtil(diskdev):
return EmmcUtil('/dev/mmcblk0')