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
This commit is contained in:
armando-migliaccio 2015-07-01 18:01:10 -07:00
parent 4fa3c0619d
commit 5e11769e49
2 changed files with 4 additions and 8 deletions

View File

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

View File

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