blob: 378fee8620015a6963db5df269ad05776cdbff21 [file] [log] [blame]
BjornMagnussonXA37d37852019-10-15 08:42:08 +02001#!/bin/bash
2
3echo "Usage: populate.sh [<host:port>]"
4
5HOST_PORT="localhost:8080"
6
7if [ $# == 1 ]; then
8 echo "Setting host and port from cmd line: "$1
9 HOST_PORT=$1
10fi
11
12echo "======================================="
13echo "Using host and port:" $HOST_PORT
14echo "======================================="
15
16
17PT_MAX=10
18PI_MAX=20
19PI_ID=0
20pt=0
21while [ $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
36done
37
38curl -v --header 'Accept: application/json' 'http://'$HOST_PORT'/a1-p/policytypes/'
39curl -v --header 'Accept: application/json' 'http://'$HOST_PORT'/a1-p/policytypes/1/policies'