diff --git a/ceilometer/pipeline.py b/ceilometer/pipeline.py index 7a47c42a..66cfe7bc 100644 --- a/ceilometer/pipeline.py +++ b/ceilometer/pipeline.py @@ -293,11 +293,7 @@ class EventSource(Source): def __init__(self, cfg): super(EventSource, self).__init__(cfg) - try: - self.events = cfg['events'] - except KeyError as err: - raise PipelineException( - "Required field %s not specified" % err.args[0], cfg) + self.events = cfg.get('events') self.check_source_filtering(self.events, 'events') def support_event(self, event_name): @@ -315,13 +311,8 @@ class SampleSource(Source): def __init__(self, cfg): super(SampleSource, self).__init__(cfg) - try: - # Support 'counters' for backward compatibility - self.meters = cfg.get('meters', cfg.get('counters')) - except KeyError as err: - raise PipelineException( - "Required field %s not specified" % err.args[0], cfg) - + # Support 'counters' for backward compatibility + self.meters = cfg.get('meters', cfg.get('counters')) try: self.interval = int(cfg.get('interval', 600)) except ValueError: diff --git a/ceilometer/tests/unit/test_decoupled_pipeline.py b/ceilometer/tests/unit/test_decoupled_pipeline.py index ac9a6d1d..ec418207 100644 --- a/ceilometer/tests/unit/test_decoupled_pipeline.py +++ b/ceilometer/tests/unit/test_decoupled_pipeline.py @@ -103,6 +103,10 @@ class TestDecoupledPipeline(pipeline_base.BasePipelineTestCase): del self.pipeline_cfg['sinks'] self._exception_create_pipelinemanager() + def test_source_no_meters_or_counters(self): + del self.pipeline_cfg['sources'][0]['counters'] + self._exception_create_pipelinemanager() + def test_source_dangling_sink(self): self.pipeline_cfg['sources'].append({ 'name': 'second_source',