# lib/osprofiler
# Functions to control the configuration and operation of the **osprofiler**

# Dependencies:
#
# - ``functions`` file
# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined

# ``stack.sh`` calls the entry points in this order:
#
# - install_osprofiler
# - configure_osprofiler
# - init_osprofiler

# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace


# Defaults
# --------

CONF_FILES=(
    $CINDER_CONF
    $HEAT_CONF
    $KEYSTONE_CONF
    $NOVA_CONF
    $NEUTRON_CONF
    $GLANCE_API_CONF
    $GLANCE_REGISTRY_CONF
    $TROVE_CONF
    $TROVE_CONDUCTOR_CONF
    $TROVE_GUESTAGENT_CONF
    $TROVE_TASKMANAGER_CONF
    $SENLIN_CONF
    $MAGNUM_CONF
    $ZUN_CONF
)

# This will update CEILOMETER_NOTIFICATION_TOPICS in ceilometer.conf file
export CEILOMETER_NOTIFICATION_TOPICS=notifications,profiler


# Functions
# ---------

# configure_osprofiler() - Nothing for now
function configure_osprofiler() {

    for conf in ${CONF_FILES[@]}; do
        if [ -f $conf ]
        then
            iniset $conf profiler enabled True
            iniset $conf profiler trace_sqlalchemy True
            iniset $conf profiler hmac_keys $OSPROFILER_HMAC_KEYS
            iniset $conf profiler connection_string $OSPROFILER_CONNECTION_STRING
        fi
    done
    if [ -f $CEILOMETER_CONF ]
    then
        iniset $CEILOMETER_CONF event store_raw info
    fi
}


# Restore xtrace
$XTRACE

# Tell emacs to use shell-script-mode
## Local variables:
## mode: shell-script
## End:
