Remove rpc service from agent manager

The agent doesn't need to act as a rpc server.
This patch migrate the agent manager from a rpc service to a normal service

Change-Id: I06f4546fa40f8702a75adc7f6f8e439d17af3de3
This commit is contained in:
Mehdi Abaakouk 2013-12-04 10:46:08 +01:00
parent c8ae150d60
commit 9d7d7d7cd6
4 changed files with 13 additions and 18 deletions

View File

@ -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):

View File

@ -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()

View File

@ -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()

View File

@ -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({