Setup Keystone catalog information for Ceilometer
Change-Id: I3f536f38fe7862ee41b06d1d48b848cc07492c8d
Closes-Bug: #1267322
diff --git a/files/default_catalog.templates b/files/default_catalog.templates
index 277904a..430c42a 100644
--- a/files/default_catalog.templates
+++ b/files/default_catalog.templates
@@ -51,3 +51,8 @@
catalog.RegionOne.orchestration.adminURL = http://%SERVICE_HOST%:8000/v1
catalog.RegionOne.orchestration.internalURL = http://%SERVICE_HOST%:8000/v1
catalog.RegionOne.orchestration.name = Heat Service
+
+catalog.RegionOne.metering.publicURL = http://%SERVICE_HOST%:8777/v1
+catalog.RegionOne.metering.adminURL = http://%SERVICE_HOST%:8777/v1
+catalog.RegionOne.metering.internalURL = http://%SERVICE_HOST%:8777/v1
+catalog.RegionOne.metering.name = Telemetry Service
diff --git a/lib/ceilometer b/lib/ceilometer
index fac3be1..fe72fcd 100644
--- a/lib/ceilometer
+++ b/lib/ceilometer
@@ -48,8 +48,50 @@
# Set up database backend
CEILOMETER_BACKEND=${CEILOMETER_BACKEND:-mysql}
+# Ceilometer connection info.
+CEILOMETER_SERVICE_PROTOCOL=http
+CEILOMETER_SERVICE_HOST=$SERVICE_HOST
+CEILOMETER_SERVICE_PORT=${CEILOMETER_SERVICE_PORT:-8777}
+#
+
# Functions
# ---------
+#
+# create_ceilometer_accounts() - Set up common required ceilometer accounts
+
+create_ceilometer_accounts() {
+
+ SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
+ ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
+
+ # Ceilometer
+ if [[ "$ENABLED_SERVICES" =~ "ceilometer-api" ]]; then
+ CEILOMETER_USER=$(keystone user-create \
+ --name=ceilometer \
+ --pass="$SERVICE_PASSWORD" \
+ --tenant_id $SERVICE_TENANT \
+ --email=ceilometer@example.com \
+ | grep " id " | get_field 2)
+ keystone user-role-add \
+ --tenant-id $SERVICE_TENANT \
+ --user-id $CEILOMETER_USER \
+ --role-id $ADMIN_ROLE
+ if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
+ CEILOMETER_SERVICE=$(keystone service-create \
+ --name=ceilometer \
+ --type=metering \
+ --description="OpenStack Telemetry Service" \
+ | grep " id " | get_field 2)
+ keystone endpoint-create \
+ --region RegionOne \
+ --service_id $CEILOMETER_SERVICE \
+ --publicurl "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/" \
+ --adminurl "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/" \
+ --internalurl "$CEILOMETER_SERVICE_PROTOCOL://$CEILOMETER_SERVICE_HOST:$CEILOMETER_SERVICE_PORT/"
+ fi
+ fi
+}
+
# cleanup_ceilometer() - Remove residual data files, anything left over from previous
# runs that a clean run would need to clean up
diff --git a/stack.sh b/stack.sh
index 2438f9f..bf782bc 100755
--- a/stack.sh
+++ b/stack.sh
@@ -901,6 +901,10 @@
create_trove_accounts
fi
+ if is_service_enabled ceilometer; then
+ create_ceilometer_accounts
+ fi
+
if is_service_enabled swift || is_service_enabled s-proxy; then
create_swift_accounts
fi