Apply six for metaclass

__metaclass__ cannot be used in python3.
six be used in general for python 3 compatibility.

Change-Id: Ib0d71b9676dc01390679396443575c05975d3b58
Closes-Bug: #1236648
This commit is contained in:
fujioka yuuichi 2013-10-10 20:54:40 +09:00
parent bc18247313
commit 6096dd5892
27 changed files with 76 additions and 47 deletions

View File

@ -18,7 +18,10 @@
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.

View File

@ -20,12 +20,13 @@
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):

View 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):

View 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

View 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):

View 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

View 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

View 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

View 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):

View 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

View File

@ -23,11 +23,12 @@ methods that needs to be implemented by a v2 Neutron Plug-in.
from abc import ABCMeta, abstractmethod
import six
@six.add_metaclass(ABCMeta)
class NeutronPluginBaseV2(object):
__metaclass__ = ABCMeta
@abstractmethod
def create_subnet(self, context, subnet):
"""Create a subnet.

View File

@ -19,7 +19,10 @@
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.

View File

@ -19,7 +19,10 @@
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):

View 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.

View File

@ -15,12 +15,15 @@
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.

View 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.

View File

@ -18,7 +18,10 @@
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.

View 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

View 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):

View 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,

View File

@ -19,7 +19,10 @@
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.

View File

@ -18,7 +18,10 @@
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):

View File

@ -16,10 +16,12 @@
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class MeteringAbstractDriver(object):
"""Abstract Metering driver."""
__metaclass__ = abc.ABCMeta
def __init__(self, plugin, conf):
pass

View 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

View File

@ -16,9 +16,11 @@
# under the License.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class DeviceDriver(object):
__metaclass__ = abc.ABCMeta
def __init__(self, agent, host):
pass

View 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

View File

@ -17,9 +17,11 @@
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class VpnDriver(object):
__metaclass__ = abc.ABCMeta
@property
def service_type(self):