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
32 cmd=${service_cmd_array[$service]}
38 echo ">>Checking ${service} service..."
39 if ! openstack service list | grep -i ${service} > /dev/null; then
40 if [ "$required" == 'false' ]; then
41 echo "WARN: Optional Service ${service} is not enabled!"
44 echo "ERROR: Required Service ${service} is not enabled!"
50 if [ $result -ne 0 ]; then
51 echo "ERROR: Failed execution $cmd. The $service does not seem to be working."
58 if [ -z $OS_AUTH_URL ];then
59 echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?"
64 echo "Checking OpenStack endpoints:"
65 publicURL=$(openstack catalog show identity |awk '/public/ {print $4}')
66 publicIP=$(echo $publicURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
67 publicPort=$(echo $publicURL|sed 's/^.*://'|sed 's/\/.*$//')
68 echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..."
69 verify_connectivity $publicIP $publicPort
71 if [ $RETVAL -ne 0 ]; then
72 echo "ERROR: Cannot talk to the public endpoint $publicIP:$publicPort ."
73 echo "OS_AUTH_URL=$OS_AUTH_URL"
78 adminURL=$(openstack catalog show identity |awk '/admin/ {print $4}')
79 if [ -z ${adminURL} ]; then
80 echo "ERROR: Cannot determine the admin URL."
81 openstack catalog show identity
84 adminIP=$(echo $adminURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
85 adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
86 echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..."
87 verify_connectivity $adminIP $adminPort
89 if [ $RETVAL -ne 0 ]; then
90 echo "ERROR: Cannot talk to the admin endpoint $adminIP:$adminPort ."
97 echo "Checking Required OpenStack services:"
98 for service in $MANDATORY_SERVICES; do
99 check_service $service "true"
101 echo "Required OpenStack services are OK."
103 echo "Checking Optional OpenStack services:"
104 for service in $OPTIONAL_SERVICES; do
105 check_service $service
108 echo "Checking External network..."
109 networks=($(neutron net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}'))
111 for net in "${networks[@]}"
113 is_external=$(neutron net-show $net|grep "router:external"|awk '{print $4}')
114 if [ $is_external == "True" ]; then
115 echo "External network found: $net"
119 if [ $is_external == "False" ]; then
120 echo "ERROR: There are no external networks in the deployment."