#!/bin/bash
set -eux

TEMPLATE_ROOT=$(dirname $0)/../os-apply-config

get_additional_config(){
  if [ -d ${TEMPLATE_ROOT}/etc/nova/${1} ]; then
    echo "--config-dir /etc/nova/${1}"
  fi
}

NOVA_COMPONENTS="api cert scheduler consoleauth conductor"

for component in $NOVA_COMPONENTS; do
    os-svc-daemon -i "${NOVA_VENV_DIR}" nova-${component} nova nova-${component} "--config-dir /etc/nova $(get_additional_config ${component})"
done

ln -s $NOVA_VENV_DIR/bin/nova-manage /usr/local/bin/nova-manage
