Merge "auto restart influxdb and grafana support"
[yardstick.git] / tests / ci / clean_images.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB, Huawei Technologies Co.,Ltd and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 # Clean the images and flavor before running yardstick test suites.
12
13 cleanup()
14 {
15     echo
16     echo "========== Cleanup =========="
17
18     if [ $OS_CACERT ] && [ "$(echo $OS_CACERT | tr '[:upper:]' '[:lower:]')" = "false" ]; then
19         SECURE="--insecure"
20     else
21         SECURE=""
22     fi
23
24     if ! openstack "${SECURE}" image list; then
25         return
26     fi
27
28     for image in $(openstack "${SECURE}" image list | grep -e cirros-0.3.5 -e yardstick-image -e Ubuntu-16.04 \
29         | awk '{print $2}'); do
30         echo "Deleting image $image..."
31         openstack "${SECURE}" image delete $image || true
32     done
33
34     openstack "${SECURE}" flavor delete yardstick-flavor &> /dev/null || true
35     openstack "${SECURE}" flavor delete storperf &> /dev/null || true
36 }
37
38 main()
39 {
40     cleanup
41 }
42
43 main