1
2function post_curl {
3  echo "Sending mapping from ${2} to ODL; operation: ${1}"
4  until [ "`curl -X POST "http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:${1}" \
5     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}/${2}" \
6     -u ${ODL_USER}:${ODL_PASSWD} -s -o /dev/null -w "%{http_code}"`" == "200" ]
7  do
8    echo "Updating failed; trying again.."
9  done
10}
11
12function odl_clear_all {
13  echo "Deleting all ODL mappings.."
14  curl -X DELETE "http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database" \
15       -u ${ODL_USER}:${ODL_PASSWD}
16  # TODO how to delete operational mappings?
17}
18
19function check_odl_running {
20  if [ -z  "`netstat -tunlp | grep 8181`" ] ; then
21  echo "ODL is not running!"
22    exit 1
23  fi
24}
25