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:
parent
c8ae150d60
commit
9d7d7d7cd6
@ -21,6 +21,7 @@ import itertools
|
|||||||
|
|
||||||
from ceilometer.openstack.common import context
|
from ceilometer.openstack.common import context
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
|
from ceilometer.openstack.common import service as os_service
|
||||||
from ceilometer import pipeline
|
from ceilometer import pipeline
|
||||||
from ceilometer import transformer
|
from ceilometer import transformer
|
||||||
|
|
||||||
@ -48,9 +49,10 @@ class PollingTask(object):
|
|||||||
"""Polling sample and publish into pipeline."""
|
"""Polling sample and publish into pipeline."""
|
||||||
|
|
||||||
|
|
||||||
class AgentManager(object):
|
class AgentManager(os_service.Service):
|
||||||
|
|
||||||
def __init__(self, extension_manager):
|
def __init__(self, extension_manager):
|
||||||
|
super(AgentManager, self).__init__()
|
||||||
|
|
||||||
self.pollster_manager = extension_manager
|
self.pollster_manager = extension_manager
|
||||||
|
|
||||||
@ -74,18 +76,17 @@ class AgentManager(object):
|
|||||||
|
|
||||||
return polling_tasks
|
return polling_tasks
|
||||||
|
|
||||||
def initialize_service_hook(self, service):
|
def start(self):
|
||||||
self.pipeline_manager = pipeline.setup_pipeline(
|
self.pipeline_manager = pipeline.setup_pipeline(
|
||||||
transformer.TransformerExtensionManager(
|
transformer.TransformerExtensionManager(
|
||||||
'ceilometer.transformer',
|
'ceilometer.transformer',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.service = service
|
|
||||||
for interval, task in self.setup_polling_tasks().iteritems():
|
for interval, task in self.setup_polling_tasks().iteritems():
|
||||||
self.service.tg.add_timer(interval,
|
self.tg.add_timer(interval,
|
||||||
self.interval_task,
|
self.interval_task,
|
||||||
task=task)
|
task=task)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def interval_task(task):
|
def interval_task(task):
|
||||||
|
@ -23,7 +23,6 @@ from stevedore import extension
|
|||||||
from ceilometer import agent
|
from ceilometer import agent
|
||||||
from ceilometer.openstack.common.gettextutils import _ # noqa
|
from ceilometer.openstack.common.gettextutils import _ # noqa
|
||||||
from ceilometer.openstack.common import log
|
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.openstack.common import service as os_service
|
||||||
from ceilometer import service
|
from ceilometer import service
|
||||||
|
|
||||||
@ -83,6 +82,4 @@ class AgentManager(agent.AgentManager):
|
|||||||
|
|
||||||
def agent_central():
|
def agent_central():
|
||||||
service.prepare_service()
|
service.prepare_service()
|
||||||
os_service.launch(rpc_service.Service(cfg.CONF.host,
|
os_service.launch(AgentManager()).wait()
|
||||||
'ceilometer.agent.central',
|
|
||||||
AgentManager())).wait()
|
|
||||||
|
@ -24,7 +24,6 @@ from ceilometer.compute.virt import inspector as virt_inspector
|
|||||||
from ceilometer import nova_client
|
from ceilometer import nova_client
|
||||||
from ceilometer.openstack.common.gettextutils import _ # noqa
|
from ceilometer.openstack.common.gettextutils import _ # noqa
|
||||||
from ceilometer.openstack.common import log
|
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.openstack.common import service as os_service
|
||||||
from ceilometer import service
|
from ceilometer import service
|
||||||
|
|
||||||
@ -84,6 +83,4 @@ class AgentManager(agent.AgentManager):
|
|||||||
|
|
||||||
def agent_compute():
|
def agent_compute():
|
||||||
service.prepare_service()
|
service.prepare_service()
|
||||||
os_service.launch(rpc_service.Service(cfg.CONF.host,
|
os_service.launch(AgentManager()).wait()
|
||||||
'ceilometer.agent.compute',
|
|
||||||
AgentManager())).wait()
|
|
||||||
|
@ -253,12 +253,12 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
|
|||||||
pub = self.mgr.pipeline_manager.pipelines[0].publishers[0]
|
pub = self.mgr.pipeline_manager.pipelines[0].publishers[0]
|
||||||
self.assertEqual(len(pub.samples), 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 = agent.AgentManager(self.mgr.pollster_manager)
|
||||||
mgr.create_polling_task = mock.MagicMock()
|
mgr.create_polling_task = mock.MagicMock()
|
||||||
service = mock.MagicMock()
|
mgr.tg = mock.MagicMock()
|
||||||
mgr.initialize_service_hook(service)
|
mgr.start()
|
||||||
self.assertTrue(service.tg.add_timer.called)
|
self.assertTrue(mgr.tg.add_timer.called)
|
||||||
|
|
||||||
def test_manager_exception_persistency(self):
|
def test_manager_exception_persistency(self):
|
||||||
self.pipeline_cfg.append({
|
self.pipeline_cfg.append({
|
||||||
|
Loading…
Reference in New Issue
Block a user