- if1_adj_mac, if2_adj_mac = if2_adj_mac, if1_adj_mac
- self._ifaces_reordered = 1
-
- if1_mac_hex = "0x"+if1_mac.replace(":", ",0x")
- if2_mac_hex = "0x"+if2_mac.replace(":", ",0x")
- if1_adj_mac_hex = "0x"+if1_adj_mac.replace(":", ",0x")
- if2_adj_mac_hex = "0x"+if2_adj_mac.replace(":", ",0x")
-
- (ret, stdout, stderr) = ssh.exec_command(
- "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
- "- port_limit : 2\n"
- " version : 2\n"
- " interfaces : [\"{}\",\"{}\"]\n"
- " port_bandwidth_gb : 10\n"
- " port_info :\n"
- " - dest_mac : [{}]\n"
- " src_mac : [{}]\n"
- " - dest_mac : [{}]\n"
- " src_mac : [{}]\n"
- "EOF'"\
- .format(if1_pci, if2_pci,
- if1_adj_mac_hex, if1_mac_hex,
- if2_adj_mac_hex, if2_mac_hex))
- if int(ret) != 0:
- logger.error("failed to create t-rex config: {}"\
- .format(stdout + stderr))
- raise RuntimeError('trex config generation error')
-
- (ret, stdout, stderr) = ssh.exec_command(
- "sh -c 'cd {0}/scripts/ && "
- "sudo ./trex-cfg'"\
- .format(trex_path))
- if int(ret) != 0:
- logger.error('trex-cfg failed: {0}'.format(stdout + stderr))
- raise RuntimeError('trex-cfg failed')
-
- (ret, _, _) = ssh.exec_command(
- "sh -c 'cd {0}/scripts/ && "
- "sudo nohup ./t-rex-64 -i -c 4 --iom 0 > /dev/null 2>&1 &'"
- "> /dev/null"\
- .format(trex_path))
+ if1_addr, if2_addr = if2_addr, if1_addr
+ if1_adj_addr, if2_adj_addr = if2_adj_addr, if1_adj_addr
+ self._ifaces_reordered = True
+
+ if test_type == 'L2' or test_type == 'L3':
+ (ret, _, _) = ssh.exec_command(
+ "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
+ "- port_limit: 2\n"
+ " version: 2\n"
+ " interfaces: [\"{0}\",\"{1}\"]\n"
+ " port_info:\n"
+ " - dest_mac: [{2}]\n"
+ " src_mac: [{3}]\n"
+ " - dest_mac: [{4}]\n"
+ " src_mac: [{5}]\n"
+ "EOF'"\
+ .format(if1_pci, if2_pci,
+ "0x"+if1_adj_addr.replace(":", ",0x"),
+ "0x"+if1_addr.replace(":", ",0x"),
+ "0x"+if2_adj_addr.replace(":", ",0x"),
+ "0x"+if2_addr.replace(":", ",0x")))
+ elif test_type == 'L7':
+ (ret, _, _) = ssh.exec_command(
+ "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
+ "- port_limit: 2\n"
+ " version: 2\n"
+ " interfaces: [\"{0}\",\"{1}\"]\n"
+ " port_info:\n"
+ " - ip: [{2}]\n"
+ " default_gw: [{3}]\n"
+ " - ip: [{4}]\n"
+ " default_gw: [{5}]\n"
+ "EOF'"\
+ .format(if1_pci, if2_pci,
+ if1_addr, if1_adj_addr,
+ if2_addr, if2_adj_addr))
+ else:
+ raise ValueError("Unknown Test Type")