3 # Simple script to check the basic OpenStack clients
6 # jose.lausuch@ericsson.com
9 if [[ ${OS_INSECURE,,} == "true" ]]; then
15 declare -A service_cmd_array
16 service_cmd_array['nova']="openstack $options server list"
17 service_cmd_array['neutron']="openstack $options network list"
18 service_cmd_array['keystone']="openstack $options endpoint list"
19 service_cmd_array['cinder']="openstack $options volume list"
20 service_cmd_array['glance']="openstack $options image list"
22 MANDATORY_SERVICES='nova neutron keystone glance'
23 OPTIONAL_SERVICES='cinder'
25 verify_connectivity() {
26 for i in $(seq 0 9); do
27 if echo "test" | nc -v -w 10 $1 $2 &>/dev/null; then
35 verify_SSL_connectivity() {
36 openssl s_client -connect $1:$2 &>/dev/null
43 cmd=${service_cmd_array[$service]}
49 echo ">>Checking ${service} service..."
50 if ! openstack $options service list | grep -i ${service} > /dev/null; then
51 if [ "$required" == 'false' ]; then
52 echo "WARN: Optional Service ${service} is not enabled!"
55 echo "ERROR: Required Service ${service} is not enabled!"
61 if [ $result -ne 0 ]; then
62 echo "ERROR: Failed execution $cmd. The $service does not seem to be working."
69 if [ -z $OS_AUTH_URL ];then
70 echo "ERROR: OS_AUTH_URL environment variable missing... Have you sourced the OpenStack credentials?"
75 echo "Checking OpenStack endpoints:"
76 publicURL=$(openstack $options catalog show identity |awk '/public/ {print $4}')
77 publicIP=$(echo $publicURL|sed 's/^.*http.*\:\/\///'|sed 's/.[^:]*$//')
78 publicPort=$(echo $publicURL|grep -Po '(?<=:)\d+')
79 https_enabled=$(echo $publicURL | grep 'https')
80 if [[ -n $https_enabled ]]; then
81 echo ">>Verifying SSL connectivity to the public endpoint $publicIP:$publicPort..."
82 verify_SSL_connectivity $publicIP $publicPort
84 echo ">>Verifying connectivity to the public endpoint $publicIP:$publicPort..."
85 verify_connectivity $publicIP $publicPort
88 if [ $RETVAL -ne 0 ]; then
89 echo "ERROR: Cannot talk to the public endpoint $publicIP:$publicPort ."
90 echo "OS_AUTH_URL=$OS_AUTH_URL"
96 echo "Checking Required OpenStack services:"
97 for service in $MANDATORY_SERVICES; do
98 check_service $service "true"
100 echo "Required OpenStack services are OK."
102 echo "Checking Optional OpenStack services:"
103 for service in $OPTIONAL_SERVICES; do
104 check_service $service
107 echo "Checking External network..."
108 networks=($(neutron $options net-list -F id | tail -n +4 | head -n -1 | awk '{print $2}'))
110 for net in "${networks[@]}"
112 is_external=$(neutron $options net-show $net|grep "router:external"|awk '{print $4}')
113 if [ $is_external == "True" ]; then
114 echo "External network found: $net"
118 if [ $is_external == "False" ]; then
119 echo "ERROR: There are no external networks in the deployment."