Add docker-compose files and requirements
[releng.git] / jjb / yardstick / yardstick-cleanup.sh
1 #!/bin/bash
2 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
3
4 echo "Cleaning up docker containers/images..."
5 # Remove previous running containers if exist
6 if [[ ! -z $(docker ps -a | grep opnfv/yardstick) ]]; then
7     echo "Removing existing opnfv/yardstick containers..."
8     docker ps -a | grep opnfv/yardstick | awk '{print $1}' | xargs docker rm -f >$redirect
9
10 fi
11
12 # Remove existing images if exist
13 if [[ ! -z $(docker images | grep opnfv/yardstick) ]]; then
14     echo "Docker images to remove:"
15     docker images | head -1 && docker images | grep opnfv/yardstick
16     image_tags=($(docker images | grep opnfv/yardstick | awk '{print $2}'))
17     for tag in "${image_tags[@]}"; do
18         echo "Removing docker image opnfv/yardstick:$tag..."
19         docker rmi opnfv/yardstick:$tag >$redirect
20
21     done
22 fi