From c47bb5b89e04403b46c224c1bda13d3d0e11eedd Mon Sep 17 00:00:00 2001 From: fujioka yuuichi Date: Thu, 17 Oct 2013 09:53:30 +0900 Subject: [PATCH] Apply six for metaclass __metaclass__ cannot be used in python3. six be used in general for python 3 compatibility. Change-Id: I1d21c82163a1c00bbf4fbf3c9dd513f1c0591b00 Closes-Bug: #1236648 --- cinder/api/openstack/wsgi.py | 4 ++-- cinder/keymgr/key.py | 5 +++-- cinder/keymgr/key_mgr.py | 5 +++-- cinder/taskflow/patterns/base.py | 5 +++-- cinder/taskflow/task.py | 5 +++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 5b54cceefb9..64a5fecb272 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -29,6 +29,7 @@ from cinder import utils from cinder import wsgi from lxml import etree +import six from xml.dom import minidom from xml.parsers import expat @@ -1027,11 +1028,10 @@ class ControllerMetaclass(type): cls_dict) +@six.add_metaclass(ControllerMetaclass) class Controller(object): """Default controller.""" - __metaclass__ = ControllerMetaclass - _view_builder_class = None def __init__(self, view_builder=None): diff --git a/cinder/keymgr/key.py b/cinder/keymgr/key.py index e0a3f415f47..a5debac3249 100644 --- a/cinder/keymgr/key.py +++ b/cinder/keymgr/key.py @@ -25,12 +25,13 @@ from Java. import abc +import six + +@six.add_metaclass(abc.ABCMeta) class Key(object): """Base class to represent all keys.""" - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def get_algorithm(self): """Returns the key's algorithm. diff --git a/cinder/keymgr/key_mgr.py b/cinder/keymgr/key_mgr.py index bd5669fa56e..b47c79e9055 100644 --- a/cinder/keymgr/key_mgr.py +++ b/cinder/keymgr/key_mgr.py @@ -20,7 +20,10 @@ Key manager API import abc +import six + +@six.add_metaclass(abc.ABCMeta) class KeyManager(object): """Base Key Manager Interface @@ -28,8 +31,6 @@ class KeyManager(object): Key Manager is responsible for creating, reading, and deleting keys. """ - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def create_key(self, ctxt, algorithm='AES', length=256, expiration=None, **kwargs): diff --git a/cinder/taskflow/patterns/base.py b/cinder/taskflow/patterns/base.py index edb53807118..7f47debd914 100644 --- a/cinder/taskflow/patterns/base.py +++ b/cinder/taskflow/patterns/base.py @@ -19,6 +19,8 @@ import abc import threading +import six + from cinder.openstack.common import uuidutils from cinder.taskflow import decorators @@ -27,6 +29,7 @@ from cinder.taskflow import states from cinder.taskflow import utils +@six.add_metaclass(abc.ABCMeta) class Flow(object): """The base abstract class of all flow implementations. @@ -45,8 +48,6 @@ class Flow(object): - soft_reset """ - __metaclass__ = abc.ABCMeta - # Common states that certain actions can be performed in. If the flow # is not in these sets of states then it is likely that the flow operation # can not succeed. diff --git a/cinder/taskflow/task.py b/cinder/taskflow/task.py index 57753d759b3..3d5d2eeed0f 100644 --- a/cinder/taskflow/task.py +++ b/cinder/taskflow/task.py @@ -18,15 +18,16 @@ import abc +import six + from cinder.taskflow import utils +@six.add_metaclass(abc.ABCMeta) class Task(object): """An abstraction that defines a potential piece of work that can be applied and can be reverted to undo the work as a single unit. """ - __metaclass__ = abc.ABCMeta - def __init__(self, name): self.name = name # An *immutable* input 'resource' name set this task depends