The ceilometer.event.trait_plugins ModuleΒΆ

class ceilometer.event.trait_plugins.BitfieldTraitPlugin(initial_bitfield=0, flags=None, **kw)[source]

Bases: ceilometer.event.trait_plugins.TraitPluginBase

Plugin to set flags on a bitfield.

trait_value(match_list)[source]
class ceilometer.event.trait_plugins.SplitterTraitPlugin(separator='.', segment=0, max_split=None, **kw)[source]

Bases: ceilometer.event.trait_plugins.TraitPluginBase

Plugin that splits a piece off of a string value.

trait_value(match_list)[source]
class ceilometer.event.trait_plugins.TraitPluginBase(**kw)[source]

Bases: object

Base class for plugins.

It converts notification fields to Trait values.

trait_value(match_list)[source]

Convert a set of fields to a Trait value.

This method is called each time a trait is attempted to be extracted from a notification. It will be called even if no matching fields are found in the notification (in that case, the match_list will be empty). If this method returns None, the trait will not be added to the event. Any other value returned by this method will be used as the value for the trait. Values returned will be coerced to the appropriate type for the trait.

Parameters:match_list – A list (may be empty if no matches) of tuples. Each tuple is (field_path, value) where field_path is the jsonpath for that specific field.

Example:

trait's fields definition: ['payload.foobar',
                            'payload.baz',
                            'payload.thing.*']
notification body:
            {
             'message_id': '12345',
             'publisher': 'someservice.host',
             'payload': {
                         'foobar': 'test',
                         'thing': {
                                   'bar': 12,
                                   'boing': 13,
                                  }
                        }
            }
match_list will be: [('payload.foobar','test'),
                     ('payload.thing.bar',12),
                     ('payload.thing.boing',13)]

Here is a plugin that emulates the default (no plugin) behavior:

class DefaultPlugin(TraitPluginBase):
    "Plugin that returns the first field value."

    def __init__(self, **kw):
        super(DefaultPlugin, self).__init__()

    def trait_value(self, match_list):
        if not match_list:
            return None
        return match_list[0][1]

Previous topic

The ceilometer.event.converter Module

Next topic

The ceilometer.event Module

This Page