blob: 8645820b355c67935e4233f3635579c5f47be1b2 [file] [log] [blame]
Gabe Black90623222017-01-18 19:52:28 +00001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13import oslo_messaging
14from oslo_config import cfg
15
16from ceilometer.agent import plugin_base
17from oslo_log import log
18from ceilometer import sample
19
20OPTS = [
21 cfg.StrOpt('passivetestservice_control_exchange',
22 default='passivetestservice',
23 help="Exchange name for PassiveTest notifications."),
24]
25
26cfg.CONF.register_opts(OPTS)
27
28LOG = log.getLogger(__name__)
29
30class PassiveTestNotification(plugin_base.NotificationBase):
31
32 resource_name = None
33 event_types = ['passivetest.stats']
34
35 def get_targets(self,conf):
36 """Return a sequence of oslo.messaging.Target
37
38 This sequence is defining the exchange and topics to be connected for
39 this plugin.
40 """
41
42 return [oslo_messaging.Target(topic=topic,
43 exchange=conf.passivetestservice_control_exchange)
44 for topic in self.get_notification_topics(conf)]
45
46
47 def process_notification(self, message):
48 LOG.debug('Received Passivetest event passivetest.stats')
49
50 if message['payload']:
51 message['payload']['volume']=float(message['payload']['volume'])
52 yield sample.Sample.from_notification(
53 message=message,
54 **message['payload'])