From 9fc422a93a00f4126e91fa79ffcd43903ea9c8ac Mon Sep 17 00:00:00 2001 From: "Sean M. Collins" Date: Mon, 15 Jun 2015 13:51:05 -0400 Subject: [PATCH] API Extensions: inherit from the ExtensionDescriptor For consistency in the codebase, API extensions should inherit from the abstract base class ExtensionDescriptor. Change-Id: Id4829c265866e80c042c433bebcc01383e1e7417 --- neutron/api/extensions.py | 7 ++----- neutron/extensions/agent.py | 2 +- neutron/extensions/allowedaddresspairs.py | 3 ++- neutron/extensions/dvr.py | 3 ++- neutron/extensions/extraroute.py | 4 ++-- neutron/extensions/portsecurity.py | 3 ++- neutron/extensions/routerservicetype.py | 3 ++- neutron/plugins/nec/extensions/router_provider.py | 3 ++- .../plugins/vmware/extensions/advancedserviceproviders.py | 3 ++- neutron/plugins/vmware/extensions/lsn.py | 2 +- neutron/plugins/vmware/extensions/maclearning.py | 3 ++- neutron/plugins/vmware/extensions/networkgw.py | 3 ++- neutron/plugins/vmware/extensions/qos.py | 2 +- neutron/plugins/vmware/extensions/routertype.py | 3 ++- neutron/plugins/vmware/extensions/vnicindex.py | 3 ++- 15 files changed, 27 insertions(+), 20 deletions(-) diff --git a/neutron/api/extensions.py b/neutron/api/extensions.py index f6b4601ba..5476157fc 100644 --- a/neutron/api/extensions.py +++ b/neutron/api/extensions.py @@ -63,12 +63,9 @@ class PluginInterface(object): return True +@six.add_metaclass(abc.ABCMeta) class ExtensionDescriptor(object): - """Base class that defines the contract for extensions. - - Note that you don't have to derive from this class to have a valid - extension; it is purely a convenience. - """ + """Base class that defines the contract for extensions.""" def get_name(self): """The name of the extension. diff --git a/neutron/extensions/agent.py b/neutron/extensions/agent.py index 4dee27c6e..c2fab0bcc 100644 --- a/neutron/extensions/agent.py +++ b/neutron/extensions/agent.py @@ -71,7 +71,7 @@ class MultipleAgentFoundByTypeHost(exceptions.Conflict): "host=%(host)s found") -class Agent(object): +class Agent(extensions.ExtensionDescriptor): """Agent management extension.""" @classmethod diff --git a/neutron/extensions/allowedaddresspairs.py b/neutron/extensions/allowedaddresspairs.py index 2e618eef2..765f6ff1b 100644 --- a/neutron/extensions/allowedaddresspairs.py +++ b/neutron/extensions/allowedaddresspairs.py @@ -14,6 +14,7 @@ import webob.exc +from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.common import exceptions as nexception from oslo_config import cfg @@ -102,7 +103,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Allowedaddresspairs(object): +class Allowedaddresspairs(extensions.ExtensionDescriptor): """Extension class supporting allowed address pairs.""" @classmethod diff --git a/neutron/extensions/dvr.py b/neutron/extensions/dvr.py index bb5720e9d..4d415245f 100644 --- a/neutron/extensions/dvr.py +++ b/neutron/extensions/dvr.py @@ -16,6 +16,7 @@ import abc import six +from neutron.api import extensions from neutron.api.v2 import attributes from neutron.common import constants from neutron.common import exceptions @@ -42,7 +43,7 @@ class MacAddressGenerationFailure(exceptions.ServiceUnavailable): message = _("Unable to generate unique DVR mac for host %(host)s.") -class Dvr(object): +class Dvr(extensions.ExtensionDescriptor): """Extension class supporting distributed virtual router.""" @classmethod diff --git a/neutron/extensions/extraroute.py b/neutron/extensions/extraroute.py index 2e6916c60..38f386149 100644 --- a/neutron/extensions/extraroute.py +++ b/neutron/extensions/extraroute.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. - +from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.common import exceptions as nexception @@ -44,7 +44,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Extraroute(object): +class Extraroute(extensions.ExtensionDescriptor): @classmethod def get_name(cls): diff --git a/neutron/extensions/portsecurity.py b/neutron/extensions/portsecurity.py index 68663f9e1..0a9b17e29 100644 --- a/neutron/extensions/portsecurity.py +++ b/neutron/extensions/portsecurity.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.api import extensions from neutron.api.v2 import attributes from neutron.common import exceptions as nexception @@ -48,7 +49,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Portsecurity(object): +class Portsecurity(extensions.ExtensionDescriptor): """Extension class supporting port security.""" @classmethod diff --git a/neutron/extensions/routerservicetype.py b/neutron/extensions/routerservicetype.py index cce9cf85d..8a131b23e 100644 --- a/neutron/extensions/routerservicetype.py +++ b/neutron/extensions/routerservicetype.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.api import extensions SERVICE_TYPE_ID = 'service_type_id' EXTENDED_ATTRIBUTES_2_0 = { @@ -23,7 +24,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Routerservicetype(object): +class Routerservicetype(extensions.ExtensionDescriptor): """Extension class supporting router service type.""" @classmethod diff --git a/neutron/plugins/nec/extensions/router_provider.py b/neutron/plugins/nec/extensions/router_provider.py index 5098a47fd..e37f6b873 100644 --- a/neutron/plugins/nec/extensions/router_provider.py +++ b/neutron/plugins/nec/extensions/router_provider.py @@ -14,6 +14,7 @@ from oslo_log import log as logging +from neutron.api import extensions from neutron.api.v2 import attributes @@ -31,7 +32,7 @@ ROUTER_PROVIDER_ATTRIBUTE = { } -class Router_provider(object): +class Router_provider(extensions.ExtensionDescriptor): @classmethod def get_name(cls): return "Router Provider" diff --git a/neutron/plugins/vmware/extensions/advancedserviceproviders.py b/neutron/plugins/vmware/extensions/advancedserviceproviders.py index ba6203639..4c1552274 100644 --- a/neutron/plugins/vmware/extensions/advancedserviceproviders.py +++ b/neutron/plugins/vmware/extensions/advancedserviceproviders.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.api import extensions # Attribute Map ADV_SERVICE_PROVIDERS = 'advanced_service_providers' @@ -26,7 +27,7 @@ EXTENDED_ATTRIBUTES_2_0 = { 'default': None}}} -class Advancedserviceproviders(object): +class Advancedserviceproviders(extensions.ExtensionDescriptor): @classmethod def get_name(cls): return "Advanced Service Providers" diff --git a/neutron/plugins/vmware/extensions/lsn.py b/neutron/plugins/vmware/extensions/lsn.py index 4a7d3ca3d..8887c2951 100644 --- a/neutron/plugins/vmware/extensions/lsn.py +++ b/neutron/plugins/vmware/extensions/lsn.py @@ -37,7 +37,7 @@ RESOURCE_ATTRIBUTE_MAP = { } -class Lsn(object): +class Lsn(extensions.ExtensionDescriptor): """Enable LSN configuration for Neutron NSX networks.""" @classmethod diff --git a/neutron/plugins/vmware/extensions/maclearning.py b/neutron/plugins/vmware/extensions/maclearning.py index 21c669150..b18f02e08 100644 --- a/neutron/plugins/vmware/extensions/maclearning.py +++ b/neutron/plugins/vmware/extensions/maclearning.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.api import extensions from neutron.api.v2 import attributes @@ -26,7 +27,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Maclearning(object): +class Maclearning(extensions.ExtensionDescriptor): """Extension class supporting port mac learning.""" @classmethod diff --git a/neutron/plugins/vmware/extensions/networkgw.py b/neutron/plugins/vmware/extensions/networkgw.py index 1e9bc2ace..b46ff01eb 100644 --- a/neutron/plugins/vmware/extensions/networkgw.py +++ b/neutron/plugins/vmware/extensions/networkgw.py @@ -17,6 +17,7 @@ import abc from oslo_config import cfg +from neutron.api import extensions from neutron.api.v2 import attributes from neutron.api.v2 import resource_helper @@ -149,7 +150,7 @@ attributes.validators['type:device_list'] = _validate_device_list attributes.validators['type:connector_type'] = _validate_connector_type -class Networkgw(object): +class Networkgw(extensions.ExtensionDescriptor): """API extension for Layer-2 Gateway support. The Layer-2 gateway feature allows for connecting neutron networks diff --git a/neutron/plugins/vmware/extensions/qos.py b/neutron/plugins/vmware/extensions/qos.py index 30e6f8c7d..e1e5710b7 100644 --- a/neutron/plugins/vmware/extensions/qos.py +++ b/neutron/plugins/vmware/extensions/qos.py @@ -161,7 +161,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Qos(object): +class Qos(extensions.ExtensionDescriptor): """Port Queue extension.""" @classmethod diff --git a/neutron/plugins/vmware/extensions/routertype.py b/neutron/plugins/vmware/extensions/routertype.py index ba7c831a2..02f09bc20 100644 --- a/neutron/plugins/vmware/extensions/routertype.py +++ b/neutron/plugins/vmware/extensions/routertype.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.api import extensions from neutron.api.v2 import attributes @@ -26,7 +27,7 @@ EXTENDED_ATTRIBUTES_2_0 = { } -class Routertype(object): +class Routertype(extensions.ExtensionDescriptor): """Extension class supporting router type.""" @classmethod diff --git a/neutron/plugins/vmware/extensions/vnicindex.py b/neutron/plugins/vmware/extensions/vnicindex.py index 9b0e6d05c..76dda33a7 100644 --- a/neutron/plugins/vmware/extensions/vnicindex.py +++ b/neutron/plugins/vmware/extensions/vnicindex.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron.api import extensions from neutron.api.v2 import attributes # Attribute Map @@ -28,7 +29,7 @@ EXTENDED_ATTRIBUTES_2_0 = { 'convert_to': attributes.convert_to_int_if_not_none}}} -class Vnicindex(object): +class Vnicindex(extensions.ExtensionDescriptor): @classmethod def get_name(cls): return "VNIC Index" -- 2.45.2