Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | if [[ -z ${token+x} ]]; then |
| 3 | export token=$(openstack token issue -c id -f value) |
| 4 | echo "# Exported token: ${token}" |
| 5 | fi |
| 6 | if [[ -z ${project_id+x} ]]; then |
| 7 | export project_id=$(openstack project list -c ID -c Name -f value | grep ${OS_PROJECT_NAME} | cut -d' ' -f1) |
| 8 | echo "# Exported project_id: ${project_id}" |
| 9 | fi |
Alex | c7f187c | 2022-04-28 10:02:27 -0500 | [diff] [blame] | 10 | #poke_uri=$(echo ${1/project_id/$project_id}) |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 11 | |
| 12 | function ppoke { |
Alex | c7f187c | 2022-04-28 10:02:27 -0500 | [diff] [blame] | 13 | rr=$(curl -sSH "X-Auth-Token: ${token}" $1 2>&1) |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 14 | if [[ $? != 0 ]]; then |
Alex | c7f187c | 2022-04-28 10:02:27 -0500 | [diff] [blame] | 15 | printf "[$(date +'%H:%M:%S')] -> $1\nError: $rr\n\n" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 16 | else |
Alex | c7f187c | 2022-04-28 10:02:27 -0500 | [diff] [blame] | 17 | printf "[$(date +'%H:%M:%S')] -> '$1', $(echo $rr | wc -c) bytes\n" |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 18 | fi |
| 19 | } |
| 20 | |
Alex | c7f187c | 2022-04-28 10:02:27 -0500 | [diff] [blame] | 21 | cc=${2}; |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 22 | while [[ $cc -gt 0 ]]; do |
| 23 | cat $1 | while read svc; do |
Alex | c7f187c | 2022-04-28 10:02:27 -0500 | [diff] [blame] | 24 | ppoke $svc; |
Alex | b00fee1 | 2022-02-17 14:20:04 -0600 | [diff] [blame] | 25 | done |
| 26 | (( cc -= 1 )); |
| 27 | echo "$cc to go"; |
| 28 | sleep 0.1; |
| 29 | done |