Skip to content
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

[sonic_ssd] Nokia-7215: Fix "show platform ssdhealth" #337

Merged
merged 1 commit into from
Mar 7, 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
16 changes: 11 additions & 5 deletions sonic_platform_base/sonic_ssd/ssd_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,18 @@ 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)
else:
if self.health == NOT_AVAILABLE:
health_raw = self.parse_id_number(INNODISK_HEALTH_ID)

if self.health == NOT_AVAILABLE:
health_raw = self.parse_id_number(INNODISK_HEALTH_ID)
if health_raw == NOT_AVAILABLE:
self.health = NOT_AVAILABLE
else:
self.health = health_raw.split()[-1]
if self.temperature == NOT_AVAILABLE:
temp_raw = self.parse_id_number(INNODISK_TEMPERATURE_ID)
if self.temperature == NOT_AVAILABLE:
temp_raw = self.parse_id_number(INNODISK_TEMPERATURE_ID)
if temp_raw == NOT_AVAILABLE:
self.temperature = NOT_AVAILABLE
else:
self.temperature = temp_raw.split()[-6]

def parse_virtium_info(self):
Expand Down
12 changes: 11 additions & 1 deletion tests/ssd_generic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def test_ssd_with_na_path(self):
def test_Innodisk_ssd(self):
# Test parsing Innodisk ssd info
Innodisk_ssd = SsdUtil('/dev/sda')
assert(Innodisk_ssd.get_health() == 'N/A')
assert(Innodisk_ssd.get_health() == '0x000000000000')
assert(Innodisk_ssd.get_model() == 'InnoDisk Corp. - mSATA 3ME')
assert(Innodisk_ssd.get_firmware() == "S140714")
assert(Innodisk_ssd.get_temperature() == 'N/A')
Expand All @@ -411,4 +411,14 @@ def test_Innodisk_missing_names_ssd(self):
Innodisk_ssd.parse_vendor_ssd_info('InnoDisk')
assert(Innodisk_ssd.get_health() == '94')
assert(Innodisk_ssd.get_temperature() == '39')

@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell', mock.MagicMock(return_value=output_Innodisk_missing_names_ssd))
def test_Innodisk_missing_names_ssd_2(self):
# Test parsing Innodisk ssd info
Innodisk_ssd = SsdUtil('/dev/sda')
Innodisk_ssd.vendor_ssd_info = 'ERROR message from cmd'
Innodisk_ssd.parse_vendor_ssd_info('InnoDisk')
assert(Innodisk_ssd.get_health() == '94')
assert(Innodisk_ssd.get_temperature() == '39')