3 # Simple script to check the basic OpenStack clients
6 # jose.lausuch@ericsson.com
9 declare -A service_cmd_array
10 service_cmd_array['nova']='openstack server list'
11 service_cmd_array['neutron']='openstack network list'
12 service_cmd_array['keystone']='openstack endpoint list'
13 service_cmd_array['cinder']='openstack volume list'
14 service_cmd_array['glance']='openstack image list'
16 MANDATORY_SERVICES='nova neutron keystone glance'
17 OPTIONAL_SERVICES='cinder'
19 verify_connectivity() {
20 for i in $(seq 0 9); do
21 if echo "test" | nc -v -w 10 $1 $2 &>/dev/null; then
29 verify_SSL_connectivity() {
30 openssl s_client -connect $1:$2 &>/dev/null
37 cmd=${service_cmd_array[$service]}
43 echo ">>Checking ${service} service..."
44 if ! openstack service list | grep -i ${service} > /dev/null; then
45 if [ "$required" == 'false' ]; then
46 echo "WARN: Optional Service ${service} is not enabled!"
49 echo "ERROR: Required Service ${service} is not enabled!"
55 if [ $result -ne 0 ]; then
56 echo "ERROR: Failed execution $cmd. The $service does not seem to be working."
63 if [ -z $OS_AUTH_URL ];then
64 echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?"
69 echo "Checking OpenStack endpoints:"
70 publicURL=$(openstack catalog show identity |awk '/public/ {print $4}')
71 publicIP=$(echo $publicURL|sed 's/^.*http.*\:\/\///'|sed 's/.[^:]*$//')
72 publicPort=$(echo $publicURL|sed 's/^.*://'|sed 's/\/.*$//')
73 https_enabled=$(echo $publicURL | grep 'https')
74 if [[ -n $https_enabled ]]; then
75 echo ">>Verifying SSL connectivity to the public endpoint $publicIP:$publicPort..."
76 verify_SSL_connectivity $publicIP $publicPort
78 echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..."
79 verify_connectivity $publicIP $publicPort
82 if [ $RETVAL -ne 0 ]; then
83 echo "ERROR: Cannot talk to the public endpoint $publicIP:$publicPort ."
84 echo "OS_AUTH_URL=$OS_AUTH_URL"
89 adminURL=$(openstack catalog show identity |awk '/admin/ {print $4}')
90 if [ -z ${adminURL} ]; then
91 echo "ERROR: Cannot determine the admin URL."
92 openstack catalog show identity
95 adminIP=$(echo $adminURL|sed 's/^.*http.*\:\/\///'|sed 's/.[^:]*$//')
96 adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
97 https_enabled=$(echo $adminURL | grep 'https')
98 if [[ -n $https_enabled ]]; then
99 echo ">>Verifying SSL connectivity to the admin endpoint $adminIP:$adminPort..."
100 verify_SSL_connectivity $adminIP $adminPort
102 echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..."
103 verify_connectivity $adminIP $adminPort
106 if [ $RETVAL -ne 0 ]; then
107 echo "ERROR: Cannot talk to the admin endpoint $adminIP:$adminPort ."
114 echo "Checking Required OpenStack services:"
115 for service in $MANDATORY_SERVICES; do
116 check_service $service "true"
118 echo "Required OpenStack services are OK."
120 echo "Checking Optional OpenStack services:"
121 for service in $OPTIONAL_SERVICES; do
122 check_service $service
125 echo "Checking External network..."
126 networks=($(neutron net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}'))
128 for net in "${networks[@]}"
130 is_external=$(neutron net-show $net|grep "router:external"|awk '{print $4}')
131 if [ $is_external == "True" ]; then
132 echo "External network found: $net"
136 if [ $is_external == "False" ]; then
137 echo "ERROR: There are no external networks in the deployment."