~cloud-init-dev/cloud-init/trunk

« back to all changes in this revision

Viewing changes to cloudinit/reporting/__init__.py

  • Committer: Scott Moser
  • Date: 2016-08-10 15:06:15 UTC
  • Revision ID: smoser@ubuntu.com-20160810150615-ma2fv107w3suy1ma
README: Mention move of revision control to git.

cloud-init development has moved its revision control to git.
It is available at 
  https://code.launchpad.net/cloud-init

Clone with 
  git clone https://git.launchpad.net/cloud-init
or
  git clone git+ssh://git.launchpad.net/cloud-init

For more information see
  https://git.launchpad.net/cloud-init/tree/HACKING.rst

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2015 Canonical Ltd.
2
 
# This file is part of cloud-init.  See LICENCE file for license information.
3
 
#
4
 
"""
5
 
cloud-init reporting framework
6
 
 
7
 
The reporting framework is intended to allow all parts of cloud-init to
8
 
report events in a structured manner.
9
 
"""
10
 
 
11
 
from ..registry import DictRegistry
12
 
from .handlers import available_handlers
13
 
 
14
 
DEFAULT_CONFIG = {
15
 
    'logging': {'type': 'log'},
16
 
}
17
 
 
18
 
 
19
 
def update_configuration(config):
20
 
    """Update the instanciated_handler_registry.
21
 
 
22
 
    :param config:
23
 
        The dictionary containing changes to apply.  If a key is given
24
 
        with a False-ish value, the registered handler matching that name
25
 
        will be unregistered.
26
 
    """
27
 
    for handler_name, handler_config in config.items():
28
 
        if not handler_config:
29
 
            instantiated_handler_registry.unregister_item(
30
 
                handler_name, force=True)
31
 
            continue
32
 
        handler_config = handler_config.copy()
33
 
        cls = available_handlers.registered_items[handler_config.pop('type')]
34
 
        instantiated_handler_registry.unregister_item(handler_name)
35
 
        instance = cls(**handler_config)
36
 
        instantiated_handler_registry.register_item(handler_name, instance)
37
 
 
38
 
 
39
 
instantiated_handler_registry = DictRegistry()
40
 
update_configuration(DEFAULT_CONFIG)
41
 
 
42
 
# vi: ts=4 expandtab