forked from sonic-net/sonic-swss
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSD Generic] Add support for parsing nvme ssd model, health and temp…
…erature (sonic-net#265) * add support for parsing nvme ssd model, health and temperature Signed-off-by: Kebo Liu <kebol@nvidia.com> * Add test case for sfp_ssd Signed-off-by: Kebo Liu <kebol@nvidia.com>
- Loading branch information
Showing
2 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
import sys | ||
if sys.version_info.major == 3: | ||
from unittest import mock | ||
else: | ||
import mock | ||
|
||
from sonic_platform_base.sonic_ssd.ssd_generic import SsdUtil | ||
|
||
output_nvme_ssd = """smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.10.0-8-2-amd64] (local build) | ||
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org | ||
=== START OF INFORMATION SECTION === | ||
Model Number: SFPC020GM1EC2TO-I-5E-11P-STD | ||
Serial Number: A0221030722410000027 | ||
Firmware Version: COT6OQ | ||
PCI Vendor/Subsystem ID: 0x1dd4 | ||
IEEE OUI Identifier: 0x8c6078 | ||
Controller ID: 1 | ||
NVMe Version: 1.3 | ||
Number of Namespaces: 1 | ||
Namespace 1 Size/Capacity: 20,014,718,976 [20.0 GB] | ||
Namespace 1 Formatted LBA Size: 512 | ||
Namespace 1 IEEE EUI-64: 486834 133070001b | ||
Local Time is: Tue Mar 1 06:35:23 2022 UTC | ||
Firmware Updates (0x12): 1 Slot, no Reset required | ||
Optional Admin Commands (0x0016): Format Frmw_DL Self_Test | ||
Optional NVM Commands (0x001f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat | ||
Log Page Attributes (0x0e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg | ||
Maximum Data Transfer Size: 64 Pages | ||
Warning Comp. Temp. Threshold: 105 Celsius | ||
Critical Comp. Temp. Threshold: 120 Celsius | ||
Supported Power States | ||
St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat | ||
0 + 3.50W - - 0 0 0 0 0 0 | ||
1 + 2.50W - - 1 1 1 1 0 0 | ||
2 + 1.50W - - 2 2 2 2 0 0 | ||
3 - 0.0200W - - 3 3 3 3 2200 3000 | ||
4 - 0.0100W - - 4 4 4 4 15000 12000 | ||
Supported LBA Sizes (NSID 0x1) | ||
Id Fmt Data Metadt Rel_Perf | ||
0 + 512 0 0 | ||
=== START OF SMART DATA SECTION === | ||
SMART overall-health self-assessment test result: PASSED | ||
SMART/Health Information (NVMe Log 0x02) | ||
Critical Warning: 0x00 | ||
Temperature: 37 Celsius | ||
Available Spare: 100% | ||
Available Spare Threshold: 10% | ||
Percentage Used: 0% | ||
Data Units Read: 1,546,369 [791 GB] | ||
Data Units Written: 7,118,163 [3.64 TB] | ||
Host Read Commands: 27,027,268 | ||
Host Write Commands: 87,944,082 | ||
Controller Busy Time: 5,660 | ||
Power Cycles: 455 | ||
Power On Hours: 3,638 | ||
Unsafe Shutdowns: 435 | ||
Media and Data Integrity Errors: 0 | ||
Error Information Log Entries: 5,275 | ||
Warning Comp. Temperature Time: 0 | ||
Critical Comp. Temperature Time: 0 | ||
Temperature Sensor 1: 41 Celsius | ||
Temperature Sensor 2: 38 Celsius | ||
Error Information (NVMe Log 0x01, 16 of 64 entries) | ||
Num ErrCount SQId CmdId Status PELoc LBA NSID VS | ||
0 5275 0 0x0001 0x0004 - 0 1 -""" | ||
|
||
class TestSsdGeneric: | ||
@mock.patch('sonic_platform_base.sonic_ssd.ssd_generic.SsdUtil._execute_shell', mock.MagicMock(return_value=output_nvme_ssd)) | ||
def test_nvme_ssd(self): | ||
nvme_ssd = SsdUtil('/dev/nvme0n1') | ||
assert(nvme_ssd.get_health() == 100.0) | ||
assert(nvme_ssd.get_model() == 'SFPC020GM1EC2TO-I-5E-11P-STD') | ||
assert(nvme_ssd.get_firmware() == "COT6OQ") | ||
assert(nvme_ssd.get_temperature() == 37) | ||
assert(nvme_ssd.get_serial() == "A0221030722410000027") | ||
|
||
|