Skip to content

Commit 07ccd27

Browse files
Fix issue: should use 'Value' column to calculate the health percentage
1 parent 6d2d7a3 commit 07ccd27

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

sonic_platform_base/sonic_ssd/ssd_generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ 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-
127+
128128
if self.health == NOT_AVAILABLE:
129129
health_raw = self.parse_id_number(INNODISK_HEALTH_ID)
130130
if health_raw == NOT_AVAILABLE:
@@ -150,10 +150,10 @@ def parse_virtium_info(self):
150150
pass
151151
else:
152152
try:
153-
self.health = float(self._parse_re('Remaining_Life_Left\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info))
153+
self.health = float(self._parse_re('Remaining_Life_Left\s*\d*\s*\d*\s*(\d+?)\s+', self.vendor_ssd_info))
154154
except ValueError:
155155
pass
156-
156+
157157
def fetch_vendor_ssd_info(self, diskdev, model):
158158
self.vendor_ssd_info = self._execute_shell(self.vendor_ssd_utility[model]["utility"].format(diskdev))
159159

tests/ssd_generic_test.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
Offline data collection status: (0x00) Offline data collection activity
9999
was never started.
100100
Auto Offline Data Collection: Disabled.
101-
Total time to complete Offline
101+
Total time to complete Offline
102102
data collection: ( 32) seconds.
103103
Offline data collection
104104
capabilities: (0x00) Offline data collection not supported.
@@ -178,7 +178,7 @@
178178
Offline data collection status: (0x00) Offline data collection activity
179179
was never started.
180180
Auto Offline Data Collection: Disabled.
181-
Total time to complete Offline
181+
Total time to complete Offline
182182
data collection: ( 32) seconds.
183183
Offline data collection
184184
capabilities: (0x00) Offline data collection not supported.
@@ -232,29 +232,29 @@
232232
output_Innodisk_vendor_info = """********************************************************************************************
233233
* Innodisk iSMART V3.9.41 2018/05/25 *
234234
********************************************************************************************
235-
Model Name: InnoDisk Corp. - mSATA 3ME
236-
FW Version: S140714
235+
Model Name: InnoDisk Corp. - mSATA 3ME
236+
FW Version: S140714
237237
Serial Number: 20171126AAAA11730156
238-
Health: 82.34%
238+
Health: 82.34%
239239
Capacity: 29.818199 GB
240-
P/E Cycle: 3000
241-
Lifespan : 0 (Years : 0 Months : 0 Days : 0)
242-
Write Protect: Disable
243-
InnoRobust: Enable
240+
P/E Cycle: 3000
241+
Lifespan : 0 (Years : 0 Months : 0 Days : 0)
242+
Write Protect: Disable
243+
InnoRobust: Enable
244244
--------------------------------------------------------------------------------------------
245-
ID SMART Attributes Value Raw Value
245+
ID SMART Attributes Value Raw Value
246246
--------------------------------------------------------------------------------------------
247-
[09] Power On Hours [32474] [0902006464DA7E0000000000]
248-
[0C] Power Cycle Count [ 297] [0C0200646429010000000000]
249-
[AA] Total Bad Block Count [ 47] [AA0300646400002F00000000]
250-
[AD] Erase Count Max. [ 7280] [AD02006464181C701C000000]
251-
[AD] Erase Count Avg. [ 7192] [AD02006464181C701C000000]
252-
[C2] Temperature [ 0] [000000000000000000000000]
253-
[EB] Later Bad Block [ 0] [EB0200640000000000000000]
254-
[EB] Read Block [ 0] [EB0200640000000000000000]
255-
[EB] Write Block [ 0] [EB0200640000000000000000]
256-
[EB] Erase Block [ 0] [EB0200640000000000000000]
257-
[EC] Unstable Power Count [ 0] [EC0200646400000000000000]
247+
[09] Power On Hours [32474] [0902006464DA7E0000000000]
248+
[0C] Power Cycle Count [ 297] [0C0200646429010000000000]
249+
[AA] Total Bad Block Count [ 47] [AA0300646400002F00000000]
250+
[AD] Erase Count Max. [ 7280] [AD02006464181C701C000000]
251+
[AD] Erase Count Avg. [ 7192] [AD02006464181C701C000000]
252+
[C2] Temperature [ 0] [000000000000000000000000]
253+
[EB] Later Bad Block [ 0] [EB0200640000000000000000]
254+
[EB] Read Block [ 0] [EB0200640000000000000000]
255+
[EB] Write Block [ 0] [EB0200640000000000000000]
256+
[EB] Erase Block [ 0] [EB0200640000000000000000]
257+
[EC] Unstable Power Count [ 0] [EC0200646400000000000000]
258258
"""
259259

260260
output_lack_info_ssd = """smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-8-2-amd64] (local build)
@@ -292,7 +292,7 @@
292292
Offline data collection status: (0x02) Offline data collection activity
293293
was completed without error.
294294
Auto Offline Data Collection: Disabled.
295-
Total time to complete Offline
295+
Total time to complete Offline
296296
data collection: ( 32) seconds.
297297
Offline data collection
298298
capabilities: (0x00) Offline data collection not supported.
@@ -372,9 +372,9 @@
372372
was never started.
373373
Auto Offline Data Collection: Disabled.
374374
Self-test execution status: ( 0) The previous self-test routine completed
375-
without error or no self-test has ever
375+
without error or no self-test has ever
376376
been run.
377-
Total time to complete Offline
377+
Total time to complete Offline
378378
data collection: ( 0) seconds.
379379
Offline data collection
380380
capabilities: (0x73) SMART execute Offline immediate.
@@ -390,7 +390,7 @@
390390
Supports SMART auto save timer.
391391
Error logging capability: (0x01) Error logging supported.
392392
General Purpose Logging supported.
393-
Short self-test routine
393+
Short self-test routine
394394
recommended polling time: ( 2) minutes.
395395
Extended self-test routine
396396
recommended polling time: ( 15) minutes.
@@ -484,7 +484,7 @@
484484
241 Total_LBAs_Written 0 302116658 100 100 0
485485
242 Total_LBAs_Read 0 45608497 100 100 0
486486
247 Reserved_Attribute 0 347463680 100 100 0
487-
248 Remaining_Life_Left 0 1 100 100 0
487+
248 Remaining_Life_Left 0 0 1 100 0
488488
"""
489489

490490
output_virtium_no_remain_life = """
@@ -599,7 +599,7 @@ 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-
602+
603603
@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell', mock.MagicMock(return_value=output_Innodisk_missing_names_ssd))
604604
def test_Innodisk_missing_names_ssd_2(self):
605605
# Test parsing Innodisk ssd info
@@ -608,7 +608,7 @@ def test_Innodisk_missing_names_ssd_2(self):
608608
Innodisk_ssd.parse_vendor_ssd_info('InnoDisk')
609609
assert(Innodisk_ssd.get_health() == '94')
610610
assert(Innodisk_ssd.get_temperature() == '39')
611-
611+
612612

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

0 commit comments

Comments
 (0)