]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Apply six for metaclass
authorfujioka yuuichi <fujioka-yuuichi@zx.mxh.nes.nec.co.jp>
Thu, 10 Oct 2013 11:54:40 +0000 (20:54 +0900)
committerfujioka yuuichi <fujioka-yuuichi@zx.mxh.nes.nec.co.jp>
Mon, 18 Nov 2013 08:58:58 +0000 (17:58 +0900)
__metaclass__ cannot be used in python3.
six be used in general for python 3 compatibility.

Change-Id: Ib0d71b9676dc01390679396443575c05975d3b58
Closes-Bug: #1236648

27 files changed:
neutron/agent/firewall.py
neutron/agent/l2population_rpc.py
neutron/agent/linux/dhcp.py
neutron/agent/linux/interface.py
neutron/api/extensions.py
neutron/extensions/firewall.py
neutron/extensions/loadbalancer.py
neutron/extensions/metering.py
neutron/extensions/securitygroup.py
neutron/extensions/vpnaas.py
neutron/neutron_plugin_base_v2.py
neutron/plugins/cisco/l2device_plugin_base.py
neutron/plugins/embrane/l2base/support_base.py
neutron/plugins/ml2/driver_api.py
neutron/plugins/ml2/drivers/mech_agent.py
neutron/plugins/ml2/drivers/type_tunnel.py
neutron/plugins/nec/ofc_driver_base.py
neutron/plugins/nec/router_drivers.py
neutron/plugins/nicira/api_client/client.py
neutron/plugins/nicira/api_client/request.py
neutron/services/firewall/drivers/fwaas_base.py
neutron/services/loadbalancer/drivers/abstract_driver.py
neutron/services/metering/drivers/abstract_driver.py
neutron/services/service_base.py
neutron/services/vpn/device_drivers/__init__.py
neutron/services/vpn/device_drivers/ipsec.py
neutron/services/vpn/service_drivers/__init__.py

index 8ca6715027373519e7c7b713456d16b294141337..6c9cd25029b6e3af75bf40c20c3003bbb4366474 100644 (file)
 import abc
 import contextlib
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class FirewallDriver(object):
     """Firewall Driver base class.
 
@@ -52,8 +55,6 @@ class FirewallDriver(object):
       remote_group_id will also remaining membership update management
     """
 
-    __metaclass__ = abc.ABCMeta
-
     def prepare_port_filter(self, port):
         """Prepare filters for the port.
 
index f108c4ebdcd55e66b91a3ec71c0838ff1c1376b4..80c5a97de00629e8ee3bf7fe772bed1cd06a72e8 100644 (file)
 import abc
 
 from oslo.config import cfg
+import six
 
 from neutron.common import log
 
 
+@six.add_metaclass(abc.ABCMeta)
 class L2populationRpcCallBackMixin(object):
-    __metaclass__ = abc.ABCMeta
 
     @log.log
     def add_fdb_entries(self, context, fdb_entries, host=None):
index fdb6c9b757d620c3c58a848122ac86f18ee462b6..4d29405ea330679839d79e1f8081ce55f8da400c 100644 (file)
@@ -26,6 +26,7 @@ import uuid
 
 import netaddr
 from oslo.config import cfg
+import six
 
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import utils
@@ -101,8 +102,8 @@ class NetModel(DictModel):
         return self._ns_name
 
 
+@six.add_metaclass(abc.ABCMeta)
 class DhcpBase(object):
-    __metaclass__ = abc.ABCMeta
 
     def __init__(self, conf, network, root_helper='sudo',
                  version=None, plugin=None):
index 42a1f82d15d9fcbe49865d859156bf3902818634..a39adb360a664bcaf1dd0f2d6e86c67215eb44f2 100644 (file)
@@ -19,6 +19,7 @@ import abc
 
 import netaddr
 from oslo.config import cfg
+import six
 
 from neutron.agent.common import config
 from neutron.agent.linux import ip_lib
@@ -59,8 +60,8 @@ OPTS = [
 ]
 
 
+@six.add_metaclass(abc.ABCMeta)
 class LinuxInterfaceDriver(object):
-    __metaclass__ = abc.ABCMeta
 
     # from linux IF_NAMESIZE
     DEV_NAME_LEN = 14
index 5919d8396508672416e05128f38c86e4084fccc8..e425cbb0463084487918b42c52845f419c44547f 100644 (file)
@@ -22,6 +22,7 @@ import os
 
 from oslo.config import cfg
 import routes
+import six
 import webob.dec
 import webob.exc
 
@@ -36,8 +37,8 @@ from neutron import wsgi
 LOG = logging.getLogger(__name__)
 
 
+@six.add_metaclass(ABCMeta)
 class PluginInterface(object):
-    __metaclass__ = ABCMeta
 
     @classmethod
     def __subclasshook__(cls, klass):
index a4d1580250d8254b08fbf262621992f68690c9ff..d6e43a5a15671f61148ac4f7889334d9f4f6463f 100644 (file)
@@ -20,6 +20,7 @@
 import abc
 
 from oslo.config import cfg
+import six
 
 from neutron.api import extensions
 from neutron.api.v2 import attributes as attr
@@ -376,8 +377,8 @@ class Firewall(extensions.ExtensionDescriptor):
             return {}
 
 
+@six.add_metaclass(abc.ABCMeta)
 class FirewallPluginBase(ServicePluginBase):
-    __metaclass__ = abc.ABCMeta
 
     def get_plugin_name(self):
         return constants.FIREWALL
index d2dde8adb7f968359b8276bd51b98076a3800d79..2cbd914e704444b5043516ae3c85e9a8515fc297 100644 (file)
@@ -18,6 +18,7 @@
 import abc
 
 from oslo.config import cfg
+import six
 
 from neutron.api import extensions
 from neutron.api.v2 import attributes as attr
@@ -376,8 +377,8 @@ class Loadbalancer(extensions.ExtensionDescriptor):
             return {}
 
 
+@six.add_metaclass(abc.ABCMeta)
 class LoadBalancerPluginBase(ServicePluginBase):
-    __metaclass__ = abc.ABCMeta
 
     def get_plugin_name(self):
         return constants.LOADBALANCER
index 67ec4d5907192b9bca4ef7195d6218aa27e4ef73..f9417b53c2d62554d2e704c4abc78fc178ee00a6 100644 (file)
@@ -16,6 +16,8 @@
 
 import abc
 
+import six
+
 from neutron.api import extensions
 from neutron.api.v2 import attributes as attr
 from neutron.api.v2 import base
@@ -147,8 +149,8 @@ class Metering(extensions.ExtensionDescriptor):
             return {}
 
 
+@six.add_metaclass(abc.ABCMeta)
 class MeteringPluginBase(service_base.ServicePluginBase):
-    __metaclass__ = abc.ABCMeta
 
     def get_plugin_name(self):
         return constants.METERING
index 85d499ad59f77dbd811532a31872f06840d716b8..3fcf15a78f0e847b2c1566f373409bb9d850f81c 100644 (file)
@@ -19,6 +19,7 @@ from abc import ABCMeta
 from abc import abstractmethod
 
 from oslo.config import cfg
+import six
 
 from neutron.api import extensions
 from neutron.api.v2 import attributes as attr
@@ -291,8 +292,8 @@ class Securitygroup(extensions.ExtensionDescriptor):
             return {}
 
 
+@six.add_metaclass(ABCMeta)
 class SecurityGroupPluginBase(object):
-    __metaclass__ = ABCMeta
 
     @abstractmethod
     def create_security_group(self, context, security_group):
index 44d12f683bb7d23d44741a08d504278e13ede9ab..8e42b62f99102556373f96de7175eca02ed4d34f 100644 (file)
@@ -20,6 +20,7 @@
 import abc
 
 from oslo.config import cfg
+import six
 
 from neutron.api import extensions
 from neutron.api.v2 import attributes as attr
@@ -405,8 +406,8 @@ class Vpnaas(extensions.ExtensionDescriptor):
             return {}
 
 
+@six.add_metaclass(abc.ABCMeta)
 class VPNPluginBase(ServicePluginBase):
-    __metaclass__ = abc.ABCMeta
 
     def get_plugin_name(self):
         return constants.VPN
index fb60ffe5995f4084328a445885d68c4ef9952067..43b99f5da88b40f3f5a37277a235d4849e7d42a9 100644 (file)
@@ -23,10 +23,11 @@ methods that needs to be implemented by a v2 Neutron Plug-in.
 
 from abc import ABCMeta, abstractmethod
 
+import six
 
-class NeutronPluginBaseV2(object):
 
-    __metaclass__ = ABCMeta
+@six.add_metaclass(ABCMeta)
+class NeutronPluginBaseV2(object):
 
     @abstractmethod
     def create_subnet(self, context, subnet):
index cbac97585ff6ad56148b40a8d1c53a2b2576a07f..453302fcbc7e2797d30e388df0e5142c5916d9f1 100644 (file)
 from abc import ABCMeta, abstractmethod
 import inspect
 
+import six
 
+
+@six.add_metaclass(ABCMeta)
 class L2DevicePluginBase(object):
     """Base class for a device-specific plugin.
 
@@ -28,8 +31,6 @@ class L2DevicePluginBase(object):
     the configuration on each device.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def get_all_networks(self, tenant_id, **kwargs):
         """Get newtorks.
index ee4ca65cc50324f39e9a524e10b3d3fb371a1284..a2b7e534245fa62482cd50ac378e2f6d7d93a513 100644 (file)
 
 import abc
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class SupportBase(object):
     """abstract support class.
 
@@ -27,7 +30,6 @@ class SupportBase(object):
     the L2 base for Embrane plugin.
 
     """
-    __metaclass__ = abc.ABCMeta
 
     @abc.abstractmethod
     def __init__(self):
index 8925a7666aa9ed47d49685e19c4879846c2f54c7..d7663042b9a851e5c904e3b1118d6927f091c59e 100644 (file)
@@ -15,6 +15,8 @@
 
 from abc import ABCMeta, abstractmethod, abstractproperty
 
+import six
+
 # The following keys are used in the segment dictionaries passed via
 # the driver API. These are defined separately from similar keys in
 # neutron.extensions.providernet so that drivers don't need to change
@@ -26,6 +28,7 @@ PHYSICAL_NETWORK = 'physical_network'
 SEGMENTATION_ID = 'segmentation_id'
 
 
+@six.add_metaclass(ABCMeta)
 class TypeDriver(object):
     """Define stable abstract interface for ML2 type drivers.
 
@@ -43,8 +46,6 @@ class TypeDriver(object):
     either be excluded or stored as None.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def get_type(self):
         """Get driver's network type.
@@ -128,6 +129,7 @@ class TypeDriver(object):
         pass
 
 
+@six.add_metaclass(ABCMeta)
 class NetworkContext(object):
     """Context passed to MechanismDrivers for changes to network resources.
 
@@ -137,8 +139,6 @@ class NetworkContext(object):
     MechanismDrivers can freely access the same information.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractproperty
     def current(self):
         """Return the current state of the network.
@@ -165,6 +165,7 @@ class NetworkContext(object):
         pass
 
 
+@six.add_metaclass(ABCMeta)
 class SubnetContext(object):
     """Context passed to MechanismDrivers for changes to subnet resources.
 
@@ -174,8 +175,6 @@ class SubnetContext(object):
     MechanismDrivers can freely access the same information.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractproperty
     def current(self):
         """Return the current state of the subnet.
@@ -197,6 +196,7 @@ class SubnetContext(object):
         pass
 
 
+@six.add_metaclass(ABCMeta)
 class PortContext(object):
     """Context passed to MechanismDrivers for changes to port resources.
 
@@ -206,8 +206,6 @@ class PortContext(object):
     freely access the same information.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractproperty
     def current(self):
         """Return the current state of the port.
@@ -262,6 +260,7 @@ class PortContext(object):
         pass
 
 
+@six.add_metaclass(ABCMeta)
 class MechanismDriver(object):
     """Define stable abstract interface for ML2 mechanism drivers.
 
@@ -283,8 +282,6 @@ class MechanismDriver(object):
     methods that are part of the database transaction.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def initialize(self):
         """Perform driver initialization.
index a89956f9066746ec8e497f603e13bdb68cd7551f..7bf21a49752b440e895b8114ecde8ac2f2ec9e66 100644 (file)
 
 from abc import ABCMeta, abstractmethod
 
+import six
+
 from neutron.openstack.common import log
 from neutron.plugins.ml2 import driver_api as api
 
 LOG = log.getLogger(__name__)
 
 
+@six.add_metaclass(ABCMeta)
 class AgentMechanismDriverBase(api.MechanismDriver):
     """Base class for drivers that attach to networks using an L2 agent.
 
@@ -35,8 +38,6 @@ class AgentMechanismDriverBase(api.MechanismDriver):
     check_segment_for_agent().
     """
 
-    __metaclass__ = ABCMeta
-
     def __init__(self, agent_type, vif_type, cap_port_filter):
         """Initialize base class for specific L2 agent type.
 
index a761bf26b17be17e4634f7fded6412d8fc68f204..5081d9e57fc516634efe3cb59a4e871ffaabd453 100644 (file)
@@ -14,6 +14,8 @@
 #    under the License.
 from abc import ABCMeta, abstractmethod
 
+import six
+
 from neutron.common import exceptions as exc
 from neutron.common import topics
 from neutron.openstack.common import log
@@ -24,6 +26,7 @@ LOG = log.getLogger(__name__)
 TUNNEL = 'tunnel'
 
 
+@six.add_metaclass(ABCMeta)
 class TunnelTypeDriver(api.TypeDriver):
     """Define stable abstract interface for ML2 type drivers.
 
@@ -31,8 +34,6 @@ class TunnelTypeDriver(api.TypeDriver):
     methods to manage these endpoints.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def add_endpoint(self, ip):
         """Register the endpoint in the type_driver database.
index 680286101db769c75f597a58e63f9e016d0f8aa3..e367ba3442a36853911cac70981954319a9aca5c 100644 (file)
 
 from abc import ABCMeta, abstractmethod
 
+import six
 
+
+@six.add_metaclass(ABCMeta)
 class OFCDriverBase(object):
     """OpenFlow Controller (OFC) Driver Specification.
 
@@ -26,8 +29,6 @@ class OFCDriverBase(object):
     It would be better that other methods like update_* are implemented.
     """
 
-    __metaclass__ = ABCMeta
-
     @abstractmethod
     def create_tenant(self, description, tenant_id=None):
         """Create a new tenant at OpenFlow Controller.
index b16c4d8a0f21c79d6a0cc383f2f8e2892fea19a0..9781f0b6e0ec58597f35616ccb4553cbd154cb50 100644 (file)
@@ -19,6 +19,8 @@
 import abc
 import httplib
 
+import six
+
 from neutron.common import log as call_log
 from neutron.common import utils
 from neutron.openstack.common import excutils
@@ -31,10 +33,9 @@ LOG = logging.getLogger(__name__)
 PROVIDER_OPENFLOW = nconst.ROUTER_PROVIDER_OPENFLOW
 
 
+@six.add_metaclass(abc.ABCMeta)
 class RouterDriverBase(object):
 
-    __metaclass__ = abc.ABCMeta
-
     def __init__(self, plugin, ofc_manager):
         self.plugin = plugin
         self.ofc = ofc_manager
index 01a068f77e6e79905e398c6aa263210855a62c5f..6a86695eea97e048e64f23838a473bf2701f5a70 100644 (file)
@@ -24,6 +24,7 @@ import httplib
 import logging
 import time
 
+import six
 
 from neutron.plugins.nicira.api_client.common import (
     _conn_str)
@@ -37,6 +38,7 @@ DEFAULT_CONCURRENT_CONNECTIONS = 3
 DEFAULT_CONNECT_TIMEOUT = 5
 
 
+@six.add_metaclass(ABCMeta)
 class NvpApiClient(object):
     '''An abstract baseclass for all NvpApiClient implementations.
 
@@ -44,8 +46,6 @@ class NvpApiClient(object):
     coroutine-based classes.
     '''
 
-    __metaclass__ = ABCMeta
-
     CONN_IDLE_TIMEOUT = 60 * 15
 
     def _create_connection(self, host, port, is_ssl):
index 056e55cd8bb4d42f3b5f4208dec4ae6869e39776..c54ed1bdfe56c7b804297d645b7b0682c1c8ba5a 100644 (file)
@@ -26,6 +26,8 @@ import logging
 import time
 import urlparse
 
+import six
+
 from neutron.openstack.common import excutils
 from neutron.plugins.nicira.api_client.common import (
     _conn_str)
@@ -45,6 +47,7 @@ DOWNLOAD_TIMEOUT = 180  # The UI code has a coorespoind 190 sec timeout
                         # for downloads, see: django/nvp_console/views.py
 
 
+@six.add_metaclass(ABCMeta)
 class NvpApiRequest(object):
     '''An abstract baseclass for all ApiRequest implementations.
 
@@ -52,8 +55,6 @@ class NvpApiRequest(object):
     gevent-based ApiRequest classes.
     '''
 
-    __metaclass__ = ABCMeta
-
     # List of allowed status codes.
     ALLOWED_STATUS_CODES = [
         httplib.OK,
index 66bf867c11a5934813818229ad1a592214fdb686..7128e251a2af17b1263013d9ae3cb7608124db50 100644 (file)
 
 import abc
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class FwaasDriverBase(object):
     """Firewall as a Service Driver base class.
 
@@ -60,8 +63,6 @@ class FwaasDriverBase(object):
     application of rules.
     """
 
-    __metaclass__ = abc.ABCMeta
-
     @abc.abstractmethod
     def create_firewall(self, apply_list, firewall):
         """Create the Firewall with default (drop all) policy.
index 50212d1fc08a0f690b07bdc7bdd62f7ac5ba402c..b3519bffe5ea8efe6da50b2770adb4af139b4d70 100644 (file)
 
 import abc
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class LoadBalancerAbstractDriver(object):
     """Abstract lbaas driver that expose ~same API as lbaas plugin.
 
@@ -27,7 +30,6 @@ class LoadBalancerAbstractDriver(object):
     Get operations are not part of the API - it will be handled
     by the lbaas plugin.
     """
-    __metaclass__ = abc.ABCMeta
 
     @abc.abstractmethod
     def create_vip(self, context, vip):
index a5e5ca193c240f8d38b7aff0583ce01b2d89bd71..884fbba50af559c40cf5eed94c0dfad0802eaf49 100644 (file)
 
 import abc
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class MeteringAbstractDriver(object):
     """Abstract Metering driver."""
-    __metaclass__ = abc.ABCMeta
 
     def __init__(self, plugin, conf):
         pass
index a70c17f271c703a29827eac98202b28f4da5d3f3..2730dee6de96b614890bbc0d6b1c3b5606ca96a4 100644 (file)
@@ -17,6 +17,8 @@
 
 import abc
 
+import six
+
 from neutron.api import extensions
 from neutron.db import servicetype_db as sdb
 from neutron.openstack.common import importutils
@@ -26,9 +28,9 @@ from neutron.services import provider_configuration as pconf
 LOG = logging.getLogger(__name__)
 
 
+@six.add_metaclass(abc.ABCMeta)
 class ServicePluginBase(extensions.PluginInterface):
     """Define base interface for any Advanced Service plugin."""
-    __metaclass__ = abc.ABCMeta
     supported_extension_aliases = []
 
     @abc.abstractmethod
index c15fcbfd9b4133ee20672d97a2d94aaa452ef306..c6d5f69e316c50690f7a3c2f8e70971f1dc35e89 100644 (file)
 #    under the License.
 import abc
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class DeviceDriver(object):
-    __metaclass__ = abc.ABCMeta
 
     def __init__(self, agent, host):
         pass
index fda64798bbb1857ae8e14362d47eed18f02b6f56..ad16996dc54aeaef0df8c41be7a96f1a7b622d39 100644 (file)
@@ -23,6 +23,7 @@ import shutil
 import jinja2
 import netaddr
 from oslo.config import cfg
+import six
 
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import utils
@@ -85,13 +86,13 @@ def _get_template(template_file):
     return JINJA_ENV.get_template(template_file)
 
 
+@six.add_metaclass(abc.ABCMeta)
 class BaseSwanProcess():
     """Swan Family Process Manager
 
     This class manages start/restart/stop ipsec process.
     This class create/delete config template
     """
-    __metaclass__ = abc.ABCMeta
 
     binary = "ipsec"
     CONFIG_DIRS = [
@@ -465,6 +466,7 @@ class IPsecVpnDriverApi(proxy.RpcProxy):
                          topic=self.topic)
 
 
+@six.add_metaclass(abc.ABCMeta)
 class IPsecDriver(device_drivers.DeviceDriver):
     """VPN Device Driver for IPSec.
 
@@ -478,7 +480,6 @@ class IPsecDriver(device_drivers.DeviceDriver):
     #   1.0 Initial version
 
     RPC_API_VERSION = '1.0'
-    __metaclass__ = abc.ABCMeta
 
     def __init__(self, agent, host):
         self.agent = agent
index 4996882e1c08b2aa977c23b853cd3e88c0197032..edb27abec8ccf840d42996f231006e2c5f6ef895 100644 (file)
 
 import abc
 
+import six
 
+
+@six.add_metaclass(abc.ABCMeta)
 class VpnDriver(object):
-    __metaclass__ = abc.ABCMeta
 
     @property
     def service_type(self):