aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/VIM/OpenStack/CI/libraries/check_os.sh
blob: 1327eff5f618a1ae82d21a86eb1401d5831ea497 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
#
# Simple script to check the basic OpenStack clients
#
# Author:
#    jose.lausuch@ericsson.com
#

verify_connectivity() {
    for i in $(seq 0 10); do
        if echo "test" | nc -v $1 $2 &>/dev/null; then
            return 0
        fi
        sleep 1
    done
    return 1
}


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 endpoints:"
publicURL=$OS_AUTH_URL
publicIP=$(echo $publicURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
publicPort=$(echo $publicURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..."
verify_connectivity $publicIP $publicPort
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
    echo "ERROR: Cannot talk to the public endpoint publicIP:$publicPort ."
    echo "OS_AUTH_URL=$OS_AUTH_URL"
    exit 1
fi
echo "  ...OK"

adminURL=$(keystone catalog --service identity 2>/dev/null|grep adminURL|awk '{print $4}')
adminIP=$(echo $adminURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..."
verify_connectivity $adminIP $adminPort
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
    echo "ERROR: Cannot talk to the admin endpoint adminIP:$adminPort ."
    echo "adminURL"
    exit 1
fi
echo "  ...OK"


echo "Checking OpenStack basic services:"
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."

echo "Checking External network..."
networks=($(neutron net-list | tail -n +4 | head -n -1 | awk '{print $2}'))
is_external=False
for net in "${networks[@]}"
do
    is_external=$(neutron net-show $net|grep "router:external"|awk '{print $4}')
    if [ $is_external == "True" ]; then
        echo "External network found: $net"
        break
    fi
done
if [ $is_external == "False" ]; then
    echo "ERROR: There are no external networks in the deployment."
    exit 1
fi


# Temporary output information
# To see the initial OpenStack defaults
# in case we delete something later on.
# This is to be removed for the release
echo "nova list:"
nova list
echo "cinder list"
cinder list
echo "nova floating-ip-list:"
nova floating-ip-list
echo "neutron net-list:"
neutron net-list
echo "neutron router-list:"
neutron router-list
echo "neutron security-group-list:"
neutron security-group-list
echo "keystone tenant-list:"
keystone tenant-list
echo "keystone user-list:"
keystone user-list

exit 0