14bf6318cSFilip Tehlar
24bf6318cSFilip Tehlarfunction post_curl {
34bf6318cSFilip Tehlar  echo "Sending mapping from ${2} to ODL; operation: ${1}"
44bf6318cSFilip Tehlar  until [ "`curl -X POST "http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:${1}" \
5bcae6baeSFilip Tehlar     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}/${2}" \
64bf6318cSFilip Tehlar     -u ${ODL_USER}:${ODL_PASSWD} -s -o /dev/null -w "%{http_code}"`" == "200" ]
74bf6318cSFilip Tehlar  do
84bf6318cSFilip Tehlar    echo "Updating failed; trying again.."
94bf6318cSFilip Tehlar  done
104bf6318cSFilip Tehlar}
114bf6318cSFilip Tehlar
124bf6318cSFilip Tehlarfunction odl_clear_all {
134bf6318cSFilip Tehlar  echo "Deleting all ODL mappings.."
144bf6318cSFilip Tehlar  curl -X DELETE "http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database" \
154bf6318cSFilip Tehlar       -u ${ODL_USER}:${ODL_PASSWD}
16d65394beSFilip Tehlar  # TODO how to delete operational mappings?
174bf6318cSFilip Tehlar}
184543d282SFlorin Coras
194543d282SFlorin Corasfunction check_odl_running {
204543d282SFlorin Coras  if [ -z  "`netstat -tunlp | grep 8181`" ] ; then
214543d282SFlorin Coras  echo "ODL is not running!"
224543d282SFlorin Coras    exit 1
234543d282SFlorin Coras  fi
244543d282SFlorin Coras}
25