diff --git a/ceilometer/cmd/eventlet/sample.py b/ceilometer/cmd/eventlet/sample.py index c08212e6..6f5794a7 100644 --- a/ceilometer/cmd/eventlet/sample.py +++ b/ceilometer/cmd/eventlet/sample.py @@ -23,11 +23,11 @@ import sys from oslo_config import cfg from oslo_context import context from oslo_utils import timeutils +from stevedore import extension from ceilometer import pipeline from ceilometer import sample from ceilometer import service -from ceilometer import transformer def send_sample(): @@ -79,10 +79,7 @@ def send_sample(): root_logger.setLevel(logging.DEBUG) pipeline_manager = pipeline.setup_pipeline( - transformer.TransformerExtensionManager( - 'ceilometer.transformer', - ), - ) + extension.ExtensionManager('ceilometer.transformer')) with pipeline_manager.publisher(context.get_admin_context()) as p: p([sample.Sample( diff --git a/ceilometer/notifier.py b/ceilometer/notifier.py index 3490fcc6..f3240688 100644 --- a/ceilometer/notifier.py +++ b/ceilometer/notifier.py @@ -19,7 +19,6 @@ from stevedore import extension from ceilometer.i18n import _ from ceilometer import pipeline -from ceilometer import transformer LOG = logging.getLogger(__name__) @@ -51,7 +50,7 @@ def _load_pipeline_manager(): global _pipeline_manager _pipeline_manager = pipeline.setup_pipeline( - transformer.TransformerExtensionManager( + extension.ExtensionManager( 'ceilometer.transformer', ), ) diff --git a/ceilometer/pipeline.py b/ceilometer/pipeline.py index 9026dfed..0b4bf82a 100644 --- a/ceilometer/pipeline.py +++ b/ceilometer/pipeline.py @@ -25,14 +25,15 @@ from oslo_config import cfg from oslo_log import log from oslo_utils import timeutils import six +from stevedore import extension import yaml + from ceilometer.event.storage import models from ceilometer.i18n import _ from ceilometer import publisher from ceilometer.publisher import utils as publisher_utils from ceilometer import sample as sample_util -from ceilometer import transformer as xformer OPTS = [ @@ -376,7 +377,7 @@ class Sink(object): for transformer in self.transformer_cfg: parameter = transformer['parameters'] or {} try: - ext = transformer_manager.get_ext(transformer['name']) + ext = transformer_manager[transformer['name']] except KeyError: raise PipelineException( "No transformer named %s loaded" % transformer['name'], @@ -732,7 +733,7 @@ def _setup_pipeline_manager(cfg_file, transformer_manager, p_type=SAMPLE_TYPE): return PipelineManager(pipeline_cfg, transformer_manager or - xformer.TransformerExtensionManager( + extension.ExtensionManager( 'ceilometer.transformer', ), p_type) diff --git a/ceilometer/tests/agent/agentbase.py b/ceilometer/tests/agent/agentbase.py index 51217b1d..ce0face9 100644 --- a/ceilometer/tests/agent/agentbase.py +++ b/ceilometer/tests/agent/agentbase.py @@ -37,7 +37,6 @@ from ceilometer import publisher from ceilometer.publisher import test as test_publisher from ceilometer import sample from ceilometer.tests import base -from ceilometer import transformer from ceilometer import utils @@ -173,7 +172,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase): params = [] def setup_pipeline(self): - self.transformer_manager = transformer.TransformerExtensionManager( + self.transformer_manager = extension.ExtensionManager( 'ceilometer.transformer', ) self.mgr.pipeline_manager = pipeline.PipelineManager( diff --git a/ceilometer/tests/pipeline_base.py b/ceilometer/tests/pipeline_base.py index 2e06dd4e..9f05ae78 100644 --- a/ceilometer/tests/pipeline_base.py +++ b/ceilometer/tests/pipeline_base.py @@ -138,18 +138,12 @@ class BasePipelineTestCase(base.BaseTestCase): resource_metadata={} ) - self.useFixture(mockpatch.PatchObject( - transformer.TransformerExtensionManager, "__init__", - side_effect=self.fake_tem_init)) - - self.useFixture(mockpatch.PatchObject( - transformer.TransformerExtensionManager, "get_ext", - side_effect=self.fake_tem_get_ext)) - self.useFixture(mockpatch.PatchObject( publisher, 'get_publisher', side_effect=self.get_publisher)) - self.transformer_manager = transformer.TransformerExtensionManager() + self.transformer_manager = mock.MagicMock() + self.transformer_manager.__getitem__.side_effect = \ + self.fake_tem_get_ext self._setup_pipeline_cfg() diff --git a/ceilometer/tests/test_notifier.py b/ceilometer/tests/test_notifier.py index 0ccdb8ab..fb40ec84 100644 --- a/ceilometer/tests/test_notifier.py +++ b/ceilometer/tests/test_notifier.py @@ -15,10 +15,10 @@ """Tests for ceilometer/notifier.py """ from oslotest import base +from stevedore import extension from ceilometer import notifier from ceilometer import pipeline -from ceilometer import transformer MESSAGE = { @@ -64,7 +64,7 @@ MESSAGE = { class TestNotifier(base.BaseTestCase): def test_process_notification(self): - transformer_manager = transformer.TransformerExtensionManager( + transformer_manager = extension.ExtensionManager( 'ceilometer.transformer', ) notifier._pipeline_manager = pipeline.PipelineManager( diff --git a/ceilometer/transformer/__init__.py b/ceilometer/transformer/__init__.py index 3df6d7f3..c3124c2e 100644 --- a/ceilometer/transformer/__init__.py +++ b/ceilometer/transformer/__init__.py @@ -17,22 +17,6 @@ import abc import collections import six -from stevedore import extension - - -class TransformerExtensionManager(extension.ExtensionManager): - - def __init__(self, namespace): - super(TransformerExtensionManager, self).__init__( - namespace=namespace, - invoke_on_load=False, - invoke_args=(), - invoke_kwds={} - ) - self.by_name = dict((e.name, e) for e in self.extensions) - - def get_ext(self, name): - return self.by_name[name] @six.add_metaclass(abc.ABCMeta)