Skip to content

Commit c551a81

Browse files
authored
[sonic_ssd] Nokia-7215: Fix "show platform ssdhealth" (sonic-net#337)
Description: The command is not showing the correct value for ssd health and temperature. admin@sonic:~$ show platform ssdhealth Device Model : M.2 (S42) 3IE4 Health : N/A Temperature : N/A Motivation and Context: SSD health percentage and temperature not displayed on Nokia-7215 platform. How Has This Been Tested? "show platform ssdhealth" cli command on Nokia-7215 and Unittests Output after fix: admin@sonic:~$ show platform ssdhealth Device Model : M.2 (S42) 3IE4 Health : 100% Temperature : 25C
1 parent 1929332 commit c551a81

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

sonic_platform_base/sonic_ssd/ssd_generic.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ def parse_innodisk_info(self):
124124
if self.vendor_ssd_info:
125125
self.health = self._parse_re('Health:\s*(.+?)%', self.vendor_ssd_info)
126126
self.temperature = self._parse_re('Temperature\s*\[\s*(.+?)\]', self.vendor_ssd_info)
127-
else:
128-
if self.health == NOT_AVAILABLE:
129-
health_raw = self.parse_id_number(INNODISK_HEALTH_ID)
127+
128+
if self.health == NOT_AVAILABLE:
129+
health_raw = self.parse_id_number(INNODISK_HEALTH_ID)
130+
if health_raw == NOT_AVAILABLE:
131+
self.health = NOT_AVAILABLE
132+
else:
130133
self.health = health_raw.split()[-1]
131-
if self.temperature == NOT_AVAILABLE:
132-
temp_raw = self.parse_id_number(INNODISK_TEMPERATURE_ID)
134+
if self.temperature == NOT_AVAILABLE:
135+
temp_raw = self.parse_id_number(INNODISK_TEMPERATURE_ID)
136+
if temp_raw == NOT_AVAILABLE:
137+
self.temperature = NOT_AVAILABLE
138+
else:
133139
self.temperature = temp_raw.split()[-6]
134140

135141
def parse_virtium_info(self):

tests/ssd_generic_test.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def test_ssd_with_na_path(self):
577577
def test_Innodisk_ssd(self):
578578
# Test parsing Innodisk ssd info
579579
Innodisk_ssd = SsdUtil('/dev/sda')
580-
assert(Innodisk_ssd.get_health() == 'N/A')
580+
assert(Innodisk_ssd.get_health() == '0x000000000000')
581581
assert(Innodisk_ssd.get_model() == 'InnoDisk Corp. - mSATA 3ME')
582582
assert(Innodisk_ssd.get_firmware() == "S140714")
583583
assert(Innodisk_ssd.get_temperature() == 'N/A')
@@ -599,6 +599,16 @@ def test_Innodisk_missing_names_ssd(self):
599599
Innodisk_ssd.parse_vendor_ssd_info('InnoDisk')
600600
assert(Innodisk_ssd.get_health() == '94')
601601
assert(Innodisk_ssd.get_temperature() == '39')
602+
603+
@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell', mock.MagicMock(return_value=output_Innodisk_missing_names_ssd))
604+
def test_Innodisk_missing_names_ssd_2(self):
605+
# Test parsing Innodisk ssd info
606+
Innodisk_ssd = SsdUtil('/dev/sda')
607+
Innodisk_ssd.vendor_ssd_info = 'ERROR message from cmd'
608+
Innodisk_ssd.parse_vendor_ssd_info('InnoDisk')
609+
assert(Innodisk_ssd.get_health() == '94')
610+
assert(Innodisk_ssd.get_temperature() == '39')
611+
602612

603613
@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell')
604614
def test_virtium_ssd(self, mock_exec):

0 commit comments

Comments
 (0)