23
23
from oslo.config import cfg
25
from ceilometer.openstack.common.gettextutils import _ # noqa
26
from ceilometer.openstack.common.gettextutils import _
26
27
from ceilometer.openstack.common import log
27
28
from ceilometer import plugin
28
29
from ceilometer import sample
66
def get_exchange_topics(conf):
67
"""Return a sequence of ExchangeTopics defining the exchange and topics
68
to be connected for this plugin.
67
def get_targets(conf):
68
"""Return a sequence of oslo.messaging.Target defining the exchange and
69
topics to be connected for this plugin.
72
plugin.ExchangeTopics(
73
exchange=conf.neutron_control_exchange,
74
topics=set(topic + ".info"
75
for topic in conf.notification_topics)),
71
return [oslo.messaging.Target(topic=topic,
72
exchange=conf.neutron_control_exchange)
73
for topic in conf.notification_topics]
78
75
def process_notification(self, message):
79
76
LOG.info(_('network notification %r') % message)
80
message['payload'] = message['payload'][self.resource_name]
81
77
counter_name = getattr(self, 'counter_name', self.resource_name)
82
78
unit_value = getattr(self, 'unit', self.resource_name)
84
yield sample.Sample.from_notification(
86
type=sample.TYPE_GAUGE,
89
user_id=message['_context_user_id'],
90
project_id=message['_context_tenant_id'],
91
resource_id=message['payload']['id'],
94
event_type_split = message['event_type'].split('.')
95
if len(event_type_split) > 2:
80
payload = message['payload'].get(self.resource_name)
81
payloads = message['payload'].get(self.resource_name + 's')
82
payload_list = copy.copy([payload] if payload else payloads)
83
for p in payload_list:
84
message['payload'] = p
96
85
yield sample.Sample.from_notification(
98
+ "." + event_type_split[1],
99
type=sample.TYPE_DELTA,
87
type=sample.TYPE_GAUGE,
102
90
user_id=message['_context_user_id'],
103
91
project_id=message['_context_tenant_id'],
104
92
resource_id=message['payload']['id'],
94
event_type_split = message['event_type'].split('.')
95
if len(event_type_split) > 2:
96
yield sample.Sample.from_notification(
98
+ "." + event_type_split[1],
99
type=sample.TYPE_DELTA,
102
user_id=message['_context_user_id'],
103
project_id=message['_context_tenant_id'],
104
resource_id=message['payload']['id'],
108
108
class Network(NetworkNotificationBase):