Committed by
Gerrit Code Review
Support validate JSON file in onos-netcfg
Validate network configuration is JSON format before POST Change-Id: I6538bba27252c2c06f387804dabe15542988bfa1
Showing
1 changed file
with
5 additions
and
0 deletions
... | @@ -17,6 +17,11 @@ url="${3}" | ... | @@ -17,6 +17,11 @@ url="${3}" |
17 | method="POST" | 17 | method="POST" |
18 | [ $file == "delete" ] && method="DELETE" | 18 | [ $file == "delete" ] && method="DELETE" |
19 | 19 | ||
20 | +# Validate JSON | ||
21 | +if [ $method == "POST" ]; then | ||
22 | + cat $file | python -m json.tool >> /dev/null || echo "Not valid JSON File"; exit 1 | ||
23 | +fi | ||
24 | + | ||
20 | curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \ | 25 | curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \ |
21 | -X $method -H 'Content-Type:application/json' \ | 26 | -X $method -H 'Content-Type:application/json' \ |
22 | http://$node:8181/onos/v1/network/configuration/${url} -d@$file | 27 | http://$node:8181/onos/v1/network/configuration/${url} -d@$file | ... | ... |
-
Please register or login to post a comment