~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/openstack/common/notifier/api.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-09-08 21:51:19 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20130908215119-7tcek6gn73275x5k
Tags: upstream-2013.2~b3
ImportĀ upstreamĀ versionĀ 2013.2~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
157
157
    if _drivers is None:
158
158
        _drivers = {}
159
159
        for notification_driver in CONF.notification_driver:
160
 
            add_driver(notification_driver)
161
 
 
 
160
            try:
 
161
                driver = importutils.import_module(notification_driver)
 
162
                _drivers[notification_driver] = driver
 
163
            except ImportError:
 
164
                LOG.exception(_("Failed to load notifier %s. "
 
165
                                "These notifications will not be sent.") %
 
166
                              notification_driver)
162
167
    return _drivers.values()
163
168
 
164
169
 
165
 
def add_driver(notification_driver):
166
 
    """Add a notification driver at runtime."""
167
 
    # Make sure the driver list is initialized.
168
 
    _get_drivers()
169
 
    if isinstance(notification_driver, basestring):
170
 
        # Load and add
171
 
        try:
172
 
            driver = importutils.import_module(notification_driver)
173
 
            _drivers[notification_driver] = driver
174
 
        except ImportError:
175
 
            LOG.exception(_("Failed to load notifier %s. "
176
 
                            "These notifications will not be sent.") %
177
 
                          notification_driver)
178
 
    else:
179
 
        # Driver is already loaded; just add the object.
180
 
        _drivers[notification_driver] = notification_driver
181
 
 
182
 
 
183
170
def _reset_drivers():
184
171
    """Used by unit tests to reset the drivers."""
185
172
    global _drivers