diff --git a/ceilometer/alarm/evaluator/__init__.py b/ceilometer/alarm/evaluator/__init__.py index 512965fd..b2030d96 100644 --- a/ceilometer/alarm/evaluator/__init__.py +++ b/ceilometer/alarm/evaluator/__init__.py @@ -18,6 +18,7 @@ import abc +import six from oslo.config import cfg @@ -33,11 +34,10 @@ OK = 'ok' ALARM = 'alarm' +@six.add_metaclass(abc.ABCMeta) class Evaluator(object): """Base class for alarm rule evaluator plugins.""" - __metaclass__ = abc.ABCMeta - def __init__(self, notifier): self.notifier = notifier self.api_client = None diff --git a/ceilometer/alarm/notifier/__init__.py b/ceilometer/alarm/notifier/__init__.py index 5ac58e48..ce155820 100644 --- a/ceilometer/alarm/notifier/__init__.py +++ b/ceilometer/alarm/notifier/__init__.py @@ -17,13 +17,13 @@ # under the License. import abc +import six +@six.add_metaclass(abc.ABCMeta) class AlarmNotifier(object): """Base class for alarm notifier plugins.""" - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def notify(self, action, alarm_id, previous, current, reason): """Notify that an alarm has been triggered. diff --git a/ceilometer/alarm/service.py b/ceilometer/alarm/service.py index a8e99a73..099e4837 100644 --- a/ceilometer/alarm/service.py +++ b/ceilometer/alarm/service.py @@ -19,6 +19,7 @@ # under the License. import abc +import six from oslo.config import cfg from stevedore import extension @@ -58,10 +59,9 @@ cfg.CONF.import_opt('partition_rpc_topic', 'ceilometer.alarm.rpc', LOG = log.getLogger(__name__) +@six.add_metaclass(abc.ABCMeta) class AlarmService(object): - __metaclass__ = abc.ABCMeta - EXTENSIONS_NAMESPACE = "ceilometer.alarm.evaluator" def _load_evaluators(self): diff --git a/ceilometer/collector/dispatcher/__init__.py b/ceilometer/collector/dispatcher/__init__.py index f9011053..fff32b20 100644 --- a/ceilometer/collector/dispatcher/__init__.py +++ b/ceilometer/collector/dispatcher/__init__.py @@ -17,12 +17,12 @@ # under the License. import abc +import six +@six.add_metaclass(abc.ABCMeta) class Base(object): - __metaclass__ = abc.ABCMeta - def __init__(self, conf): self.conf = conf diff --git a/ceilometer/compute/plugin.py b/ceilometer/compute/plugin.py index 9603f196..048ff2b0 100644 --- a/ceilometer/compute/plugin.py +++ b/ceilometer/compute/plugin.py @@ -19,16 +19,16 @@ """ import abc +import six from ceilometer import plugin +@six.add_metaclass(abc.ABCMeta) class ComputePollster(plugin.PollsterBase): """Base class for plugins that support the polling API on the compute node. """ - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def get_samples(self, manager, cache, instance): """Return a sequence of Counter instances from polling the resources. diff --git a/ceilometer/plugin.py b/ceilometer/plugin.py index 834027c2..1cbcb7b8 100644 --- a/ceilometer/plugin.py +++ b/ceilometer/plugin.py @@ -22,6 +22,7 @@ import abc import collections import fnmatch from oslo.config import cfg +import six # Import this option so every Notification plugin can use it freely. cfg.CONF.import_opt('notification_topics', @@ -37,11 +38,10 @@ class PluginBase(object): """ +@six.add_metaclass(abc.ABCMeta) class NotificationBase(PluginBase): """Base class for plugins that support the notification API.""" - __metaclass__ = abc.ABCMeta - @abc.abstractproperty def event_types(self): """Return a sequence of strings defining the event types to be @@ -85,11 +85,10 @@ class NotificationBase(PluginBase): return [] +@six.add_metaclass(abc.ABCMeta) class PollsterBase(PluginBase): """Base class for plugins that support the polling API.""" - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def get_samples(self, manager, cache): """Return a sequence of Counter instances from polling the resources. diff --git a/ceilometer/publisher/__init__.py b/ceilometer/publisher/__init__.py index df2b39e1..bda11383 100644 --- a/ceilometer/publisher/__init__.py +++ b/ceilometer/publisher/__init__.py @@ -21,6 +21,7 @@ import abc from stevedore import driver from ceilometer.openstack.common import network_utils +import six def get_publisher(url, namespace='ceilometer.publisher'): @@ -34,11 +35,10 @@ def get_publisher(url, namespace='ceilometer.publisher'): return loaded_driver.driver(parse_result) +@six.add_metaclass(abc.ABCMeta) class PublisherBase(object): """Base class for plugins that publish the sampler.""" - __metaclass__ = abc.ABCMeta - def __init__(self, parsed_url): pass diff --git a/ceilometer/storage/base.py b/ceilometer/storage/base.py index 7b59da80..0715ca43 100644 --- a/ceilometer/storage/base.py +++ b/ceilometer/storage/base.py @@ -21,6 +21,7 @@ import abc import datetime import math +import six from ceilometer.openstack.common import timeutils @@ -102,21 +103,19 @@ class Pagination(object): self.sort_dirs = sort_dirs +@six.add_metaclass(abc.ABCMeta) class StorageEngine(object): """Base class for storage engines.""" - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def get_connection(self, conf): """Return a Connection instance based on the configuration settings.""" +@six.add_metaclass(abc.ABCMeta) class Connection(object): """Base class for storage system connections.""" - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def __init__(self, conf): """Constructor.""" diff --git a/ceilometer/tests/db.py b/ceilometer/tests/db.py index 6a767cfe..e1d9f9c6 100644 --- a/ceilometer/tests/db.py +++ b/ceilometer/tests/db.py @@ -20,6 +20,7 @@ """Base classes for API tests.""" import os +import six import uuid import warnings @@ -78,8 +79,8 @@ class DB2FakeConnectionUrl(MongoDBFakeConnectionUrl): self.url = self.url.replace('mongodb:', 'db2:', 1) +@six.add_metaclass(test_base.SkipNotImplementedMeta) class MixinTestsWithBackendScenarios(object): - __metaclass__ = test_base.SkipNotImplementedMeta scenarios = [ ('sqlalchemy', dict(database_connection='sqlite://')), diff --git a/ceilometer/transformer/__init__.py b/ceilometer/transformer/__init__.py index acc4bc66..0f9b0db7 100644 --- a/ceilometer/transformer/__init__.py +++ b/ceilometer/transformer/__init__.py @@ -17,6 +17,8 @@ # under the License. import abc +import six + from stevedore import extension @@ -35,11 +37,10 @@ class TransformerExtensionManager(extension.ExtensionManager): return self.by_name[name] +@six.add_metaclass(abc.ABCMeta) class TransformerBase(object): """Base class for plugins that transform the sample.""" - __metaclass__ = abc.ABCMeta - def __init__(self, **kwargs): """Setup transformer.