Use common method name and parameters for calling subprocesses for local (Target) and remote systems (Initiators) instead of using "check_output" (from subprocess module) and "exec_command" (from paramiko) separately. Having these functions wrapped by a single common method will allow to create common methods in Server class more eaisly, instead of creating two copies in Target and Initiator classes. Signed-off-by: Karol Latecki <karol.latecki@intel.com> Change-Id: I1c10f6a88f3d7300c227e969ad6fd901763ac52c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6261 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Michal Berger <michalx.berger@intel.com> Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import os
|
|
import re
|
|
import json
|
|
from itertools import product, chain
|
|
from subprocess import check_output, CalledProcessError, Popen
|
|
|
|
|
|
def get_used_numa_nodes():
|
|
used_numa_nodes = set()
|
|
for bdf in get_nvme_devices_bdf():
|
|
with open("/sys/bus/pci/devices/%s/numa_node" % bdf, "r") as numa_file:
|
|
output = numa_file.read()
|
|
used_numa_nodes.add(int(output))
|
|
return used_numa_nodes
|
|
|
|
|
|
def get_nvme_devices_count():
|
|
output = get_nvme_devices_bdf()
|
|
return len(output)
|
|
|
|
|
|
def get_nvme_devices_bdf():
|
|
print("Getting BDFs for NVMe section")
|
|
output = check_output("rootdir=$PWD; \
|
|
source test/common/autotest_common.sh; \
|
|
get_nvme_bdfs 01 08 02",
|
|
executable="/bin/bash", shell=True)
|
|
output = [str(x, encoding="utf-8") for x in output.split()]
|
|
print("Done getting BDFs")
|
|
return output
|
|
|
|
|
|
def get_nvme_devices():
|
|
print("Getting kernel NVMe names")
|
|
output = check_output("lsblk -o NAME -nlp", shell=True).decode(encoding="utf-8")
|
|
output = [x for x in output.split("\n") if "nvme" in x]
|
|
print("Done getting kernel NVMe names")
|
|
return output
|
|
|
|
|
|
def nvmet_command(nvmet_bin, command):
|
|
return check_output("%s %s" % (nvmet_bin, command), shell=True).decode(encoding="utf-8")
|