scripts/nvmf_perf: get detailed info about NICs in servers

Get detailed info about NICs installed in servers. This
is using lshw utility to make things easier and not
implement the whole logic for parsing /sys objects and
pci.ids listing in system.

Change-Id: I97871fdc9feaae1c2485574a7b488b88ac3afc4f
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6259
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>
This commit is contained in:
Karol Latecki 2021-02-02 12:13:43 +01:00 committed by Tomasz Zawadzki
parent 9fec8853fb
commit ddb4d24b1d

View File

@ -28,6 +28,7 @@ class Server:
self.transport = general_config["transport"].lower()
self.nic_ips = server_config["nic_ips"]
self.mode = server_config["mode"]
self.local_nic_info = []
self._nics_json_obj = {}
if not re.match("^[A-Za-z0-9]*$", name):
@ -49,6 +50,24 @@ class Server:
if ip in addr["local"]:
return nic["ifname"]
def set_local_nic_info_helper(self):
pass
def set_local_nic_info(self, pci_info):
def extract_network_elements(json_obj):
nic_list = []
if isinstance(json_obj, list):
for x in json_obj:
nic_list.extend(extract_network_elements(x))
elif isinstance(json_obj, dict):
if "children" in json_obj:
nic_list.extend(extract_network_elements(json_obj["children"]))
if "class" in json_obj.keys() and "network" in json_obj["class"]:
nic_list.append(json_obj)
return nic_list
self.local_nic_info = extract_network_elements(pci_info)
class Target(Server):
def __init__(self, name, general_config, target_config):
@ -91,8 +110,12 @@ class Target(Server):
self.script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
self.spdk_dir = os.path.abspath(os.path.join(self.script_dir, "../../../"))
self.set_local_nic_info(self.set_local_nic_info_helper())
self.sys_config()
def set_local_nic_info_helper(self):
return json.loads(check_output(["lshw", "-json"]))
def zip_spdk_sources(self, spdk_dir, dest_file):
self.log_print("Zipping SPDK source directory")
fh = zipfile.ZipFile(dest_file, "w", zipfile.ZIP_DEFLATED)
@ -373,9 +396,13 @@ class Initiator(Server):
self.remote_call("sudo rm -rf %s/nvmf_perf" % self.spdk_dir)
self.remote_call("mkdir -p %s" % self.spdk_dir)
self._nics_json_obj = json.loads(self.remote_call("ip -j address show")[0])
self.set_local_nic_info(self.set_local_nic_info_helper())
self.set_cpu_frequency()
self.sys_config()
def set_local_nic_info_helper(self):
return json.loads(self.remote_call("lshw -json")[0])
def __del__(self):
self.ssh_connection.close()