iscsi: Use Python to parse output of lspci
Instead of using shell commands, use python to parse the output of lspci. This is considered more "Pythonic". Change-Id: I88ef0fe8cbfbcaa9c5d323552a82ef63e46f52cf Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
fe3ac8e5c7
commit
4ebf15eedf
@ -396,25 +396,25 @@ def verify_add_delete_ip_address(rpc_py):
|
||||
def verify_add_nvme_bdev_rpc_methods(rpc_py):
|
||||
rpc = spdk_rpc(rpc_py)
|
||||
test_pass = 0
|
||||
output = check_output("lspci -mm -n | awk '{if ($2 == \"\\\"0108\\\"\") print $0}' | grep p02", shell=True)
|
||||
for out in output.split("\n"):
|
||||
if out != '':
|
||||
ctrlr_address = "0000:{}".format(out.split(" ")[0])
|
||||
output = check_output(["lspci", "-mm", "-nn"])
|
||||
addrs = re.findall('^([0-9]{2}:[0-9]{2}.[0-9]) "Non-Volatile memory controller \[0108\]".*-p02', output, re.MULTILINE)
|
||||
for addr in addrs:
|
||||
ctrlr_address = "0000:{}".format(addr)
|
||||
output = rpc.construct_nvme_bdev(ctrlr_address)
|
||||
if output.strip() == '':
|
||||
print "add nvme device passed first time"
|
||||
test_pass = 1
|
||||
verify(test_pass == 1, 1, "add nvme device passed first time")
|
||||
test_pass = 0
|
||||
try:
|
||||
output = rpc.construct_nvme_bdev(ctrlr_address)
|
||||
if output.strip() == '':
|
||||
print "add nvme device passed first time"
|
||||
test_pass = 1
|
||||
verify(test_pass == 1, 1, "add nvme device passed first time")
|
||||
test_pass = 0
|
||||
try:
|
||||
output = rpc.construct_nvme_bdev(ctrlr_address)
|
||||
except Exception as e:
|
||||
print "add nvme device passed second time"
|
||||
test_pass = 1
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
verify(test_pass == 1, 1, "add nvme device passed second time")
|
||||
except Exception as e:
|
||||
print "add nvme device passed second time"
|
||||
test_pass = 1
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
verify(test_pass == 1, 1, "add nvme device passed second time")
|
||||
print "verify_add_nvme_bdev_rpc_methods passed."
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user