Classes lack metaclass decoration
Add decorations where required. There are roughly a dozen classes in Neutron that define abstract methods or properties but are not decorated with @six.add_metaclass(abc.ABCMeta). Without this decoration, children can be created without defining the required methods or properties. Decorating RBACColumns in db/rbac_db_models.py causes failures and will be reported separately. Decorating unit tests is of dubious benifit and should be addressed separately (if at all). There are also several more places where metaclassing isn't correct, to be taken care of in follow-on patches. For example, BaseScheduler is using the fact the None doesn't have a filter_agents() method, which gives developers confusing error messages when they incorrectly implement the interface, and they won't see any error until schedule() is called. As an aside, the docstring for this base class is also incorrect. Change-Id: I2b2cce37d9b0d40559a715a7d510a969b8ba9963 Closes-Bug: #1577648
This commit is contained in:
parent
261edb48b7
commit
972cdef50c
@ -172,6 +172,7 @@ class DhcpBase(object):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class DhcpLocalProcess(DhcpBase):
|
||||
PORTS = []
|
||||
|
||||
|
@ -17,6 +17,7 @@ import abc
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import exceptions
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
@ -122,6 +123,7 @@ class Agent(extensions.ExtensionDescriptor):
|
||||
return {}
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class AgentPluginBase(object):
|
||||
"""REST API to operate the Agent.
|
||||
|
||||
|
@ -17,6 +17,7 @@ import abc
|
||||
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
@ -135,6 +136,7 @@ class NetworkNotHostedByDhcpAgent(exceptions.Conflict):
|
||||
" by the DHCP agent %(agent_id)s.")
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class DhcpAgentSchedulerPluginBase(object):
|
||||
"""REST API to operate the DHCP agent scheduler.
|
||||
|
||||
|
@ -18,6 +18,7 @@ import abc
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib import exceptions as nexception
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
@ -220,6 +221,7 @@ class L3(extensions.ExtensionDescriptor):
|
||||
return {}
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class RouterPluginBase(object):
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -18,6 +18,7 @@ import abc
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
import webob.exc
|
||||
|
||||
from neutron._i18n import _, _LE
|
||||
@ -183,6 +184,7 @@ class DVRL3CannotRemoveFromDvrAgent(exceptions.Conflict):
|
||||
"an agent in 'dvr' mode.")
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class L3AgentSchedulerPluginBase(object):
|
||||
"""REST API to operate the l3 agent scheduler.
|
||||
|
||||
|
@ -104,6 +104,7 @@ class L2populationRpcCallBackMixin(object):
|
||||
pass
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
|
||||
'''Mixin class of L2-population call back for Tunnel.
|
||||
|
||||
|
@ -21,6 +21,7 @@ from oslo_config import cfg
|
||||
from oslo_db import api as oslo_db_api
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log
|
||||
import six
|
||||
from six import moves
|
||||
from sqlalchemy import or_
|
||||
|
||||
@ -45,6 +46,7 @@ def chunks(iterable, chunk_size):
|
||||
chunk = list(itertools.islice(iterator, 0, chunk_size))
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class TunnelTypeDriver(helpers.SegmentTypeDriver):
|
||||
"""Define stable abstract interface for ML2 type drivers.
|
||||
|
||||
|
@ -15,7 +15,10 @@
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseResourceFilter(object):
|
||||
"""Encapsulate logic that is specific to the resource type."""
|
||||
@abc.abstractmethod
|
||||
|
@ -17,7 +17,10 @@ import abc
|
||||
from operator import attrgetter
|
||||
import random
|
||||
|
||||
import six
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class BaseScheduler(object):
|
||||
"""The base scheduler (agnostic to resource type).
|
||||
Child classes of BaseScheduler must define the
|
||||
|
@ -16,6 +16,7 @@
|
||||
import abc
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from neutron.api import extensions
|
||||
from neutron import wsgi
|
||||
@ -27,6 +28,7 @@ class FoxInSocksController(wsgi.Controller):
|
||||
return "Try to say this Mr. Knox, sir..."
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class FoxInSocksPluginInterface(extensions.PluginInterface):
|
||||
|
||||
@abc.abstractmethod
|
||||
|
Loading…
Reference in New Issue
Block a user