diff --git a/neutron/extensions/l2_adjacency.py b/neutron/extensions/l2_adjacency.py index 795a3d94272..4224e190d5a 100644 --- a/neutron/extensions/l2_adjacency.py +++ b/neutron/extensions/l2_adjacency.py @@ -13,20 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib.api.definitions import l2_adjacency as apidef from neutron_lib.api import extensions -L2_ADJACENCY = 'l2_adjacency' -EXTENDED_ATTRIBUTES_2_0 = { - 'networks': { - L2_ADJACENCY: {'allow_post': False, - 'allow_put': False, - 'is_visible': True} - } -} - - -class L2_adjacency(extensions.ExtensionDescriptor): +class L2_adjacency(extensions.APIExtensionDescriptor): """Extension class supporting L2 Adjacency for Routed Networks The following class is used by neutron's extension framework @@ -34,25 +25,4 @@ class L2_adjacency(extensions.ExtensionDescriptor): Routed Network, exposing the same to clients. No new resources have been defined by this extension. """ - - @classmethod - def get_name(cls): - return "L2 Adjacency" - - @classmethod - def get_alias(cls): - return "l2_adjacency" - - @classmethod - def get_description(cls): - return "Display L2 Adjacency for Neutron Networks." - - @classmethod - def get_updated(cls): - return "2016-04-12T16:00:00-00:00" - - def get_extended_resources(self, version): - if version == "2.0": - return EXTENDED_ATTRIBUTES_2_0 - else: - return {} + api_definition = apidef diff --git a/neutron/services/segments/plugin.py b/neutron/services/segments/plugin.py index 99871f93743..c14af4f1342 100644 --- a/neutron/services/segments/plugin.py +++ b/neutron/services/segments/plugin.py @@ -16,6 +16,7 @@ from keystoneauth1 import loading as ks_loading import netaddr +from neutron_lib.api.definitions import l2_adjacency as l2adj_apidef from neutron_lib.api.definitions import network as net_def from neutron_lib.api.definitions import port as port_def from neutron_lib.api.definitions import subnet as subnet_def @@ -36,7 +37,6 @@ from neutron.db import api as db_api from neutron.db.models import segment as segment_model from neutron.db import models_v2 from neutron.extensions import ip_allocation -from neutron.extensions import l2_adjacency from neutron.extensions import segment from neutron.notifiers import batch_notifier from neutron.services.segments import db @@ -57,7 +57,8 @@ class Plugin(db.SegmentDbMixin, segment.SegmentPluginBase): _instance = None - supported_extension_aliases = ["segment", "ip_allocation", "l2_adjacency"] + supported_extension_aliases = ["segment", "ip_allocation", + l2adj_apidef.ALIAS] def __init__(self): self.nova_updater = NovaSegmentNotifier() @@ -72,7 +73,7 @@ class Plugin(db.SegmentDbMixin, segment.SegmentPluginBase): # it's a thing. is_adjacent = (not network_db.subnets or not network_db.subnets[0].segment_id) - network_res[l2_adjacency.L2_ADJACENCY] = is_adjacent + network_res[l2adj_apidef.L2_ADJACENCY] = is_adjacent @staticmethod @resource_extend.extends([subnet_def.COLLECTION_NAME]) diff --git a/neutron/tests/unit/extensions/test_segment.py b/neutron/tests/unit/extensions/test_segment.py index bcb307f81cf..970496a893c 100644 --- a/neutron/tests/unit/extensions/test_segment.py +++ b/neutron/tests/unit/extensions/test_segment.py @@ -17,6 +17,7 @@ import copy from keystoneauth1 import exceptions as ks_exc import mock import netaddr +from neutron_lib.api.definitions import l2_adjacency as l2adj_apidef from neutron_lib.api.definitions import portbindings from neutron_lib.callbacks import events from neutron_lib.callbacks import exceptions @@ -39,7 +40,6 @@ from neutron.db import db_base_plugin_v2 from neutron.db import portbindings_db from neutron.db import segments_db from neutron.extensions import ip_allocation -from neutron.extensions import l2_adjacency from neutron.extensions import segment as ext_segment from neutron.objects import network from neutron.services.segments import db @@ -843,7 +843,7 @@ class SegmentAwareIpamTestCase(SegmentTestCase): request = self.new_show_request('networks', network_id) response = self.deserialize(self.fmt, request.get_response(self.api)) self.assertEqual(is_adjacent, - response['network'][l2_adjacency.L2_ADJACENCY]) + response['network'][l2adj_apidef.L2_ADJACENCY]) class TestSegmentAwareIpam(SegmentAwareIpamTestCase):