Update release notes with arm results
[functest.git] / ci / check_os.sh
1 #!/bin/bash
2 #
3 # Simple script to check the basic OpenStack clients
4 #
5 # Author:
6 #    jose.lausuch@ericsson.com
7 #
8
9 verify_connectivity() {
10     for i in $(seq 0 9); do
11         if echo "test" | nc -v -w 10 $1 $2 &>/dev/null; then
12             return 0
13         fi
14         sleep 1
15     done
16     return 1
17 }
18
19
20 if [ -z $OS_AUTH_URL ];then
21     echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?"
22     exit 1
23 fi
24
25
26 echo "Checking OpenStack endpoints:"
27 publicURL=$OS_AUTH_URL
28 publicIP=$(echo $publicURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
29 publicPort=$(echo $publicURL|sed 's/^.*://'|sed 's/\/.*$//')
30 echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..."
31 verify_connectivity $publicIP $publicPort
32 RETVAL=$?
33 if [ $RETVAL -ne 0 ]; then
34     echo "ERROR: Cannot talk to the public endpoint $publicIP:$publicPort ."
35     echo "OS_AUTH_URL=$OS_AUTH_URL"
36     exit 1
37 fi
38 echo "  ...OK"
39
40 adminURL=$(openstack catalog show  identity |grep adminURL|awk '{print $4}')
41 adminIP=$(echo $adminURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
42 adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
43 echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..."
44 verify_connectivity $adminIP $adminPort
45 RETVAL=$?
46 if [ $RETVAL -ne 0 ]; then
47     echo "ERROR: Cannot talk to the admin endpoint $adminIP:$adminPort ."
48     echo "$adminURL"
49     exit 1
50 fi
51 echo "  ...OK"
52
53
54 echo "Checking OpenStack basic services:"
55 commands=('openstack endpoint list' 'nova list' 'neutron net-list' \
56             'glance image-list' 'cinder list')
57 for cmd in "${commands[@]}"
58 do
59     service=$(echo $cmd | awk '{print $1}')
60     echo ">>Checking $service service..."
61     $cmd &>/dev/null
62     result=$?
63     if [ $result -ne 0 ];
64     then
65         echo "ERROR: Failed execution $cmd. The $service does not seem to be working."
66         exit 1
67     else
68         echo "  ...OK"
69     fi
70 done
71
72 echo "OpenStack services are OK."
73
74 echo "Checking External network..."
75 networks=($(neutron net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}'))
76 is_external=False
77 for net in "${networks[@]}"
78 do
79     is_external=$(neutron net-show $net|grep "router:external"|awk '{print $4}')
80     if [ $is_external == "True" ]; then
81         echo "External network found: $net"
82         break
83     fi
84 done
85 if [ $is_external == "False" ]; then
86     echo "ERROR: There are no external networks in the deployment."
87     exit 1
88 fi
89
90 exit 0