Skip to content

[202205] Fix issue: should use 'Value' column to calculate the health percentage for Virtium SSD #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions sonic_platform_base/sonic_ssd/ssd_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def __init__(self, diskdev):

# Known vendor part
if self.model:
model_short = self.model.split()[0]
if model_short in self.vendor_ssd_utility:
self.fetch_vendor_ssd_info(diskdev, model_short)
self.parse_vendor_ssd_info(model_short)
vendor = self._parse_vendor()
if vendor:
self.fetch_vendor_ssd_info(diskdev, vendor)
self.parse_vendor_ssd_info(vendor)
else:
# No handler registered for this disk model
pass
Expand All @@ -72,6 +72,15 @@ def _parse_re(self, pattern, buffer):
res_list = re.findall(pattern, buffer)
return res_list[0] if res_list else NOT_AVAILABLE

def _parse_vendor(self):
model_short = self.model.split()[0]
if model_short in self.vendor_ssd_utility:
return model_short
elif self.model.startswith('VSF'):
return 'Virtium'
else:
return None

def fetch_generic_ssd_info(self, diskdev):
self.ssd_info = self._execute_shell(self.vendor_ssd_utility["Generic"]["utility"].format(diskdev))

Expand Down Expand Up @@ -115,7 +124,7 @@ def parse_innodisk_info(self):
if self.vendor_ssd_info:
self.health = self._parse_re('Health:\s*(.+?)%', self.vendor_ssd_info)
self.temperature = self._parse_re('Temperature\s*\[\s*(.+?)\]', self.vendor_ssd_info)

if self.health == NOT_AVAILABLE:
health_raw = self.parse_id_number(INNODISK_HEALTH_ID)
if health_raw == NOT_AVAILABLE:
Expand All @@ -134,10 +143,16 @@ def parse_virtium_info(self):
self.temperature = self._parse_re('Temperature_Celsius\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info)
nand_endurance = self._parse_re('NAND_Endurance\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info)
avg_erase_count = self._parse_re('Average_Erase_Count\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info)
try:
self.health = 100 - (float(avg_erase_count) * 100 / float(nand_endurance))
except (ValueError, ZeroDivisionError):
pass
if nand_endurance != NOT_AVAILABLE and avg_erase_count != NOT_AVAILABLE:
try:
self.health = 100 - (float(avg_erase_count) * 100 / float(nand_endurance))
except (ValueError, ZeroDivisionError):
pass
else:
try:
self.health = float(self._parse_re('Remaining_Life_Left\s*\d*\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info))
except ValueError:
pass

def fetch_vendor_ssd_info(self, diskdev, model):
self.vendor_ssd_info = self._execute_shell(self.vendor_ssd_utility[model]["utility"].format(diskdev))
Expand Down
Loading