From 5670ffebb6d71b9b835074f602fbd242834b071e Mon Sep 17 00:00:00 2001
From: Ryota MIBU <r-mibu@cq.jp.nec.com>
Date: Wed, 2 Sep 2015 01:48:05 +0900
Subject: [PATCH] devstack: add new option to support event-alarm

Change-Id: I71c11f3c57e4a055893a80083ce472cc92e27fb9
---
 devstack/plugin.sh | 6 ++++++
 devstack/settings  | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index 020fb43800..21245c846f 100644
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -37,6 +37,7 @@
 #   CEILOMETER_BACKEND:            Database backend (e.g. 'mysql', 'mongodb', 'es')
 #   CEILOMETER_COORDINATION_URL:   URL for group membership service provided by tooz.
 #   CEILOMETER_EVENTS:             Set to True to enable event collection
+#   CEILOMETER_EVENT_ALARM:        Set to True to enable publisher for event alarming
 
 # Save trace setting
 XTRACE=$(set +o | grep xtrace)
@@ -260,6 +261,11 @@ function configure_ceilometer {
     if [ "$CEILOMETER_PIPELINE_INTERVAL" ]; then
         sed -i "s/interval:.*/interval: ${CEILOMETER_PIPELINE_INTERVAL}/" $CEILOMETER_CONF_DIR/pipeline.yaml
     fi
+    if [ "$CEILOMETER_EVENT_ALARM" == "True" ]; then
+        if ! grep -q '^ *- notifier://?topic=alarm.all$' $CEILOMETER_CONF_DIR/event_pipeline.yaml; then
+            sed -i '/^ *publishers:$/,+1s|^\( *\)-.*$|\1- notifier://?topic=alarm.all\n&|' $CEILOMETER_CONF_DIR/event_pipeline.yaml
+        fi
+    fi
 
     # The compute and central agents need these credentials in order to
     # call out to other services' public APIs.
diff --git a/devstack/settings b/devstack/settings
index 6b9a48a29d..cd7fafd598 100644
--- a/devstack/settings
+++ b/devstack/settings
@@ -34,6 +34,8 @@ CEILOMETER_EVENTS=${CEILOMETER_EVENTS:-True}
 CEILOMETER_COORDINATION_URL=${CEILOMETER_COORDINATION_URL:-}
 CEILOMETER_PIPELINE_INTERVAL=${CEILOMETER_PIPELINE_INTERVAL:-}
 
+CEILOMETER_EVENT_ALARM=${CEILOMETER_EVENT_ALARM:-False}
+
 # Tell Tempest this project is present
 TEMPEST_SERVICES+=,ceilometer