Commit 78ce3152 authored by Karol Latecki's avatar Karol Latecki Committed by Tomasz Zawadzki
Browse files

scripts/nvmf_perf: add function to get interface names



Interface names will later be needed for additional
test options.

Change-Id: Ic16d305a97087ab1fdc35d5fd5a3d1ed2a021d90
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6206


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
parent c4a330c9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ class Server:
        self.nic_ips = nic_ips
        self.remote_nic_ips = remote_nic_ips
        self.transport = transport.lower()
        self._nics_json_obj = {}

        if not re.match("^[A-Za-z0-9]*$", name):
            self.log_print("Please use a name which contains only letters or numbers")
@@ -40,6 +41,15 @@ class Server:
    def get_uncommented_lines(self, lines):
        return [line for line in lines if line and not line.startswith('#')]

    def get_nic_name_by_ip(self, ip):
        if not self._nics_json_obj:
            nics_json_obj = self.exec_cmd(["ip", "-j", "address", "show"])
            self._nics_json_obj = list(filter(lambda x: x["addr_info"], json.loads(nics_json_obj)))
        for nic in self._nics_json_obj:
            for addr in nic["addr_info"]:
                if ip in addr["local"]:
                    return nic["ifname"]


class Target(Server):
    def __init__(self, name, username, password, mode, nic_ips, transport="rdma",
@@ -55,6 +65,7 @@ class Target(Server):
        self.enable_dpdk_memory = False
        self.enable_zcopy = False
        self.scheduler_name = scheduler_settings
        self._nics_json_obj = json.loads(check_output(["ip", "-j", "address", "show"]))

        if sar_settings:
            self.enable_sar, self.sar_delay, self.sar_interval, self.sar_count = sar_settings
@@ -340,6 +351,7 @@ class Initiator(Server):
        self.ssh_connection.connect(self.ip, username=self.username, password=self.password)
        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_cpu_frequency()
        self.sys_config()