#!/bin/bash
#
# This script can be used to check the Kolla containers deployed
# from the start script.

if [[ $EUID -ne 0 ]]; then
    echo "You must execute this script as root." 1>&2
    exit 1
fi

# Move to top level directory
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."

# Check what network manager is set in the ENV file.
NETWORK_MANAGER=$(grep -ri NETWORK_MANAGER compose/openstack.env | cut -f2 -d'=')

echo Checking rabbitmq.
docker-compose -f ./compose/rabbitmq.yml ps

echo Checking mariadb.
docker-compose -f ./compose/mariadb.yml ps

echo Checking keystone.
docker-compose -f ./compose/keystone.yml ps

echo Checking glance.
docker-compose -f ./compose/glance-api-registry.yml ps

echo Checking nova.
docker-compose -f ./compose/nova-api-conductor-scheduler.yml ps

if [[ "${NETWORK_MANAGER}" == "nova" ]] ; then
  echo Checking nova compute with nova networking.
  docker-compose -f ./compose/nova-compute-network.yml ps
elif [[ "${NETWORK_MANAGER}" == "neutron" ]] ; then
  echo Checking nova compute with neutron networking.
  docker-compose -f ./compose/nova-compute.yml ps
  docker-compose -f ./compose/neutron-server.yml ps
  docker-compose -f ./compose/neutron-agents.yml ps
fi

echo Checking heat.
docker-compose -f ./compose/heat-api-engine.yml ps

echo Checking Horizon.
docker-compose -f ./compose/horizon.yml ps
