- loc_i_key = 'set interface ipsec key {0} local integ {1} ' \
- '{2}\n'.format(if_s, integ_alg.alg_name, ikey)
- tmp_f1.write(loc_i_key)
- tmp_f2.write(loc_i_key)
- rem_i_key = 'set interface ipsec key {0} remote integ {1}' \
- ' {2}\n'.format(if_s, integ_alg.alg_name, ikey)
- tmp_f1.write(rem_i_key)
- tmp_f2.write(rem_i_key)
- raddr_ip1_s = ip_address(raddr_ip1_i + addr_incr*i)
- raddr_ip2_s = ip_address(raddr_ip2_i + addr_incr*i)
- dut1_rte_s = 'ip route add {0}/{1} via {2} {3}\n'.format(
- raddr_ip2_s, raddr_range, if2_ip_addr, if_s)
- tmp_f1.write(dut1_rte_s)
- dut2_rte_s = 'ip route add {0}/{1} via {2} {3}\n'.format(
- raddr_ip1_s, raddr_range, if1_ip_addr, if_s)
- tmp_f2.write(dut2_rte_s)
+ integ = 'integ_alg {integ_alg} '\
+ 'local_integ_key {local_integ_key} '\
+ 'remote_integ_key {remote_integ_key} '\
+ .format(integ_alg=integ_alg.alg_name,
+ local_integ_key=ikey,
+ remote_integ_key=ikey)
+ dut1_tunnel = 'ipsec_tunnel_if_add_del '\
+ 'local_spi {local_spi} '\
+ 'remote_spi {remote_spi} '\
+ 'crypto_alg {crypto_alg} '\
+ 'local_crypto_key {local_crypto_key} '\
+ 'remote_crypto_key {remote_crypto_key} '\
+ '{integ} '\
+ 'local_ip {local_ip} '\
+ 'remote_ip {remote_ip}\n'\
+ .format(local_spi=spi_1+i,
+ remote_spi=spi_2+i,
+ crypto_alg=crypto_alg.alg_name,
+ local_crypto_key=ckey,
+ remote_crypto_key=ckey,
+ integ=integ,
+ local_ip=if1_ip_addr,
+ remote_ip=if2_ip_addr)
+ dut2_tunnel = 'ipsec_tunnel_if_add_del '\
+ 'local_spi {local_spi} '\
+ 'remote_spi {remote_spi} '\
+ 'crypto_alg {crypto_alg} '\
+ 'local_crypto_key {local_crypto_key} '\
+ 'remote_crypto_key {remote_crypto_key} '\
+ '{integ} '\
+ 'local_ip {local_ip} '\
+ 'remote_ip {remote_ip}\n'\
+ .format(local_spi=spi_2+i,
+ remote_spi=spi_1+i,
+ crypto_alg=crypto_alg.alg_name,
+ local_crypto_key=ckey,
+ remote_crypto_key=ckey,
+ integ=integ,
+ local_ip=if2_ip_addr,
+ remote_ip=if1_ip_addr)
+ tmp_f1.write(dut1_tunnel)
+ tmp_f2.write(dut2_tunnel)
+ vat.execute_script(tmp_fn1, node1, timeout=300, json_out=False,
+ copy_on_execute=True)
+ vat.execute_script(tmp_fn2, node2, timeout=300, json_out=False,
+ copy_on_execute=True)
+ os.remove(tmp_fn1)
+ os.remove(tmp_fn2)
+
+ with open(tmp_fn1, 'w') as tmp_f1, open(tmp_fn2, 'w') as tmp_f2:
+ for i in range(0, n_tunnels):
+ raddr_ip1 = ip_address(raddr_ip1_i + addr_incr*i)
+ raddr_ip2 = ip_address(raddr_ip2_i + addr_incr*i)