From 5c4bd36e8090ecbfca48980bc47c89e4808230b1 Mon Sep 17 00:00:00 2001 From: Ifat Afek Date: Tue, 3 Apr 2018 14:09:44 +0000 Subject: [PATCH] Rename Mistral notifier queue In case there is an execute_mistral action in one of the templates, the evaluator used to send an event to a queue with a 'mistral' topic. This change adds a 'vitrage_notifier' prefix to the queue name, to make it more clear that this is a Vitrage queue. Change-Id: I23b5e43c931381cc4ec628659a1f1f250e308c82 --- vitrage/evaluator/actions/__init__.py | 11 ++++++++++- vitrage/evaluator/actions/notifier.py | 5 ++++- vitrage/notifier/service.py | 6 +++++- vitrage/opts.py | 2 ++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/vitrage/evaluator/actions/__init__.py b/vitrage/evaluator/actions/__init__.py index dd32b852f..2197b1e09 100644 --- a/vitrage/evaluator/actions/__init__.py +++ b/vitrage/evaluator/actions/__init__.py @@ -12,4 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. -__author__ = 'stack' +from oslo_config import cfg + + +# Register options for the service +OPTS = [ + cfg.StrOpt('evaluator_notification_topic_prefix', + default='vitrage_evaluator_notifications', + help='A prefix of the topic on which events will be sent from ' + 'the evaluator to the specific notifiers') +] diff --git a/vitrage/evaluator/actions/notifier.py b/vitrage/evaluator/actions/notifier.py index bfa6c13ec..4871d8ea6 100644 --- a/vitrage/evaluator/actions/notifier.py +++ b/vitrage/evaluator/actions/notifier.py @@ -34,6 +34,9 @@ class EvaluatorNotifier(object): LOG.info('Evaluator Notifier is disabled') return + topic_prefix = \ + conf.evaluator_actions.evaluator_notification_topic_prefix + for notifier in notifier_plugins: LOG.debug('Adding evaluator notifier %s', notifier) @@ -41,7 +44,7 @@ class EvaluatorNotifier(object): get_transport(conf), driver='messagingv2', publisher_id='vitrage.evaluator', - topics=[notifier]) + topics=[topic_prefix + '.' + notifier]) except Exception as e: LOG.info('Evaluator Notifier - missing configuration %s' % str(e)) diff --git a/vitrage/notifier/service.py b/vitrage/notifier/service.py index f1cbf6d07..7ad55a265 100644 --- a/vitrage/notifier/service.py +++ b/vitrage/notifier/service.py @@ -75,10 +75,14 @@ class VitrageNotifierService(os_service.Service): endpoint=VitrageDefaultEventEndpoint( self.notifiers)) + topic_prefix = \ + conf.evaluator_actions.evaluator_notification_topic_prefix + for notifier in self.notifiers: if notifier.use_private_topic(): self._init_notifier(transport=transport, - topic=notifier.get_notifier_name(), + topic=topic_prefix + '.' + + notifier.get_notifier_name(), endpoint=notifier) def _init_notifier(self, transport, topic, endpoint): diff --git a/vitrage/opts.py b/vitrage/opts.py index 599401407..1c6afc62b 100644 --- a/vitrage/opts.py +++ b/vitrage/opts.py @@ -22,6 +22,7 @@ import vitrage.api import vitrage.datasources import vitrage.entity_graph.consistency import vitrage.evaluator +import vitrage.evaluator.actions import vitrage.keystone_client import vitrage.machine_learning import vitrage.machine_learning.plugins.jaccard_correlation @@ -47,6 +48,7 @@ def list_opts(): ('api', vitrage.api.OPTS), ('datasources', vitrage.datasources.OPTS), ('evaluator', vitrage.evaluator.OPTS), + ('evaluator_actions', vitrage.evaluator.actions.OPTS), ('consistency', vitrage.entity_graph.consistency.OPTS), ('database', vitrage.storage.OPTS), ('persistency', vitrage.persistency.OPTS),