From 6d3b64c60b977e29fefa8a152d63879785d8af06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89douard=20Thuleau?= Date: Wed, 8 Jul 2015 13:35:31 +0000 Subject: [PATCH] Neutron constant COMMON_PREFIXES does not exist anymore The Neutron fix [1] removed the service provider constant COMMON_PREFIXES and that must be defined as a property. That patch also intorduce a constants file to group all BGPVPN constants. [1] https://review.openstack.org/#/c/198113/ Change-Id: Iae5d66bb8ffe6c7eb7825bf35b6f5fbc1d7dfd4a Closes-bug: #1472619 --- .../neutron/extensions/bgpvpn.py | 18 +++++++--------- .../neutron/services/common/__init__.py | 0 .../neutron/services/common/constants.py | 21 +++++++++++++++++++ networking_bgpvpn/neutron/services/plugin.py | 4 +++- .../tests/unit/extensions/test_bgpvpn.py | 2 +- 5 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 networking_bgpvpn/neutron/services/common/__init__.py create mode 100644 networking_bgpvpn/neutron/services/common/constants.py diff --git a/networking_bgpvpn/neutron/extensions/bgpvpn.py b/networking_bgpvpn/neutron/extensions/bgpvpn.py index a593d157..82aa5bf3 100644 --- a/networking_bgpvpn/neutron/extensions/bgpvpn.py +++ b/networking_bgpvpn/neutron/extensions/bgpvpn.py @@ -21,15 +21,13 @@ from networking_bgpvpn.neutron import extensions as bgpvpn_ext from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper -from neutron.plugins.common import constants +from neutron.plugins.common import constants as n_const from neutron.services.service_base import ServicePluginBase from oslo_log import log -LOG = log.getLogger(__name__) +from networking_bgpvpn.neutron.services.common import constants -BGPVPN_L3 = 'l3' -BGPVPN_L2 = 'l2' -BGPVPN_TYPES = [BGPVPN_L3, BGPVPN_L2] +LOG = log.getLogger(__name__) # Regular expression to validate Route Target list format @@ -39,9 +37,7 @@ RT_REGEX = ('^((?:0|[1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]' '{2}|655[0-2]\d|6553[0-5]))$') extensions.append_api_extensions_path(bgpvpn_ext.__path__) -constants.BGPVPN = "BGPVPN" -constants.EXT_TO_SERVICE_MAPPING['bgpvpn'] = constants.BGPVPN -constants.COMMON_PREFIXES["BGPVPN"] = "/bgpvpn" +n_const.EXT_TO_SERVICE_MAPPING['bgpvpn'] = constants.BGPVPN def _validate_rt_list(data, valid_values=None): @@ -71,7 +67,7 @@ validators = {'type:route_target_list': _validate_rt_list, attr.validators.update(validators) RESOURCE_ATTRIBUTE_MAP = { - 'bgpvpn_connections': { + constants.BGPVPN_CONNECTIONS: { 'id': {'allow_post': False, 'allow_put': False, 'validate': {'type:uuid': None}, 'is_visible': True, @@ -89,8 +85,8 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': {'type:string': None}, 'is_visible': True}, 'type': {'allow_post': True, 'allow_put': False, - 'default': BGPVPN_L3, - 'validate': {'type:values': BGPVPN_TYPES}, + 'default': constants.BGPVPN_L3, + 'validate': {'type:values': constants.BGPVPN_TYPES}, 'is_visible': True}, 'route_targets': {'allow_post': True, 'allow_put': True, 'default': [], diff --git a/networking_bgpvpn/neutron/services/common/__init__.py b/networking_bgpvpn/neutron/services/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/networking_bgpvpn/neutron/services/common/constants.py b/networking_bgpvpn/neutron/services/common/constants.py new file mode 100644 index 00000000..2b137ea7 --- /dev/null +++ b/networking_bgpvpn/neutron/services/common/constants.py @@ -0,0 +1,21 @@ +# Copyright 2015 OpenStack Foundation +# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +BGPVPN = "BGPVPN" + +BGPVPN_CONNECTIONS = "bgpvpn_connections" +BGPVPN_L3 = 'l3' +BGPVPN_L2 = 'l2' +BGPVPN_TYPES = [BGPVPN_L3, BGPVPN_L2] diff --git a/networking_bgpvpn/neutron/services/plugin.py b/networking_bgpvpn/neutron/services/plugin.py index 2d27ff38..d8c9a415 100644 --- a/networking_bgpvpn/neutron/services/plugin.py +++ b/networking_bgpvpn/neutron/services/plugin.py @@ -15,15 +15,17 @@ from networking_bgpvpn.neutron.db import bgpvpn_db from neutron.i18n import _LI -from neutron.plugins.common import constants from neutron.services import service_base from oslo_log import log +from networking_bgpvpn.neutron.services.common import constants + LOG = log.getLogger(__name__) class BGPVPNPlugin(bgpvpn_db.BGPVPNPluginDb): supported_extension_aliases = ["bgpvpn"] + path_prefix = "/bgpvpn" def __init__(self): super(BGPVPNPlugin, self).__init__() diff --git a/networking_bgpvpn/tests/unit/extensions/test_bgpvpn.py b/networking_bgpvpn/tests/unit/extensions/test_bgpvpn.py index 079be223..e21e160b 100644 --- a/networking_bgpvpn/tests/unit/extensions/test_bgpvpn.py +++ b/networking_bgpvpn/tests/unit/extensions/test_bgpvpn.py @@ -18,12 +18,12 @@ import mock from oslo_utils import uuidutils -from neutron.plugins.common import constants from neutron.tests.unit.api.v2 import test_base from neutron.tests.unit.extensions import base as test_extensions_base from webob import exc from networking_bgpvpn.neutron.extensions import bgpvpn +from networking_bgpvpn.neutron.services.common import constants _uuid = uuidutils.generate_uuid _get_path = test_base._get_path

AltStyle によって変換されたページ (->オリジナル) /