Merge "use APIExtensionDescriptor for plugins with defs in lib"

This commit is contained in:
Jenkins 2017-07-21 04:32:16 +00:00 committed by Gerrit Code Review
commit 4bb8ee3328
5 changed files with 13 additions and 115 deletions

View File

@ -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

View File

@ -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

View File

@ -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 {}

View File

@ -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

View File

@ -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