summaryrefslogtreecommitdiffstats
path: root/qa/tasks/nvme_loop.py
diff options
context:
space:
mode:
Diffstat (limited to 'qa/tasks/nvme_loop.py')
-rw-r--r--qa/tasks/nvme_loop.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/qa/tasks/nvme_loop.py b/qa/tasks/nvme_loop.py
index c9d8f0dc7..5b29c11f0 100644
--- a/qa/tasks/nvme_loop.py
+++ b/qa/tasks/nvme_loop.py
@@ -1,5 +1,6 @@
import contextlib
import logging
+import json
from io import StringIO
from teuthology import misc as teuthology
@@ -66,10 +67,33 @@ def task(ctx, config):
with contextutil.safe_while(sleep=1, tries=15) as proceed:
while proceed():
- p = remote.run(args=['sudo', 'nvme', 'list'], stdout=StringIO())
+ p = remote.run(args=['sudo', 'nvme', 'list', '-o', 'json'], stdout=StringIO())
new_devs = []
- for line in p.stdout.getvalue().splitlines():
- dev, _, vendor = line.split()[0:3]
+ # `nvme list -o json` will return the following output:
+ '''{
+ "Devices" : [
+ {
+ "DevicePath" : "/dev/nvme0n1",
+ "Firmware" : "8DV101H0",
+ "Index" : 0,
+ "ModelNumber" : "INTEL SSDPEDMD400G4",
+ "ProductName" : "Unknown Device",
+ "SerialNumber" : "PHFT620400WB400BGN"
+ },
+ {
+ "DevicePath" : "/dev/nvme1n1",
+ "Firmware" : "5.15.0-1",
+ "Index" : 1,
+ "ModelNumber" : "Linux",
+ "ProductName" : "Unknown Device",
+ "SerialNumber" : "7672ce414766ba44a8e5"
+ }
+ ]
+ }'''
+ nvme_list = json.loads(p.stdout.getvalue())
+ for device in nvme_list['Devices']:
+ dev = device['DevicePath']
+ vendor = device['ModelNumber']
if dev.startswith('/dev/') and vendor == 'Linux':
new_devs.append(dev)
log.info(f'new_devs {new_devs}')