Commit 4ebf15ee authored by Ben Walker's avatar Ben Walker
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
parent fe3ac8e5
Loading
Loading
Loading
Loading
+18 −18
Original line number Diff line number Diff line
@@ -396,10 +396,10 @@ 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"