diff --git a/ceilometer/agent.py b/ceilometer/agent.py index fad91823a..d602d73fe 100644 --- a/ceilometer/agent.py +++ b/ceilometer/agent.py @@ -20,6 +20,8 @@ import abc import collections import itertools +import six + from ceilometer.openstack.common import context from ceilometer.openstack.common import log from ceilometer.openstack.common import service as os_service @@ -29,6 +31,7 @@ from ceilometer import transformer LOG = log.getLogger(__name__) +@six.add_metaclass(abc.ABCMeta) class PollingTask(object): """Polling task for polling samples and inject into pipeline. A polling task can be invoked periodically or only once. @@ -56,6 +59,7 @@ class PollingTask(object): """Polling sample and publish into pipeline.""" +@six.add_metaclass(abc.ABCMeta) class AgentManager(os_service.Service): def __init__(self, extension_manager): diff --git a/ceilometer/compute/pollsters/disk.py b/ceilometer/compute/pollsters/disk.py index acbdcb4c2..cd1d4cb2a 100644 --- a/ceilometer/compute/pollsters/disk.py +++ b/ceilometer/compute/pollsters/disk.py @@ -21,6 +21,8 @@ import abc import collections +import six + from ceilometer.compute import plugin from ceilometer.compute.pollsters import util from ceilometer.compute.virt import inspector as virt_inspector @@ -37,6 +39,7 @@ DiskIOData = collections.namedtuple( ) +@six.add_metaclass(abc.ABCMeta) class _Base(plugin.ComputePollster): DISKIO_USAGE_MESSAGE = ' '.join(["DISKIO USAGE:", diff --git a/ceilometer/tests/agentbase.py b/ceilometer/tests/agentbase.py index 890ac1487..c9c6dc29d 100644 --- a/ceilometer/tests/agentbase.py +++ b/ceilometer/tests/agentbase.py @@ -23,10 +23,10 @@ import abc import datetime import mock +import six from stevedore import extension from stevedore.tests import manager as extension_tests -from ceilometer import agent from ceilometer.openstack.common.fixture import config from ceilometer import pipeline from ceilometer import plugin @@ -68,6 +68,7 @@ class TestPollsterException(TestPollster): raise Exception() +@six.add_metaclass(abc.ABCMeta) class BaseAgentManagerTestCase(base.BaseTestCase): class Pollster(TestPollster): @@ -154,13 +155,13 @@ class BaseAgentManagerTestCase(base.BaseTestCase): ) @abc.abstractmethod - def setup_manager(self): - """Setup subclass specific managers.""" + def create_manager(self): + """Return subclass specific manager.""" @mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock()) def setUp(self): super(BaseAgentManagerTestCase, self).setUp() - self.setup_manager() + self.mgr = self.create_manager() self.mgr.pollster_manager = self.create_extension_manager() self.pipeline_cfg = [{ 'name': "test_pipeline", @@ -276,7 +277,8 @@ class BaseAgentManagerTestCase(base.BaseTestCase): self.assertEqual(len(pub.samples), 0) def test_agent_manager_start(self): - mgr = agent.AgentManager(self.mgr.pollster_manager) + mgr = self.create_manager() + mgr.pollster_manager = self.mgr.pollster_manager mgr.create_polling_task = mock.MagicMock() mgr.tg = mock.MagicMock() mgr.start() diff --git a/ceilometer/tests/central/test_manager.py b/ceilometer/tests/central/test_manager.py index dbfb885fa..6db3606bd 100644 --- a/ceilometer/tests/central/test_manager.py +++ b/ceilometer/tests/central/test_manager.py @@ -35,9 +35,9 @@ class TestManager(test.BaseTestCase): class TestRunTasks(agentbase.BaseAgentManagerTestCase): - - def setup_manager(self): - self.mgr = manager.AgentManager() + @staticmethod + def create_manager(): + return manager.AgentManager() def setUp(self): super(TestRunTasks, self).setUp() diff --git a/ceilometer/tests/compute/test_manager.py b/ceilometer/tests/compute/test_manager.py index 84a371be3..de3466ac3 100644 --- a/ceilometer/tests/compute/test_manager.py +++ b/ceilometer/tests/compute/test_manager.py @@ -45,8 +45,9 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase): def _raise_exception(self): raise Exception - def setup_manager(self): - self.mgr = manager.AgentManager() + @staticmethod + def create_manager(): + return manager.AgentManager() @mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock()) def setUp(self):