From 5e11769e498f210b1c84a6addaffecb7db9c5fed Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Wed, 1 Jul 2015 18:01:10 -0700 Subject: [PATCH] Use EXT_TO_SERVICE_MAPPING instead of ALLOWED_SERVICES We can derive the services from EXT_TO_SERVICE_MAPPING, therefore there is no need for duplicating the service labels into ALLOWED_SERVICES. Change-Id: If92e0ea3dea4480588141a2819ea4036c527c9bc --- neutron/plugins/common/constants.py | 7 +------ neutron/services/provider_configuration.py | 5 +++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/neutron/plugins/common/constants.py b/neutron/plugins/common/constants.py index 5c562dc3b7b..809a1399e85 100644 --- a/neutron/plugins/common/constants.py +++ b/neutron/plugins/common/constants.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -# Service type constants: +# Neutron well-known service type constants: CORE = "CORE" DUMMY = "DUMMY" LOADBALANCER = "LOADBALANCER" @@ -23,7 +23,6 @@ VPN = "VPN" METERING = "METERING" L3_ROUTER_NAT = "L3_ROUTER_NAT" - # Maps extension alias to service type EXT_TO_SERVICE_MAPPING = { 'dummy': DUMMY, @@ -35,10 +34,6 @@ EXT_TO_SERVICE_MAPPING = { 'router': L3_ROUTER_NAT } -# TODO(salvatore-orlando): Move these (or derive them) from conf file -ALLOWED_SERVICES = [CORE, DUMMY, LOADBALANCER, FIREWALL, VPN, METERING, - L3_ROUTER_NAT, LOADBALANCERV2] - COMMON_PREFIXES = { CORE: "", DUMMY: "/dummy_svc", diff --git a/neutron/services/provider_configuration.py b/neutron/services/provider_configuration.py index 9a247bfc311..cc406e74193 100644 --- a/neutron/services/provider_configuration.py +++ b/neutron/services/provider_configuration.py @@ -111,11 +111,12 @@ def parse_service_provider_opt(): prov_def) LOG.error(msg) raise n_exc.Invalid(msg) - if svc_type not in constants.ALLOWED_SERVICES: + ALLOWED_SERVICES = constants.EXT_TO_SERVICE_MAPPING.values() + if svc_type not in ALLOWED_SERVICES: msg = (_("Service type '%(svc_type)s' is not allowed, " "allowed types: %(allowed)s") % {'svc_type': svc_type, - 'allowed': constants.ALLOWED_SERVICES}) + 'allowed': ALLOWED_SERVICES}) LOG.error(msg) raise n_exc.Invalid(msg) driver = get_provider_driver_class(driver)