Skip to content

Commit

Permalink
[ssd_generic]Fix ssd no vendor information
Browse files Browse the repository at this point in the history
The ssd information can show correctly even if can't get model information in generic SSD information.
When unknown model name , use Virtuim tool to get SSD Health/Temperature .

How has this been Tested ?
Manual testing on Edgecore switch (ex AS4630_54PE)
  • Loading branch information
hantienEdgecore committed Nov 22, 2022
1 parent 030a382 commit 301287e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sonic_platform_base/sonic_ssd/ssd_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def __init__(self, diskdev):
self.fetch_vendor_ssd_info(diskdev, model_short)
self.parse_vendor_ssd_info(model_short)
else:
# No handler registered for this disk model
pass
# unknown model name , use Virtium to get information
self.vendor_ssd_info =self._execute_shell(self.vendor_ssd_utility["Virtium"]["utility"].format(diskdev))
self.parse_virtium_info()
else:
# Failed to get disk model
self.model = "Unknown"
Expand Down Expand Up @@ -124,20 +125,22 @@ def parse_innodisk_info(self):
self.temperature = temp_raw.split()[-6]

def parse_virtium_info(self):
if self.vendor_ssd_info:
self.temperature = self._parse_re('Temperature_Celsius\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info)
self.temperature = self._parse_re('Temperature_Celsius\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info)
self.health = self._parse_re('Remaining_Life_Left\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info)
if self.health == NOT_AVAILABLE:
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):
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))

def parse_vendor_ssd_info(self, model):
self.vendor_ssd_utility[model]["parser"]()
if self.vendor_ssd_info:
self.vendor_ssd_utility[model]["parser"]()

def get_health(self):
"""
Expand Down

0 comments on commit 301287e

Please sign in to comment.