event: stop using global conf
Change-Id: Ie2d4b7173e8a26f095c0eba44b3d5368d20968bd
This commit is contained in:
@@ -286,10 +286,10 @@ class NotificationEventsConverter(object):
|
||||
return edef.to_event(notification_body)
|
||||
|
||||
|
||||
def setup_events(trait_plugin_mgr):
|
||||
def setup_events(conf, trait_plugin_mgr):
|
||||
"""Setup the event definitions from yaml config file."""
|
||||
return NotificationEventsConverter(
|
||||
declarative.load_definitions(cfg.CONF, [],
|
||||
cfg.CONF.event.definitions_cfg_file),
|
||||
declarative.load_definitions(conf, [],
|
||||
conf.event.definitions_cfg_file),
|
||||
trait_plugin_mgr,
|
||||
add_catchall=not cfg.CONF.event.drop_unmatched_notifications)
|
||||
add_catchall=not conf.event.drop_unmatched_notifications)
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import oslo_messaging
|
||||
from stevedore import extension
|
||||
@@ -29,6 +28,7 @@ class EventsNotificationEndpoint(object):
|
||||
super(EventsNotificationEndpoint, self).__init__()
|
||||
LOG.debug('Loading event definitions')
|
||||
self.event_converter = event_converter.setup_events(
|
||||
manager.conf,
|
||||
extension.ExtensionManager(
|
||||
namespace='ceilometer.event.trait_plugin'))
|
||||
self.manager = manager
|
||||
@@ -61,7 +61,7 @@ class EventsNotificationEndpoint(object):
|
||||
with self.manager.publisher() as p:
|
||||
p(event)
|
||||
except Exception:
|
||||
if not cfg.CONF.notification.ack_on_event_error:
|
||||
if not self.manager.conf.notification.ack_on_event_error:
|
||||
return oslo_messaging.NotificationResult.REQUEUE
|
||||
LOG.error(_LE('Fail to process a notification'), exc_info=True)
|
||||
return oslo_messaging.NotificationResult.HANDLED
|
||||
|
||||
@@ -768,7 +768,7 @@ class TestNotificationConverter(ConverterBase):
|
||||
self.CONF.set_override('drop_unmatched_notifications',
|
||||
False, group='event')
|
||||
|
||||
c = converter.setup_events(self.fake_plugin_mgr)
|
||||
c = converter.setup_events(self.CONF, self.fake_plugin_mgr)
|
||||
self.assertIsInstance(c, converter.NotificationEventsConverter)
|
||||
self.assertEqual(1, len(c.definitions))
|
||||
self.assertTrue(c.definitions[0].is_catchall)
|
||||
@@ -776,6 +776,6 @@ class TestNotificationConverter(ConverterBase):
|
||||
self.CONF.set_override('drop_unmatched_notifications',
|
||||
True, group='event')
|
||||
|
||||
c = converter.setup_events(self.fake_plugin_mgr)
|
||||
c = converter.setup_events(self.CONF, self.fake_plugin_mgr)
|
||||
self.assertIsInstance(c, converter.NotificationEventsConverter)
|
||||
self.assertEqual(0, len(c.definitions))
|
||||
|
||||
Reference in New Issue
Block a user