From 98d1e4534fdb9cd1268f3c228598659a9a64e3f3 Mon Sep 17 00:00:00 2001
From: Joshua Harlow <jxharlow@godaddy.com>
Date: Fri, 16 Mar 2018 12:54:11 -0700
Subject: [PATCH] Have glance notifications work like the other projects

Currently glance has a very simplistic ability to configure
notifications which seems different than nova and neutron which
both allow for selecting the topics used. In order to make glance
work like the others just have glance be configured like the other
projects notifications are being configured.

Change-Id: Ia12993e1b86d040c2705e72b32f93b874fe4adc6
---
 ansible/roles/glance/defaults/main.yml                 | 8 ++++++++
 ansible/roles/glance/templates/glance-api.conf.j2      | 3 ++-
 ansible/roles/glance/templates/glance-registry.conf.j2 | 3 ++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ansible/roles/glance/defaults/main.yml b/ansible/roles/glance/defaults/main.yml
index af772b5fda..ed834d2294 100644
--- a/ansible/roles/glance/defaults/main.yml
+++ b/ansible/roles/glance/defaults/main.yml
@@ -23,6 +23,14 @@ glance_services:
       - "/etc/localtime:/etc/localtime:ro"
       - "kolla_logs:/var/log/kolla/"
 
+####################
+# Notification
+####################
+glance_notification_topics:
+  - name: notifications
+    enabled: "{{ enable_ceilometer | bool or enable_searchlight | bool }}"
+
+glance_enabled_notification_topics: "{{ glance_notification_topics | selectattr('enabled', 'equalto', true) | list }}"
 
 ####################
 # Ceph
diff --git a/ansible/roles/glance/templates/glance-api.conf.j2 b/ansible/roles/glance/templates/glance-api.conf.j2
index 1258b800ca..a54dae97ce 100644
--- a/ansible/roles/glance/templates/glance-api.conf.j2
+++ b/ansible/roles/glance/templates/glance-api.conf.j2
@@ -83,8 +83,9 @@ vmware_insecure = True
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool or enable_searchlight | bool %}
+{% if glance_enabled_notification_topics %}
 driver = messagingv2
+topics = {{ glance_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
diff --git a/ansible/roles/glance/templates/glance-registry.conf.j2 b/ansible/roles/glance/templates/glance-registry.conf.j2
index 9a714b3a12..537fe28d9c 100644
--- a/ansible/roles/glance/templates/glance-registry.conf.j2
+++ b/ansible/roles/glance/templates/glance-registry.conf.j2
@@ -33,8 +33,9 @@ flavor = keystone
 
 [oslo_messaging_notifications]
 transport_url = {{ notify_transport_url }}
-{% if enable_ceilometer | bool or enable_searchlight | bool %}
+{% if glance_enabled_notification_topics %}
 driver = messagingv2
+topics = {{ glance_enabled_notification_topics | map(attribute='name') | join(',') }}
 {% else %}
 driver = noop
 {% endif %}
-- 
GitLab