| #!/bin/bash |
| |
| if [[ "$1" == "-h" ]];then |
| echo "Usage for script $0:" |
| echo " - $0. The command without parameter means that config jsons are generated by modifying testing configuration of odtn app" |
| echo " - $0 {dev-abs-path} {link-abs-path} {net-summary}. The command means use specified device config and link config directly." |
| fi |
| |
| if [[ $# == 0 ]];then |
| # Get first IPv4 Address on local machine, even the machine has lots of NICs. |
| localIP=`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" | head -n1` |
| mkdir /tmp/odtn |
| # Replace IP address in openconfig json files with real ones. |
| 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 |
| 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 |
| cp ${HOME}/emulator/net-summary.json /tmp/odtn/net-summary.json |
| sleep 30 |
| elif [[ $# == 3 ]];then |
| mkdir /tmp/odtn |
| cp $1 /tmp/odtn/openconfig-devices.json |
| cp $2 /tmp/odtn/openconfig-device-link.json |
| cp $3 /tmp/odtn/net-summary.json |
| fi |