- 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, _, _) = ssh.exec_command(
- "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
- "- port_limit : 2\n"
- " version : 2\n"
- " interfaces : [\"{}\",\"{}\"]\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 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")