From 838cffd9c9ce8af7ecbf378faf34b882b3f4439a Mon Sep 17 00:00:00 2001
From: Kien Nguyen <kiennt65@viettel.com.vn>
Date: Wed, 12 Dec 2018 11:32:52 +0700
Subject: [PATCH] Configure vitrage notification topic

According [1], vitrage notification has to be configured in Nova,
Neutron, Cinder & Aodh config file.

[1] https://review.openstack.org/#/c/302802/

Change-Id: Iaf8cd7d40e6eb988adf4d208e6ad784f1004caa5
---
 ansible/roles/aodh/defaults/main.yml          | 11 +++++++++++
 ansible/roles/aodh/templates/aodh.conf.j2     |  6 ++++--
 ansible/roles/cinder/defaults/main.yml        | 11 +++++++++++
 ansible/roles/cinder/templates/cinder.conf.j2 |  4 ++--
 ansible/roles/neutron/defaults/main.yml       |  2 ++
 ansible/roles/nova/defaults/main.yml          |  2 ++
 6 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/ansible/roles/aodh/defaults/main.yml b/ansible/roles/aodh/defaults/main.yml
index 20b91959d1..c23bfe3d07 100644
--- a/ansible/roles/aodh/defaults/main.yml
+++ b/ansible/roles/aodh/defaults/main.yml
@@ -75,6 +75,17 @@ aodh_database_name: "aodh"
 aodh_database_user: "{% if use_preconfigured_databases | bool and use_common_mariadb_user | bool %}{{ database_user }}{% else %}aodh{% endif %}"
 aodh_database_address: "{{ database_address }}:{{ database_port }}"
 
+####################
+# Notification
+####################
+aodh_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+  - name: vitrage_notifications
+    enabled: "{{ enable_vitrage | bool }}"
+
+aodh_enabled_notification_topics: "{{ aodh_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
+
 ####################
 # Docker
 ####################
diff --git a/ansible/roles/aodh/templates/aodh.conf.j2 b/ansible/roles/aodh/templates/aodh.conf.j2
index 42bcf74b2f..45edf4beb3 100644
--- a/ansible/roles/aodh/templates/aodh.conf.j2
+++ b/ansible/roles/aodh/templates/aodh.conf.j2
@@ -47,8 +47,10 @@ interface = internal
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool %}
+{% if aodh_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ aodh_enabled_notification_topics | map(attribute='name') | join(',') }}
+{% else %}
+driver = noop
 {% endif %}
 
diff --git a/ansible/roles/cinder/defaults/main.yml b/ansible/roles/cinder/defaults/main.yml
index b813979cb0..3cb8ffe5cc 100644
--- a/ansible/roles/cinder/defaults/main.yml
+++ b/ansible/roles/cinder/defaults/main.yml
@@ -191,6 +191,17 @@ cinder_backends:
 
 cinder_enabled_backends: "{{ cinder_backends|selectattr('enabled', 'equalto', true)|list }}"
 
+####################
+# Notification
+####################
+cinder_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool }}"
+  - name: vitrage_notifications
+    enabled: "{{ enable_vitrage | bool }}"
+
+cinder_enabled_notification_topics: "{{ cinder_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
+
 #############################################
 # Hitachi NAS Platform iSCSI and NFS drivers
 #############################################
diff --git a/ansible/roles/cinder/templates/cinder.conf.j2 b/ansible/roles/cinder/templates/cinder.conf.j2
index 99769247ca..2eb69e4138 100644
--- a/ansible/roles/cinder/templates/cinder.conf.j2
+++ b/ansible/roles/cinder/templates/cinder.conf.j2
@@ -61,9 +61,9 @@ transport_url = {{ rpc_transport_url }}
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool or enable_searchlight | bool %}
+{% if cinder_enabled_notification_topics %}
 driver = messagingv2
-topics = notifications
+topics = {{ cinder_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/neutron/defaults/main.yml b/ansible/roles/neutron/defaults/main.yml
index 1af74f0ecd..cbb9f6a64b 100644
--- a/ansible/roles/neutron/defaults/main.yml
+++ b/ansible/roles/neutron/defaults/main.yml
@@ -377,6 +377,8 @@ neutron_notification_topics:
     enabled: "{{ enable_ceilometer | bool or enable_searchlight | bool or enable_neutron_infoblox_ipam_agent | bool }}"
   - name: notifications_designate
     enabled: "{{ enable_designate | bool }}"
+  - name: vitrage_notifications
+    enabled: "{{ enable_vitrage | bool }}"
 
 neutron_enabled_notification_topics: "{{ neutron_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
 
diff --git a/ansible/roles/nova/defaults/main.yml b/ansible/roles/nova/defaults/main.yml
index af08651e7e..48163db58f 100644
--- a/ansible/roles/nova/defaults/main.yml
+++ b/ansible/roles/nova/defaults/main.yml
@@ -386,6 +386,8 @@ nova_notification_topics:
     enabled: "{{ enable_ceilometer | bool or enable_searchlight | bool or enable_neutron_infoblox_ipam_agent | bool }}"
   - name: notifications_designate
     enabled: "{{ enable_designate | bool }}"
+  - name: vitrage_notifications
+    enabled: "{{ enable_vitrage | bool }}"
 
 nova_enabled_notification_topics: "{{ nova_notification_topics | selectattr('enabled', 'equalto', true) | list }}"