diff --git a/neutron/extensions/data_plane_status.py b/neutron/extensions/data_plane_status.py index 8e225e670b5..dfaaa141de8 100644 --- a/neutron/extensions/data_plane_status.py +++ b/neutron/extensions/data_plane_status.py @@ -16,32 +16,5 @@ from neutron_lib.api.definitions import data_plane_status from neutron_lib.api import extensions -class Data_plane_status(extensions.ExtensionDescriptor): - - @classmethod - def get_name(cls): - return data_plane_status.NAME - - @classmethod - def get_alias(cls): - return data_plane_status.ALIAS - - @classmethod - def get_description(cls): - return data_plane_status.DESCRIPTION - - @classmethod - def get_updated(cls): - return data_plane_status.UPDATED_TIMESTAMP - - def get_required_extensions(self): - return data_plane_status.REQUIRED_EXTENSIONS or [] - - def get_optional_extensions(self): - return data_plane_status.OPTIONAL_EXTENSIONS or [] - - def get_extended_resources(self, version): - if version == "2.0": - return data_plane_status.RESOURCE_ATTRIBUTE_MAP - else: - return {} +class Data_plane_status(extensions.APIExtensionDescriptor): + api_definition = data_plane_status diff --git a/neutron/extensions/providernet.py b/neutron/extensions/providernet.py index ae765890a28..5f7091f5189 100644 --- a/neutron/extensions/providernet.py +++ b/neutron/extensions/providernet.py @@ -33,7 +33,7 @@ def _raise_if_updates_provider_attributes(attrs): raise n_exc.InvalidInput(error_message=msg) -class Providernet(extensions.ExtensionDescriptor): +class Providernet(extensions.APIExtensionDescriptor): """Extension class supporting provider networks. This class is used by neutron's extension framework to make @@ -45,25 +45,4 @@ class Providernet(extensions.ExtensionDescriptor): With admin rights, network dictionaries returned will also include provider attributes. """ - - @classmethod - def get_name(cls): - return provider_net.NAME - - @classmethod - def get_alias(cls): - return provider_net.ALIAS - - @classmethod - def get_description(cls): - return provider_net.DESCRIPTION - - @classmethod - def get_updated(cls): - return provider_net.UPDATED_TIMESTAMP - - def get_extended_resources(self, version): - if version == "2.0": - return provider_net.RESOURCE_ATTRIBUTE_MAP - else: - return {} + api_definition = provider_net diff --git a/neutron/extensions/trunk.py b/neutron/extensions/trunk.py index 07737435b2e..15d0ebcbf71 100644 --- a/neutron/extensions/trunk.py +++ b/neutron/extensions/trunk.py @@ -19,24 +19,9 @@ from neutron_lib.api import extensions from neutron.api.v2 import resource_helper -class Trunk(extensions.ExtensionDescriptor): +class Trunk(extensions.APIExtensionDescriptor): """Trunk API extension.""" - - @classmethod - def get_name(cls): - return trunk.NAME - - @classmethod - def get_alias(cls): - return trunk.ALIAS - - @classmethod - def get_description(cls): - return trunk.DESCRIPTION - - @classmethod - def get_updated(cls): - return trunk.UPDATED_TIMESTAMP + api_definition = trunk @classmethod def get_resources(cls): @@ -49,19 +34,3 @@ class Trunk(extensions.ExtensionDescriptor): trunk.ALIAS, action_map=trunk.ACTION_MAP, register_quota=True) - - def update_attributes_map(self, attributes, extension_attrs_map=None): - super(Trunk, self).update_attributes_map( - attributes, extension_attrs_map=trunk.RESOURCE_ATTRIBUTE_MAP) - - def get_required_extensions(self): - return trunk.REQUIRED_EXTENSIONS or [] - - def get_optional_extensions(self): - return trunk.OPTIONAL_EXTENSIONS or [] - - def get_extended_resources(self, version): - if version == "2.0": - return trunk.RESOURCE_ATTRIBUTE_MAP - else: - return {} diff --git a/neutron/extensions/trunk_details.py b/neutron/extensions/trunk_details.py index 4bb5a68f763..ea5abbc7e2c 100644 --- a/neutron/extensions/trunk_details.py +++ b/neutron/extensions/trunk_details.py @@ -23,32 +23,5 @@ from neutron_lib.api import extensions # config-drive configuration. -class Trunk_details(extensions.ExtensionDescriptor): - - @classmethod - def get_name(cls): - return trunk_details.NAME - - @classmethod - def get_alias(cls): - return trunk_details.ALIAS - - @classmethod - def get_description(cls): - return trunk_details.DESCRIPTION - - @classmethod - def get_updated(cls): - return trunk_details.TIMESTAMP - - def get_required_extensions(self): - return trunk_details.REQUIRED_EXTENSIONS or [] - - def get_optional_extensions(self): - return trunk_details.OPTIONAL_EXTENSIONS or [] - - def get_extended_resources(self, version): - if version == "2.0": - return trunk_details.RESOURCE_ATTRIBUTE_MAP - else: - return {} +class Trunk_details(extensions.APIExtensionDescriptor): + api_definition = trunk_details diff --git a/neutron/tests/tools.py b/neutron/tests/tools.py index ba2dc6c956c..f9d0ca154ec 100644 --- a/neutron/tests/tools.py +++ b/neutron/tests/tools.py @@ -25,6 +25,7 @@ import fixtures import mock import netaddr from neutron_lib import constants +from neutron_lib import fixture from neutron_lib.utils import helpers from neutron_lib.utils import net from oslo_utils import netutils @@ -37,7 +38,7 @@ from neutron.plugins.common import constants as p_const from neutron.services.logapi.common import constants as log_const -class AttributeMapMemento(fixtures.Fixture): +class AttributeMapMemento(fixture.APIDefinitionFixture): """Create a copy of the resource attribute map so it can be restored during test cleanup. @@ -53,6 +54,8 @@ class AttributeMapMemento(fixtures.Fixture): """ def _setUp(self): + self.backup_global_resources = False + super(AttributeMapMemento, self)._setUp() # Shallow copy is not a proper choice for keeping a backup copy as # the RESOURCE_ATTRIBUTE_MAP map is modified in place through the # 0th level keys. Ideally deepcopy() would be used but this seems @@ -64,6 +67,7 @@ class AttributeMapMemento(fixtures.Fixture): self.addCleanup(self.restore) def restore(self): + super(AttributeMapMemento, self)._restore() attributes.RESOURCE_ATTRIBUTE_MAP = self.contents_backup