2323# SOFTWARE.
2424#
2525###############################################################################
26- import glob
2726import os
27+ import re
2828
2929from pydantic import ValidationError
3030
@@ -64,14 +64,13 @@ def collect_data(
6464 self ._log_event (
6565 category = EventCategory .SW_DRIVER ,
6666 description = "No NVMe devices found" ,
67- priority = EventPriority .CRITICAL ,
67+ priority = EventPriority .ERROR ,
6868 )
6969 self .result .message = "No NVMe devices found"
7070 self .result .status = ExecutionStatus .ERROR
7171 return self .result , None
7272
7373 all_device_data = {}
74- telemetry_file = "telemetry_log"
7574
7675 for dev in nvme_devices :
7776 device_data = {}
@@ -83,23 +82,18 @@ def collect_data(
8382 "fw_log" : f"nvme fw-log { dev } " ,
8483 "self_test_log" : f"nvme self-test-log { dev } " ,
8584 "get_log" : f"nvme get-log { dev } --log-id=6 --log-len=512" ,
86- "telemetry_log" : f"nvme telemetry-log { dev } --output-file={ telemetry_file } " ,
8785 }
8886
8987 for key , cmd in commands .items ():
9088 res = self ._run_sut_cmd (cmd , sudo = True )
91- if "telemetry-log" in cmd and res .exit_code == 0 :
92- file_artifact = self ._read_sut_file (filename = telemetry_file , encoding = None )
93- self ._log_file_artifact (file_artifact .filename , file_artifact .contents )
94-
9589 if res .exit_code == 0 :
9690 device_data [key ] = res .stdout
9791 else :
9892 self ._log_event (
9993 category = EventCategory .SW_DRIVER ,
10094 description = f"Failed to execute NVMe command: '{ cmd } '" ,
10195 data = {"command" : cmd , "exit_code" : res .exit_code },
102- priority = EventPriority .ERROR ,
96+ priority = EventPriority .WARNING ,
10397 console_log = True ,
10498 )
10599
@@ -114,7 +108,7 @@ def collect_data(
114108 category = EventCategory .SW_DRIVER ,
115109 description = "Validation error while building NvmeDataModel" ,
116110 data = {"error" : str (e )},
117- priority = EventPriority .CRITICAL ,
111+ priority = EventPriority .ERROR ,
118112 )
119113 self .result .message = "NVMe data invalid format"
120114 self .result .status = ExecutionStatus .ERROR
@@ -133,18 +127,17 @@ def collect_data(
133127 self ._log_event (
134128 category = EventCategory .SW_DRIVER ,
135129 description = "Failed to collect any NVMe data" ,
136- priority = EventPriority .CRITICAL ,
130+ priority = EventPriority .ERROR ,
137131 )
138132 self .result .message = "No NVMe data collected"
139133 self .result .status = ExecutionStatus .ERROR
140134 return self .result , None
141135
142136 def _get_nvme_devices (self ) -> list [str ]:
143- """Find all non-partition NVMe block devices (e.g., /dev/nvme0, /dev/nvme1)."""
144- devices = []
145- for dev_path in sorted (glob .glob ("/dev/nvme*" )):
146- if os .path .basename (dev_path ).endswith ("n1" ):
147- continue
148- if os .path .exists (dev_path ) and os .path .isfile (dev_path ) is False :
149- devices .append (dev_path )
150- return devices
137+ nvme_devs = []
138+ for entry in os .listdir ("/dev" ):
139+ full_path = os .path .join ("/dev" , entry )
140+
141+ if re .fullmatch (r"nvme\d+$" , entry ) and os .path .exists (full_path ):
142+ nvme_devs .append (full_path )
143+ return nvme_devs
0 commit comments