Currently, devstack only support mongodb as ceilometer storage backend,
this patch is to add mysql storage support for ceilometer.
If you want to use mysql as backend during developing, you can specify
CEILOMETER_BACKEND=mysql in localrc file.
If you use mongodb, just ignore the parameter.
Change-Id: Ic2f475a9baa6d71a43cd29a6ca777ac972e47b0a
Implements: blueprint ceilometer-mysql-support
| ... | ... |
@@ -37,12 +37,10 @@ CEILOMETER_API_LOG_DIR=/var/log/ceilometer-api |
| 37 | 37 |
CEILOMETER_AUTH_CACHE_DIR=${CEILOMETER_AUTH_CACHE_DIR:-/var/cache/ceilometer}
|
| 38 | 38 |
|
| 39 | 39 |
# Support potential entry-points console scripts |
| 40 |
-if [[ -d $CEILOMETER_DIR/bin ]]; then |
|
| 41 |
- CEILOMETER_BIN_DIR=$CEILOMETER_DIR/bin |
|
| 42 |
-else |
|
| 43 |
- CEILOMETER_BIN_DIR=$(get_python_exec_prefix) |
|
| 44 |
-fi |
|
| 40 |
+CEILOMETER_BIN_DIR=$(get_python_exec_prefix) |
|
| 45 | 41 |
|
| 42 |
+# Set up database backend |
|
| 43 |
+CEILOMETER_BACKEND=${CEILOMETER_BACKEND:-mongodb}
|
|
| 46 | 44 |
|
| 47 | 45 |
# Functions |
| 48 | 46 |
# --------- |
| ... | ... |
@@ -91,11 +89,13 @@ function configure_ceilometer() {
|
| 91 | 91 |
iniset $CEILOMETER_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 92 | 92 |
iniset $CEILOMETER_CONF keystone_authtoken signing_dir $CEILOMETER_AUTH_CACHE_DIR |
| 93 | 93 |
|
| 94 |
- iniset $CEILOMETER_CONF database connection mongodb://localhost:27017/ceilometer |
|
| 95 |
- |
|
| 96 |
- configure_mongodb |
|
| 97 |
- |
|
| 98 |
- cleanup_ceilometer |
|
| 94 |
+ if [[ "$CEILOMETER_BACKEND" = 'mysql' ]]; then |
|
| 95 |
+ iniset $CEILOMETER_CONF database connection `database_connection_url ceilometer` |
|
| 96 |
+ else |
|
| 97 |
+ iniset $CEILOMETER_CONF database connection mongodb://localhost:27017/ceilometer |
|
| 98 |
+ configure_mongodb |
|
| 99 |
+ cleanup_ceilometer |
|
| 100 |
+ fi |
|
| 99 | 101 |
} |
| 100 | 102 |
|
| 101 | 103 |
function configure_mongodb() {
|
| ... | ... |
@@ -113,6 +113,11 @@ function init_ceilometer() {
|
| 113 | 113 |
sudo mkdir -p $CEILOMETER_AUTH_CACHE_DIR |
| 114 | 114 |
sudo chown $STACK_USER $CEILOMETER_AUTH_CACHE_DIR |
| 115 | 115 |
rm -f $CEILOMETER_AUTH_CACHE_DIR/* |
| 116 |
+ |
|
| 117 |
+ if [[ "$CEILOMETER_BACKEND" = 'mysql' ]]; then |
|
| 118 |
+ recreate_database ceilometer utf8 |
|
| 119 |
+ $CEILOMETER_BIN_DIR/ceilometer-dbsync |
|
| 120 |
+ fi |
|
| 116 | 121 |
} |
| 117 | 122 |
|
| 118 | 123 |
# install_ceilometer() - Collect source and prepare |