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
This commit is contained in:
parent
b98c2dbd53
commit
155d4fa894
@ -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.
|
||||
|
@ -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)]
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user