Boyuan Yan | 1c27bc7 | 2019-02-15 19:22:19 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Boyuan Yan | 36231d2 | 2019-04-09 18:38:23 +0000 | [diff] [blame] | 3 | if [[ "$1" == "-h" ]];then |
| 4 | echo "Usage for script $0:" |
| 5 | echo " - $0. The command without parameter means that config jsons are generated by modifying testing configuration of odtn app" |
| 6 | echo " - $0 {dev-abs-path} {link-abs-path} {net-summary}. The command means use specified device config and link config directly." |
| 7 | fi |
| 8 | |
| 9 | if [[ $# == 0 ]];then |
| 10 | # Get first IPv4 Address on local machine, even the machine has lots of NICs. |
| 11 | localIP=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" | head -n1` |
| 12 | mkdir /tmp/odtn |
| 13 | # Replace IP address in openconfig json files with real ones. |
| 14 | cat ${ONOS_ROOT}/apps/odtn/api/src/test/resources/openconfig-devices.json | sed "s/127.0.0.1/${localIP}/g" > /tmp/odtn/openconfig-devices.json |
| 15 | cat ${ONOS_ROOT}/apps/odtn/api/src/test/resources/openconfig-device-link.json | sed "s/127.0.0.1/${localIP}/g" > /tmp/odtn/openconfig-device-link.json |
| 16 | cp ${HOME}/emulator/net-summary.json /tmp/odtn/net-summary.json |
| 17 | sleep 30 |
| 18 | elif [[ $# == 3 ]];then |
| 19 | mkdir /tmp/odtn |
| 20 | cp $1 /tmp/odtn/openconfig-devices.json |
| 21 | cp $2 /tmp/odtn/openconfig-device-link.json |
| 22 | cp $3 /tmp/odtn/net-summary.json |
| 23 | fi |