fix flake8 tests
[osm/NBI.git] / osm_nbi / tests / delete-all.sh
diff --git a/osm_nbi/tests/delete-all.sh b/osm_nbi/tests/delete-all.sh
new file mode 100755 (executable)
index 0000000..d8cb474
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/bash
+
+export NBI_URL=https://localhost:9999/osm
+USERNAME=admin
+PASSWORD=admin
+PROJECT=admin
+
+
+
+#get token
+TOKEN=`curl --insecure -H "Content-Type: application/yaml" -H "Accept: application/yaml"  --data "{username: $USERNAME, password: $PASSWORD, project_id: $PROJECT}" ${NBI_URL}/admin/v1/tokens 2>/dev/null | awk '($1=="id:"){print $2}' ` ; echo $TOKEN
+
+
+echo  deleting all
+#DELETE ALL
+
+for url_item in nslcm/v1/ns_instances nsd/v1/ns_descriptors_content vnfpkgm/v1/vnf_packages_content
+do
+    for ITEM_ID in `curl --insecure -w "%{http_code}\n" -H "Content-Type: application/yaml" -H "Accept: application/yaml" -H "Authorization: Bearer $TOKEN"  ${NBI_URL}/${url_item} 2>/dev/null | awk '($1=="_id:") {print $2}'` ;
+    do
+        curl --insecure -w "%{http_code}\n" -H "Content-Type: application/yaml" -H "Accept: application/yaml" -H "Authorization: Bearer $TOKEN"  ${NBI_URL}/${url_item}/$ITEM_ID -X DELETE
+    done
+done
+
+# curl --insecure  ${NBI_URL}/test/prune
+