From 301287ec49c7edcc2922740be6cfd58275be5dad Mon Sep 17 00:00:00 2001 From: hantienEdgecore Date: Wed, 17 Aug 2022 15:59:08 +0800 Subject: [PATCH] [ssd_generic]Fix ssd no vendor information 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) --- sonic_platform_base/sonic_ssd/ssd_generic.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sonic_platform_base/sonic_ssd/ssd_generic.py b/sonic_platform_base/sonic_ssd/ssd_generic.py index 8d38d11e0..e9a52158f 100644 --- a/sonic_platform_base/sonic_ssd/ssd_generic.py +++ b/sonic_platform_base/sonic_ssd/ssd_generic.py @@ -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" @@ -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): """