Harmonize notification configuration
This change makes the configuration of notifications consistent across
Liberty, Mitaka and Newton releases.
It also aligns the configuration between the controller and volume roles
by allowing to define the notitication topic(s) and messaging driver.
Finally it preserves backward-compatibility when the 'notification' parameter
is a boolean value instead of a dict.
Change-Id: Ib135f4274c251c314377ff6be915480cd2e543cc
diff --git a/cinder/files/liberty/cinder.conf.controller.Debian b/cinder/files/liberty/cinder.conf.controller.Debian
index 6255d9e..4a08a94 100644
--- a/cinder/files/liberty/cinder.conf.controller.Debian
+++ b/cinder/files/liberty/cinder.conf.controller.Debian
@@ -60,7 +60,12 @@
volume_clear={{ controller.wipe_method }}
-{%- if controller.notification %}
+{%- if controller.notification is mapping %}
+notification_driver = {{ controller.notification.get('driver', 'messagingv2') }}
+{%- if controller.notification.topics is defined %}
+notification_topics = {{ controller.notification.topics }}
+{%- endif %}
+{%- elif controller.notification %}
control_exchange = cinder
notification_driver = messagingv2
{%- endif %}
diff --git a/cinder/files/liberty/cinder.conf.volume.Debian b/cinder/files/liberty/cinder.conf.volume.Debian
index 94efa00..fbaacee 100644
--- a/cinder/files/liberty/cinder.conf.volume.Debian
+++ b/cinder/files/liberty/cinder.conf.volume.Debian
@@ -59,19 +59,13 @@
volume_clear={{ volume.wipe_method }}
-{%- if volume.notification %}
-control_exchange = cinder
-
-{%- if volume.notification.driver is defined %}
-notification_driver = {{ volume.notification.driver }}
-{%- else %}
-notification_driver = messagingv2
-{%- endif %}
-
+{%- if volume.notification is mapping %}
+notification_driver = {{ volume.notification.get('driver', 'messagingv2') }}
{%- if volume.notification.topics is defined %}
notification_topics = {{ volume.notification.topics }}
{%- endif %}
-
+{%- elif volume.notification %}
+notification_driver = messagingv2
{%- endif %}
volume_name_template = volume-%s
diff --git a/cinder/files/mitaka/cinder.conf.controller.Debian b/cinder/files/mitaka/cinder.conf.controller.Debian
index 30f464b..4ff2811 100644
--- a/cinder/files/mitaka/cinder.conf.controller.Debian
+++ b/cinder/files/mitaka/cinder.conf.controller.Debian
@@ -69,7 +69,12 @@
lock_path=/var/lock/cinder
[oslo_messaging_notifications]
-{%- if controller.notification %}
+{%- if controller.notification is mapping %}
+driver = {{ controller.notification.get('driver', 'messagingv2') }}
+{%- if controller.notification.topics is defined %}
+topics = {{ controller.notification.topics }}
+{%- endif %}
+{%- elif controller.notification %}
driver = messagingv2
{%- endif %}
diff --git a/cinder/files/mitaka/cinder.conf.volume.Debian b/cinder/files/mitaka/cinder.conf.volume.Debian
index 7212a24..73b6ca1 100644
--- a/cinder/files/mitaka/cinder.conf.volume.Debian
+++ b/cinder/files/mitaka/cinder.conf.volume.Debian
@@ -67,7 +67,12 @@
verbose=True
[oslo_messaging_notifications]
-{%- if volume.notification %}
+{%- if volume.notification is mapping %}
+driver = {{ volume.notification.get('driver', 'messagingv2') }}
+{%- if volume.notification.topics is defined %}
+topics = {{ volume.notification.topics }}
+{%- endif %}
+{%- elif volume.notification %}
driver = messagingv2
{%- endif %}
diff --git a/cinder/files/newton/cinder.conf.controller.Debian b/cinder/files/newton/cinder.conf.controller.Debian
index d1d3e31..b7e5b74 100644
--- a/cinder/files/newton/cinder.conf.controller.Debian
+++ b/cinder/files/newton/cinder.conf.controller.Debian
@@ -74,7 +74,12 @@
osapi_volume_extension = cinder.api.contrib.standard_extensions
[oslo_messaging_notifications]
-{%- if controller.notification %}
+{%- if controller.notification is mapping %}
+driver = {{ controller.notification.get('driver', 'messagingv2') }}
+{%- if controller.notification.topics is defined %}
+topics = {{ controller.notification.topics }}
+{%- endif %}
+{%- elif controller.notification %}
driver = messagingv2
{%- endif %}
diff --git a/cinder/files/newton/cinder.conf.volume.Debian b/cinder/files/newton/cinder.conf.volume.Debian
index 067f9ce..f5183be 100644
--- a/cinder/files/newton/cinder.conf.volume.Debian
+++ b/cinder/files/newton/cinder.conf.volume.Debian
@@ -70,7 +70,12 @@
nova_catalog_info = compute:nova:publicURL
[oslo_messaging_notifications]
-{%- if volume.notification %}
+{%- if volume.notification is mapping %}
+driver = {{ volume.notification.get('driver', 'messagingv2') }}
+{%- if volume.notification.topics is defined %}
+topics = {{ volume.notification.topics }}
+{%- endif %}
+{%- elif volume.notification %}
driver = messagingv2
{%- endif %}