def run_l3fwd(self, core_num): print("Starting l3fwd...") m = session.DirectSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) l3fwd_path = (self.config["path"]["dpdk_path"] + (self.config["pkg_list"])["dpdk_pkg"]).rsplit('.', 2)[0] l3fwd_bin_name = 'l3fwd' print("l3fwd_path: " + l3fwd_path + ", l3fwd_bin_name: " + l3fwd_bin_name) # ssh = paramiko.SSHClient() # ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # ssh.connect(hostname=server_config['server_info']['host_name'], port=server_config['server_info']['host_port'], username=server_config['server_info']['username'], password=server_config['server_info']['password']) # channel = ssh.invoke_shell() # self.pktgen_cli = session.PktgenSession(server_config['server_info']['host_name'], server_config['server_info']['host_port'], # server_config['server_info']['username'], server_config['server_info']['password']) execmd = "cd " + l3fwd_path + '/' + self.config["path"]["l3fwd_sub_path"] + "/build;" \ "export RTE_TARGET=" + self.config["server_info"]["rte_target"] + ";" \ "export RTE_SDK=" + l3fwd_path + ";" + \ "nohup ./" + l3fwd_bin_name + ' ' + \ self.cmdline[core_num] + "&" #" --parse-ptype &" print(execmd) self.shell_cli = session.ShellSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) # output = self.pktgen_cli.execute(execmd) # output = m.ShellSession(execmd) output = self.shell_cli.execute("scl enable devtoolset-7 bash") print(output) output = self.shell_cli.execute("gcc -v") print(output) output = self.shell_cli.execute(execmd) print(output)
def __init__(self, cfg_file): with open(cfg_file) as config_file: config_list = json.load(config_file) self.pktgen_cli = None for index in range(len(config_list)): server_config = config_list[index] if "xmit" == server_config["server_info"]["mode"]: self.config = config_list[index] print("Load flowgen configuration file success.") self.m = session.DirectSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) statistic_src_path = self.config["path"]["repo_path"] + ( self.config["pkg_list"])["eth_stat"] statistic_dst_path = self.config["path"]["tool_path"] self.m.sshclient_execmd("mkdir -p " + statistic_dst_path + ";" "cp " + statistic_src_path + " " + statistic_dst_path + ";" "chmod +rx " + statistic_dst_path + (self.config["pkg_list"])["eth_stat"]) self.df = pd.DataFrame(np.zeros( len(pkg_size_list) * len(core_list)).reshape( len(pkg_size_list), len(core_list)), index=pkg_size_list, columns=core_list)
def run_pktgen(self): print("Enable socket port 22022 on firewall...") m = session.DirectSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) m.sshclient_execmd("firewall-cmd --zone=public --add-port=22022/tcp --permanent") m.sshclient_execmd("firewall-cmd --reload") print("Set NIC to 40G mode...") mnlx_nics = m.sshclient_execmd("mst status -v | awk '/ConnectX/ { print $5 }'") print(mnlx_nics) # mnlx_nics_str = str(mnlx_nics) mnlx_nics_str = mnlx_nics.decode("utf-8") print(mnlx_nics_str) mnlx_nics = mnlx_nics_str.split("\n") print(mnlx_nics) while '' in mnlx_nics: mnlx_nics.remove('') for mnlx_nic in mnlx_nics: print(mnlx_nic) mnlx_nic_array = mnlx_nic.split('-') print("Set mnlx_nic: %s" % mnlx_nic_array[1]) m.sshclient_execmd("ethtool -s " + mnlx_nic_array[1] + " speed 40000 duplex full autoneg off") print("Starting pktgen...") # m = session.DirectSession(server_config['server_info']['host_name'], server_config['server_info']['host_port'], # server_config['server_info']['username'], server_config['server_info']['password']) # server_config = self.config_list[index] pktgen_path = (self.config["path"]["dpdk_path"] + (self.config["pkg_list"])["pktgen_pkg"]).rsplit('.', 2)[0] pktgen_bin_name = (self.config["pkg_list"])["pktgen_pkg"].rsplit('-', 1)[0] print("pktgen_path: " + pktgen_path + ", pktgen_bin_name: " + pktgen_bin_name) # ssh = paramiko.SSHClient() # ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # ssh.connect(hostname=server_config['server_info']['host_name'], port=server_config['server_info']['host_port'], username=server_config['server_info']['username'], password=server_config['server_info']['password']) # channel = ssh.invoke_shell() self.pktgen_cli = session.PktgenSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) execmd = "cd " + pktgen_path + ";" + "app/" + self.config["server_info"]["rte_target"] + "/" + pktgen_bin_name + " " + \ "-l 1-35 -n 6 -w 0000:01:00.0 -w 0004:01:00.0 --file-prefix pktgen_ -- -G -P --crc-strip -m [2:22-28].0 -m [3:29-33].1 -f themes/white-black.theme" print(execmd) output = self.pktgen_cli.execute(execmd) print(output)
def install_pkgs(self): m = session.DirectSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) # create sw installation folders dpdk_dst_path = self.config["path"]["dpdk_path"] mnlx_dst_path = self.config["path"]["mnlx_path"] m.sshclient_execmd("mkdir -p " + dpdk_dst_path) m.sshclient_execmd("mkdir -p " + mnlx_dst_path) dpdk_src_path = self.config["path"]["repo_path"] + (self.config["pkg_list"])["dpdk_pkg"] mnlx_src_path = self.config["path"]["repo_path"] + (self.config["pkg_list"])["ofed_pkg"] # extract packages m.sshclient_execmd("tar -zxf " + dpdk_src_path + " -C " + dpdk_dst_path) m.sshclient_execmd("tar -zxf " + mnlx_src_path + " -C " + mnlx_dst_path) # install mnlx_ofed 4.3 ofed_ver = None ofed_ver = m.sshclient_execmd("ofed_info -s") ofed_ver = str(ofed_ver, encoding="utf-8") #print("ofed_ver:"+ofed_ver) ofed_v43 = "MLNX_OFED_LINUX-4.3" #print("ofed_v43:" + ofed_v43) if ofed_v43 not in ofed_ver: print("Begin install OFED in " + self.config["server_info"]["mode"] + " server.") mnlx_dst_path = self.config["path"]["mnlx_path"]+(self.config["pkg_list"])["ofed_pkg"] mnlx_dst_path = mnlx_dst_path.rsplit('.', 1)[0] print(mnlx_dst_path) m.sshclient_execmd(mnlx_dst_path + "/mlnxofedinstall --dpdk --with-mlnx-ethtool --with-mft --with-mstflint --add-kernel-support --upstream-libs") else: print("Already installed OFED in " + self.config["server_info"]["mode"] + " server.") # compile dpdk package dpdk_dst_path = self.config["path"]["dpdk_path"]+(self.config["pkg_list"])["dpdk_pkg"] dpdk_dst_path = dpdk_dst_path.rsplit('.', 2)[0] print(dpdk_dst_path) m.sshclient_execmd("cd " + dpdk_dst_path + ";" "export RTE_TARGET=" + self.config["server_info"]["rte_target"] + ";" "make config T=${RTE_TARGET};" r"sed -ri 's,(LIBRTE_MLX5_PMD=).*,\1y,' build/.config;" "make -j24;" r"sed -i 's/\(CONFIG_RTE_LIBRTE_MLX5_PMD=\)n/\1y/g' config/common_base;" "make -j24 install T=${RTE_TARGET}") # patch l3fwd if 'l3fwd_patch' in self.config["pkg_list"]: # step 1: cp patch for l3fwd l3fwd_patch_path = self.config["path"]["repo_path"] + (self.config["pkg_list"])["l3fwd_patch"] dpdk_examples_path = dpdk_dst_path + "/examples/" m.sshclient_execmd("cp " + l3fwd_patch_path + " " + dpdk_examples_path) # step 2 patch patch file m.sshclient_execmd("cd " + dpdk_examples_path + ";" + "patch -p1 < " + (self.config["pkg_list"])["l3fwd_patch"]) # compile l3fwd dpdk_dst_path = self.config["path"]["dpdk_path"] + (self.config["pkg_list"])["dpdk_pkg"] dpdk_dst_path = dpdk_dst_path.rsplit('.', 2)[0] print(dpdk_dst_path) m.sshclient_execmd("cd " + dpdk_dst_path + ";" "export RTE_TARGET=" + self.config["server_info"]["rte_target"] + ";" "export RTE_SDK=" + dpdk_dst_path + ";" "make -C " + self.config["path"]["l3fwd_sub_path"])
def upload_pkgs(self): m = session.DirectSession(self.config['server_info']['host_name'], self.config['server_info']['host_port'], self.config['server_info']['username'], self.config['server_info']['password']) m.sync_sw_repo(self.config)