diff --git a/test/iscsi_tgt/rpc_config/rpc_config.py b/test/iscsi_tgt/rpc_config/rpc_config.py index e43ca22fcb..1991aa9aff 100755 --- a/test/iscsi_tgt/rpc_config/rpc_config.py +++ b/test/iscsi_tgt/rpc_config/rpc_config.py @@ -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__":