From 155d4fa894ea07264c03db73ba0828d3b96de1ae Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 2 Dec 2015 23:43:34 -0500 Subject: [PATCH] oslo.messaging option group/name change for notification topics In Ib51e2839f9035d0cc0e3f459939d9f9003a8c810, oslo.messaging is introducing a new group for the notifiction options. This review is the minimum needed to support both old and newer oslo.messaging versions. (In other words, next oslo.messaging release will break ceilometer unless we work around for the new option group) Change-Id: I4765b3b9627983a245aa5521a85ad89e83ab8551 --- ceilometer/agent/plugin_base.py | 6 ++++++ ceilometer/compute/notifications/__init__.py | 5 ++--- ceilometer/database/notifications.py | 5 ++--- ceilometer/dns/notifications.py | 5 ++--- ceilometer/ipmi/notifications/ironic.py | 5 ++--- ceilometer/meter/notifications.py | 3 ++- ceilometer/middleware.py | 5 ++--- ceilometer/network/notifications.py | 5 ++--- ceilometer/telemetry/notifications.py | 5 ++--- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ceilometer/agent/plugin_base.py b/ceilometer/agent/plugin_base.py index 1ccf16d54c..a5e9545923 100644 --- a/ceilometer/agent/plugin_base.py +++ b/ceilometer/agent/plugin_base.py @@ -48,6 +48,12 @@ class NotificationBase(PluginBase): event_type='|'.join(self.event_types)) self.manager = manager + @staticmethod + def get_notification_topics(conf): + if 'notification_topics' in conf: + return conf.notification_topics + return conf.oslo_messaging_notifications.topics + @abc.abstractproperty def event_types(self): """Return a sequence of strings. diff --git a/ceilometer/compute/notifications/__init__.py b/ceilometer/compute/notifications/__init__.py index 0392a60cf7..fac3ff286d 100644 --- a/ceilometer/compute/notifications/__init__.py +++ b/ceilometer/compute/notifications/__init__.py @@ -30,8 +30,7 @@ cfg.CONF.register_opts(OPTS) class ComputeNotificationBase(plugin_base.NotificationBase): - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """Return a sequence of oslo_messaging.Target This sequence is defining the exchange and topics to be connected for @@ -39,4 +38,4 @@ class ComputeNotificationBase(plugin_base.NotificationBase): """ return [oslo_messaging.Target(topic=topic, exchange=conf.nova_control_exchange) - for topic in conf.notification_topics] + for topic in self.get_notification_topics(conf)] diff --git a/ceilometer/database/notifications.py b/ceilometer/database/notifications.py index 3a606cafa1..271bde3108 100644 --- a/ceilometer/database/notifications.py +++ b/ceilometer/database/notifications.py @@ -28,8 +28,7 @@ cfg.CONF.import_opt('trove_control_exchange', class TroveMetricsNotificationBase(plugin_base.NotificationBase): """Base class for trove (dbaas) notifications.""" - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """Return a sequence of oslo.messaging.Target This sequence is defining the exchange and topics to be connected for @@ -37,7 +36,7 @@ class TroveMetricsNotificationBase(plugin_base.NotificationBase): """ return [oslo_messaging.Target(topic=topic, exchange=conf.trove_control_exchange) - for topic in conf.notification_topics] + for topic in self.get_notification_topics(conf)] class InstanceExists(TroveMetricsNotificationBase): diff --git a/ceilometer/dns/notifications.py b/ceilometer/dns/notifications.py index 0901799acc..788728d44e 100644 --- a/ceilometer/dns/notifications.py +++ b/ceilometer/dns/notifications.py @@ -34,8 +34,7 @@ SERVICE = 'dns' class DnsMetricsNotificationBase(plugin_base.NotificationBase): """Base class for DNSaaS(Designate) notifications.""" - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """Return a sequence of oslo.messaging.Target This sequence is defining the exchange and topics to be connected for @@ -43,7 +42,7 @@ class DnsMetricsNotificationBase(plugin_base.NotificationBase): """ return [oslo_messaging.Target(topic=topic, exchange=conf.dns_control_exchange) - for topic in conf.notification_topics] + for topic in self.get_notification_topics(conf)] class DomainExists(DnsMetricsNotificationBase): diff --git a/ceilometer/ipmi/notifications/ironic.py b/ceilometer/ipmi/notifications/ironic.py index a4456d89a7..743558d726 100644 --- a/ceilometer/ipmi/notifications/ironic.py +++ b/ceilometer/ipmi/notifications/ironic.py @@ -79,12 +79,11 @@ class SensorNotification(plugin_base.NotificationBase): event_types = ['hardware.ipmi.*'] metric = None - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """oslo.messaging.TargetS for this plugin.""" return [messaging.Target(topic=topic, exchange=conf.ironic_exchange) - for topic in conf.notification_topics] + for topic in self.get_notification_topics(conf)] def _get_sample(self, message): try: diff --git a/ceilometer/meter/notifications.py b/ceilometer/meter/notifications.py index b593f43884..d95cd23b8a 100644 --- a/ceilometer/meter/notifications.py +++ b/ceilometer/meter/notifications.py @@ -223,7 +223,8 @@ class ProcessMeterNotifications(plugin_base.NotificationBase): for exchange in exchanges: targets.extend(oslo_messaging.Target(topic=topic, exchange=exchange) - for topic in conf.notification_topics) + for topic in + self.get_notification_topics(conf)) return targets def process_notification(self, notification_body): diff --git a/ceilometer/middleware.py b/ceilometer/middleware.py index 8fa9456a7a..3901c3e2d3 100644 --- a/ceilometer/middleware.py +++ b/ceilometer/middleware.py @@ -44,15 +44,14 @@ class HTTPRequest(plugin_base.NotificationBase, plugin_base.NonMetricNotificationBase): event_types = ['http.request'] - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """Return a sequence of oslo_messaging.Target This sequence is defining the exchange and topics to be connected for this plugin. """ return [oslo_messaging.Target(topic=topic, exchange=exchange) - for topic in conf.notification_topics + for topic in self.get_notification_topics(conf) for exchange in conf.http_control_exchanges] def process_notification(self, message): diff --git a/ceilometer/network/notifications.py b/ceilometer/network/notifications.py index 9d8d61bc42..79220cec04 100644 --- a/ceilometer/network/notifications.py +++ b/ceilometer/network/notifications.py @@ -59,8 +59,7 @@ class NetworkNotificationBase(plugin_base.NotificationBase): # '%s.delete.start' % (self.resource_name), ] - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """Return a sequence of oslo_messaging.Target This sequence is defining the exchange and topics to be connected for @@ -68,7 +67,7 @@ class NetworkNotificationBase(plugin_base.NotificationBase): """ return [oslo_messaging.Target(topic=topic, exchange=conf.neutron_control_exchange) - for topic in conf.notification_topics] + for topic in self.get_notification_topics(conf)] def process_notification(self, message): counter_name = getattr(self, 'counter_name', self.resource_name) diff --git a/ceilometer/telemetry/notifications.py b/ceilometer/telemetry/notifications.py index 3a13d1c956..db825ac02b 100644 --- a/ceilometer/telemetry/notifications.py +++ b/ceilometer/telemetry/notifications.py @@ -30,8 +30,7 @@ cfg.CONF.register_opts(OPTS) class TelemetryBase(plugin_base.NotificationBase): """Convert telemetry notification into Samples.""" - @staticmethod - def get_targets(conf): + def get_targets(self, conf): """Return a sequence of oslo_messaging.Target Sequence defining the exchange and topics to be connected for this @@ -39,7 +38,7 @@ class TelemetryBase(plugin_base.NotificationBase): """ return [oslo_messaging.Target( topic=topic, exchange=conf.ceilometer_control_exchange) - for topic in conf.notification_topics] + for topic in self.get_notification_topics(conf)] class TelemetryIpc(TelemetryBase):