diff --git a/ceilometer/agent.py b/ceilometer/agent.py index 2bb0fb0b7..cf05f7dc6 100644 --- a/ceilometer/agent.py +++ b/ceilometer/agent.py @@ -21,6 +21,7 @@ import itertools from ceilometer.openstack.common import context from ceilometer.openstack.common import log +from ceilometer.openstack.common import service as os_service from ceilometer import pipeline from ceilometer import transformer @@ -48,9 +49,10 @@ class PollingTask(object): """Polling sample and publish into pipeline.""" -class AgentManager(object): +class AgentManager(os_service.Service): def __init__(self, extension_manager): + super(AgentManager, self).__init__() self.pollster_manager = extension_manager @@ -74,18 +76,17 @@ class AgentManager(object): return polling_tasks - def initialize_service_hook(self, service): + def start(self): self.pipeline_manager = pipeline.setup_pipeline( transformer.TransformerExtensionManager( 'ceilometer.transformer', ), ) - self.service = service for interval, task in self.setup_polling_tasks().iteritems(): - self.service.tg.add_timer(interval, - self.interval_task, - task=task) + self.tg.add_timer(interval, + self.interval_task, + task=task) @staticmethod def interval_task(task): diff --git a/ceilometer/central/manager.py b/ceilometer/central/manager.py index c9a06ed85..3fcbead1e 100644 --- a/ceilometer/central/manager.py +++ b/ceilometer/central/manager.py @@ -23,7 +23,6 @@ from stevedore import extension from ceilometer import agent from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log -from ceilometer.openstack.common.rpc import service as rpc_service from ceilometer.openstack.common import service as os_service from ceilometer import service @@ -83,6 +82,4 @@ class AgentManager(agent.AgentManager): def agent_central(): service.prepare_service() - os_service.launch(rpc_service.Service(cfg.CONF.host, - 'ceilometer.agent.central', - AgentManager())).wait() + os_service.launch(AgentManager()).wait() diff --git a/ceilometer/compute/manager.py b/ceilometer/compute/manager.py index 4b815dd49..4cdcbdb29 100644 --- a/ceilometer/compute/manager.py +++ b/ceilometer/compute/manager.py @@ -24,7 +24,6 @@ from ceilometer.compute.virt import inspector as virt_inspector from ceilometer import nova_client from ceilometer.openstack.common.gettextutils import _ # noqa from ceilometer.openstack.common import log -from ceilometer.openstack.common.rpc import service as rpc_service from ceilometer.openstack.common import service as os_service from ceilometer import service @@ -84,6 +83,4 @@ class AgentManager(agent.AgentManager): def agent_compute(): service.prepare_service() - os_service.launch(rpc_service.Service(cfg.CONF.host, - 'ceilometer.agent.compute', - AgentManager())).wait() + os_service.launch(AgentManager()).wait() diff --git a/ceilometer/tests/agentbase.py b/ceilometer/tests/agentbase.py index 0bc9fef44..127042cb9 100644 --- a/ceilometer/tests/agentbase.py +++ b/ceilometer/tests/agentbase.py @@ -253,12 +253,12 @@ class BaseAgentManagerTestCase(base.BaseTestCase): pub = self.mgr.pipeline_manager.pipelines[0].publishers[0] self.assertEqual(len(pub.samples), 0) - def test_agent_manager_initialize_service_hook(self): + def test_agent_manager_start(self): mgr = agent.AgentManager(self.mgr.pollster_manager) mgr.create_polling_task = mock.MagicMock() - service = mock.MagicMock() - mgr.initialize_service_hook(service) - self.assertTrue(service.tg.add_timer.called) + mgr.tg = mock.MagicMock() + mgr.start() + self.assertTrue(mgr.tg.add_timer.called) def test_manager_exception_persistency(self): self.pipeline_cfg.append({