diff --git a/ceilometer/pipeline.py b/ceilometer/pipeline.py index 8234f5333..b01e67508 100644 --- a/ceilometer/pipeline.py +++ b/ceilometer/pipeline.py @@ -129,6 +129,10 @@ class Pipeline(object): self.transformers = self._setup_transformers(cfg, transformer_manager) + self.resources = cfg.get('resources') or [] + if not isinstance(self.resources, list): + raise PipelineException("Resources should be a list", cfg) + def __str__(self): return self.name @@ -304,6 +308,7 @@ class PipelineManager(object): "name": pipeline_name "interval": interval_time "meters" : ["meter_1", "meter_2"], + "resources": ["resource_uri1", "resource_uri2"], "tranformers":[ {"name": "Transformer_1", "parameters": {"p1": "value"}}, @@ -329,6 +334,10 @@ class PipelineManager(object): "excluded meter names", wildcard and "excluded meter names", or only wildcard. + The resources is list of URI indicating the resources from where + the meters should be polled. It's optional and it's up to the + specific pollster to decide how to use it. + Transformer's name is plugin name in setup.py. Publisher's name is plugin name in setup.py diff --git a/ceilometer/tests/test_pipeline.py b/ceilometer/tests/test_pipeline.py index ccdd2f7cc..f706a4a8c 100644 --- a/ceilometer/tests/test_pipeline.py +++ b/ceilometer/tests/test_pipeline.py @@ -199,6 +199,11 @@ class TestPipeline(test.BaseTestCase): del self.pipeline_cfg[0]['publishers'] self._exception_create_pipelinemanager() + def test_invalid_resources(self): + invalid_resource = {'invalid': 1} + self.pipeline_cfg[0]['resources'] = invalid_resource + self._exception_create_pipelinemanager() + def test_check_counters_include_exclude_same(self): counter_cfg = ['a', '!a'] self.pipeline_cfg[0]['counters'] = counter_cfg @@ -1048,3 +1053,17 @@ class TestPipeline(test.BaseTestCase): self.assertEqual(len(publisher.samples), 0) pipe.flush(None) self.assertEqual(len(publisher.samples), 0) + + def test_resources(self): + resources = ['test1://', 'test2://'] + self.pipeline_cfg[0]['resources'] = resources + pipeline_manager = pipeline.PipelineManager(self.pipeline_cfg, + self.transformer_manager) + self.assertEqual(pipeline_manager.pipelines[0].resources, + resources) + + def test_no_resources(self): + pipeline_manager = pipeline.PipelineManager(self.pipeline_cfg, + self.transformer_manager) + self.assertEqual(len(pipeline_manager.pipelines[0].resources), + 0) diff --git a/etc/ceilometer/pipeline.yaml b/etc/ceilometer/pipeline.yaml index 731e755a5..5c20c1ca6 100644 --- a/etc/ceilometer/pipeline.yaml +++ b/etc/ceilometer/pipeline.yaml @@ -4,6 +4,7 @@ interval: 600 meters: - "*" + resources: transformers: publishers: - rpc://