+ ssh.connect(tg_node)
+
+ if1_pci = topo.get_interface_pci_addr(tg_node, tg_if1)
+ if2_pci = topo.get_interface_pci_addr(tg_node, tg_if2)
+ if1_mac = topo.get_interface_mac(tg_node, tg_if1)
+ if2_mac = topo.get_interface_mac(tg_node, tg_if2)
+
+ if test_type == 'L2':
+ if1_adj_mac = if2_mac
+ if2_adj_mac = if1_mac
+ elif test_type == 'L3':
+ if1_adj_mac = topo.get_interface_mac(dut1_node, dut1_if1)
+ if2_adj_mac = topo.get_interface_mac(dut2_node, dut2_if2)
+ else:
+ raise Exception("test_type unknown")
+
+ if min(if1_pci, if2_pci) != if1_pci:
+ if1_mac, if2_mac = if2_mac, if1_mac
+ if1_pci, if2_pci = if2_pci, if1_pci
+ 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_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')