Phil Huang
Committed by Gerrit Code Review

Fixed JSON validator and `DELETE` not work issue in onos-netcfg

1. Supprot handle upper case DELETE and fixed DELETE funcion
2. Fixed `POST` can not work if JSON format is correct

Change-Id: I762cb73ce73a42393264dcace1beaf5cf53492f7
...@@ -15,13 +15,18 @@ file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}" ...@@ -15,13 +15,18 @@ file="${2:-$ONOS_ROOT/tools/test/topos/oe-linear-3.json}"
15 url="${3}" 15 url="${3}"
16 16
17 method="POST" 17 method="POST"
18 -[ $file == "delete" ] && method="DELETE" 18 +[ $(echo $file | awk '{print tolower($0)}') == "delete" ] && method="DELETE"
19 19
20 -# Validate JSON
21 if [ $method == "POST" ]; then 20 if [ $method == "POST" ]; then
22 - cat $file | python -m json.tool >> /dev/null || echo "Not valid JSON File"; exit 1 21 + # Validate JSON
22 + cat $file | python -m json.tool >> /dev/null
23 + if [ "$?" -ne "0" ]; then
24 + echo "Not valid JSON File" && exit 1
25 + fi
26 + curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
27 + -X POST -H 'Content-Type:application/json' \
28 + http://$node:8181/onos/v1/network/configuration/${url} -d@$file
29 +elif [ $method == "DELETE" ]; then
30 + curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
31 + -X DELETE http://$node:8181/onos/v1/network/configuration/${url}
23 fi 32 fi
24 -
25 -curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
26 - -X $method -H 'Content-Type:application/json' \
27 - http://$node:8181/onos/v1/network/configuration/${url} -d@$file
......