BjornMagnussonXA | 37d3785 | 2019-10-15 08:42:08 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | echo "Usage: populate.sh [<host:port>]" |
| 4 | |
| 5 | HOST_PORT="localhost:8080" |
| 6 | |
| 7 | if [ $# == 1 ]; then |
| 8 | echo "Setting host and port from cmd line: "$1 |
| 9 | HOST_PORT=$1 |
| 10 | fi |
| 11 | |
| 12 | echo "=======================================" |
| 13 | echo "Using host and port:" $HOST_PORT |
| 14 | echo "=======================================" |
| 15 | |
| 16 | |
| 17 | PT_MAX=10 |
| 18 | PI_MAX=20 |
| 19 | PI_ID=0 |
| 20 | pt=0 |
| 21 | while [ $pt -lt $PT_MAX ]; do |
| 22 | pi=0 |
| 23 | PATTERN="s/XXXX/${pt}/g" |
| 24 | sed $PATTERN pt-template.json > .tmp.json |
| 25 | curl -v -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'$HOST_PORT'/a1-p/policytypes/'$pt |
| 26 | while [ $pi -lt $PI_MAX ]; do |
| 27 | echo $pt"--"$pi"-"$PI_ID |
| 28 | |
| 29 | PATTERN="s/XXXX/${PI_ID}/g" |
| 30 | sed $PATTERN pi-template.json > .tmp.json |
| 31 | curl -v -X PUT --header 'Content-Type: application/json' --header 'Accept: */*' -d @.tmp.json 'http://'$HOST_PORT'/a1-p/policytypes/'$pt'/policies/'$PI_ID |
| 32 | let pi=pi+1 |
| 33 | let PI_ID=PI_ID+1 |
| 34 | done |
| 35 | let pt=pt+1 |
| 36 | done |
| 37 | |
| 38 | curl -v --header 'Accept: application/json' 'http://'$HOST_PORT'/a1-p/policytypes/' |
| 39 | curl -v --header 'Accept: application/json' 'http://'$HOST_PORT'/a1-p/policytypes/1/policies' |