summaryrefslogtreecommitdiffstats
path: root/testcases/VIM/OpenStack/CI/libraries/check_os.sh
blob: 09d98343460e84f723391ed754bb9171fb3203f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# Simple script to check the basic OpenStack clients
#
# Author:
#    jose.lausuch@ericsson.com
#

if [ -z $OS_AUTH_URL ];then
    echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?"
    exit 1
fi

echo "Checking OpenStack basic services:"

ip=$(echo $OS_AUTH_URL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
ip='192.168.123.123'
echo ">>Pinging public keystone endpoint $ip..."
timeout=5
for i in `seq 1 $timeout`; do
    ping -q -c 1 $ip &>/dev/null
    RETVAL=$?
    if [ $RETVAL -eq 0 ]; then
        break
    fi
done
if [ $i -eq $timeout ]; then
    echo "ERROR: Cannot ping the endpoint $ip defined as env variable OS_AUTH_URL."
    echo "OS_AUTH_URL=$OS_AUTH_URL"
    exit 1
fi
echo "  ...OK"

commands=('keystone endpoint-list' 'nova list' 'neutron net-list' \
            'glance image-list' 'cinder list')
for cmd in "${commands[@]}"
do
    service=$(echo $cmd | awk '{print $1}')
    echo ">>Checking $service service..."
    $cmd &>/dev/null
    result=$?
    if [ $result -ne 0 ];
    then

        echo "ERROR: Failed execution $cmd. The $service does not seem to be working."
        exit 1
    else
        echo "  ...OK"
    fi
done

echo "OpenStack services are OK."
exit 0