+ [[ -z "$OSM_USER" ]] && OSM_USER=admin
+ [[ -z "$OSM_PASSWORD" ]] && OSM_PASSWORD=admin
+ [[ -z "$OSM_PROJECT" ]] && OSM_PROJECT=admin
+
+ TOKEN=`curl --insecure -H "Content-Type: application/yaml" -H "Accept: application/yaml" \
+ --data "{username: '$OSM_USER', password: '$OSM_PASSWORD', project_id: '$OSM_PROJECT'}" \
+ ${OSMNBI_URL}/admin/v1/tokens 2>/dev/null | awk '($1=="_id:"){print $2}'`;
+ echo "TOKEN='$TOKEN'"
+
+ echo "delete users, prujects,roles. Ignore response errors due that own user,project cannot be deleted"
+ for topic in users projects roles
+ do
+ elements=`curl --insecure ${OSMNBI_URL}/admin/v1/$topic -H "Authorization: Bearer $TOKEN" \
+ -H "Accept: application/yaml" 2>/dev/null | awk '($1=="_id:"){print $2};($2=="_id:"){print $3}'`;
+ for element in $elements
+ do
+ # not needed to check if own user, project, etc; because OSM will deny deletion
+ echo deleting $topic _id=$element
+ curl --insecure ${OSMNBI_URL}/admin/v1/$topic/$element -H "Authorization: Bearer $TOKEN" \
+ -H "Accept: application/yaml" -X DELETE 2>/dev/null
+ done
+ done
+
+