#!/bin/bash
#-----------------
# Testing nova-api
#-----------------
set -e

apt-get install -y nova-api nova-api-metadata 2>&1 > /dev/null

for daemon in nova-api nova-api-metadata; do
    if apache2ctl -t -D DUMP_VHOSTS | grep -q "$daemon.conf"; then
        echo "OK: ${daemon}.conf enabled"
    else
        echo "ERROR: ${daemon}.conf is not enabled"
        exit 1
    fi
done

for path in /usr/bin/nova-api-wsgi /usr/bin/nova-metadata-wsgi; do
    if [ -x "$path" ]; then
        echo "OK: $path present"
    else
        echo "ERROR: missing $path"
        exit 1
    fi
done
