1 # Copyright 2013 OpenStack Foundation.
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
16 from neutron._i18n import _
17 from neutron.api import extensions
18 from neutron.api.v2 import attributes
19 from neutron.api.v2 import base
20 from neutron.db import servicetype_db
23 RESOURCE_NAME = "service_provider"
24 COLLECTION_NAME = "%ss" % RESOURCE_NAME
25 SERVICE_ATTR = 'service_type'
26 PLUGIN_ATTR = 'plugin'
27 DRIVER_ATTR = 'driver'
28 EXT_ALIAS = 'service-type'
30 # Attribute Map for Service Provider Resource
31 # Allow read-only access
32 RESOURCE_ATTRIBUTE_MAP = {
34 'service_type': {'allow_post': False, 'allow_put': False,
36 'name': {'allow_post': False, 'allow_put': False,
38 'default': {'allow_post': False, 'allow_put': False,
44 class Servicetype(extensions.ExtensionDescriptor):
48 return _("Neutron Service Type Management")
55 def get_description(cls):
56 return _("API for retrieving service providers for "
57 "Neutron advanced services")
61 return "2013-01-20T00:00:00-00:00"
64 def get_resources(cls):
65 """Returns Extended Resource for service type management."""
66 my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
67 attributes.PLURALS.update(dict(my_plurals))
68 attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
69 collection_name = COLLECTION_NAME.replace('_', '-')
70 controller = base.create_resource(
73 servicetype_db.ServiceTypeManager.get_instance(),
75 return [extensions.ResourceExtension(collection_name,
79 def get_extended_resources(self, version):
81 return RESOURCE_ATTRIBUTE_MAP