use dvr api def from neutron-lib
The dvr extension's API definition was rehomed into neutron-lib with commit I6d98e83287833882515240d7db1faa4a1deb7da1 This patch consumes it by removing the rehomed code and using the APIExtensionDescriptor for the extensions parent class. NeutronLibImpact Change-Id: Id5f0be33b036370b7545258a321830fdaa4dc0da
This commit is contained in:
@@ -110,7 +110,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
||||
except exceptions.NeutronDbObjectDuplicateEntry:
|
||||
LOG.error("MAC generation error after %s attempts",
|
||||
db_api.MAX_RETRIES)
|
||||
raise ext_dvr.MacAddressGenerationFailure(host=host)
|
||||
raise n_exc.HostMacAddressGenerationFailure(host=host)
|
||||
|
||||
@db_api.context_manager.reader
|
||||
def get_dvr_mac_address_list(self, context):
|
||||
|
||||
@@ -14,68 +14,24 @@
|
||||
|
||||
import abc
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.api.definitions import dvr as apidef
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
import six
|
||||
|
||||
from neutron._i18n import _
|
||||
|
||||
DISTRIBUTED = 'distributed'
|
||||
EXTENDED_ATTRIBUTES_2_0 = {
|
||||
'routers': {
|
||||
DISTRIBUTED: {'allow_post': True,
|
||||
'allow_put': True,
|
||||
'is_visible': True,
|
||||
'default': constants.ATTR_NOT_SPECIFIED,
|
||||
'convert_to': converters.convert_to_boolean_if_not_none,
|
||||
'enforce_policy': True},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# TODO(boden): consume with I88e1aa2acf22389f69cb7d5704c80a5eb72a9bbe
|
||||
class DVRMacAddressNotFound(exceptions.NotFound):
|
||||
message = _("Distributed Virtual Router Mac Address for "
|
||||
"host %(host)s does not exist.")
|
||||
|
||||
|
||||
class MacAddressGenerationFailure(exceptions.ServiceUnavailable):
|
||||
message = _("Unable to generate unique DVR mac for host %(host)s.")
|
||||
|
||||
|
||||
class Dvr(extensions.ExtensionDescriptor):
|
||||
class Dvr(extensions.APIExtensionDescriptor):
|
||||
"""Extension class supporting distributed virtual router."""
|
||||
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
return "Distributed Virtual Router"
|
||||
|
||||
@classmethod
|
||||
def get_alias(cls):
|
||||
return constants.L3_DISTRIBUTED_EXT_ALIAS
|
||||
|
||||
@classmethod
|
||||
def get_description(cls):
|
||||
return "Enables configuration of Distributed Virtual Routers."
|
||||
|
||||
@classmethod
|
||||
def get_updated(cls):
|
||||
return "2014-06-1T10:00:00-00:00"
|
||||
|
||||
def get_required_extensions(self):
|
||||
return ["router"]
|
||||
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Ext Resources."""
|
||||
return []
|
||||
|
||||
def get_extended_resources(self, version):
|
||||
if version == "2.0":
|
||||
return EXTENDED_ATTRIBUTES_2_0
|
||||
else:
|
||||
return {}
|
||||
api_definition = apidef
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
|
||||
@@ -20,6 +20,7 @@ from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.utils import net
|
||||
|
||||
@@ -77,7 +78,7 @@ class DvrDbMixinTestCase(test_plugin.Ml2PluginV2TestCase):
|
||||
self._create_dvr_mac_entry('foo_host_1', non_unique_mac)
|
||||
with mock.patch.object(net, 'get_random_mac') as f:
|
||||
f.return_value = non_unique_mac
|
||||
self.assertRaises(dvr.MacAddressGenerationFailure,
|
||||
self.assertRaises(lib_exc.HostMacAddressGenerationFailure,
|
||||
self.mixin._create_dvr_mac_address,
|
||||
self.ctx, "foo_host_2")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user