lisp_ip4.sh revision 676362e1
1#!/usr/bin/env bash
2
3function ping_lisp {
4  local RESULTS
5  RESULTS=$(ssh_tg "ping -c 10 6.0.2.2")
6  if [ $? -ne 0 ] ; then
7      echo "Can not ping other machine"
8      ssh_vpp1 "sudo rm -r ${TMP_DIR}"
9      ssh_vpp2 "sudo rm -r ${TMP_DIR}"
10      exit -1
11  fi
12}
13
14curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:add-mapping \
15     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${ODL_ADD_CONFIG1}" \
16     -u ${ODL_USER}:${ODL_PASSWD}
17curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:add-mapping \
18     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${ODL_ADD_CONFIG2}" \
19     -u ${ODL_USER}:${ODL_PASSWD}
20
21rsync -avz ${VPP_CONFIG_DIR}${VPP_CONFIG1}  ${USER}@${VPP1_IP}:${TMP_DIR}/vpp1.conf
22rsync -avz ${VPP_CONFIG_DIR}${VPP_CONFIG2}  ${USER}@${VPP2_IP}:${TMP_DIR}/vpp2.conf
23
24ssh_vpp1 "sudo vpp_api_test < ${TMP_DIR}/vpp1.conf"
25ssh_vpp2 "sudo vpp_api_test < ${TMP_DIR}/vpp2.conf"
26
27ssh_tg "sudo ip addr add 6.0.1.2/24 dev ${TG_INT1}"
28ssh_tg "sudo ip link set ${TG_INT1} up"
29ssh_tg "sudo ip route add 6.0.2.0/24 via 6.0.1.1"
30ssh_tg "sudo ip netns exec net2 ip addr add 6.0.2.2/24 dev ${TG_INT2}"
31ssh_tg "sudo ip netns exec net2 ip link set lo up"
32ssh_tg "sudo ip netns exec net2 ip link set ${TG_INT2} up"
33ssh_tg "sudo ip netns exec net2 ip route add 6.0.1.0/24 via 6.0.2.1"
34
35ping_lisp
36
37rsync -avz ${VPP_CONFIG_DIR}${VPP_RECONF2}  ${USER}@${VPP2_IP}:${TMP_DIR}/vpp2_reconf.conf
38
39ssh_vpp2 "sudo vpp_api_test < ${TMP_DIR}/vpp2_reconf.conf"
40
41curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:update-mapping \
42     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${ODL_REPLACE_CONFIG2}" \
43     -u ${ODL_USER}:${ODL_PASSWD}
44
45ping_lisp
46