Support validate JSON file in onos-netcfg
Validate network configuration is JSON format before POST
Change-Id: I6538bba27252c2c06f387804dabe15542988bfa1
diff --git a/tools/test/bin/onos-netcfg b/tools/test/bin/onos-netcfg
index 6f49052..1cad92d 100755
--- a/tools/test/bin/onos-netcfg
+++ b/tools/test/bin/onos-netcfg
@@ -17,6 +17,11 @@
method="POST"
[ $file == "delete" ] && method="DELETE"
+# Validate JSON
+if [ $method == "POST" ]; then
+ cat $file | python -m json.tool >> /dev/null || echo "Not valid JSON File"; exit 1
+fi
+
curl $fail -sSL --user $ONOS_WEB_USER:$ONOS_WEB_PASS \
-X $method -H 'Content-Type:application/json' \
http://$node:8181/onos/v1/network/configuration/${url} -d@$file