Merge "use neutron-lib servicetype api def"
This commit is contained in:
commit
09e053cd91
@ -13,70 +13,28 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api.definitions import servicetype as apidef
|
||||
from neutron_lib.api import extensions as api_extensions
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import base
|
||||
from neutron.db import servicetype_db
|
||||
|
||||
|
||||
RESOURCE_NAME = "service_provider"
|
||||
COLLECTION_NAME = "%ss" % RESOURCE_NAME
|
||||
SERVICE_ATTR = 'service_type'
|
||||
PLUGIN_ATTR = 'plugin'
|
||||
DRIVER_ATTR = 'driver'
|
||||
EXT_ALIAS = 'service-type'
|
||||
class Servicetype(api_extensions.APIExtensionDescriptor):
|
||||
|
||||
# Attribute Map for Service Provider Resource
|
||||
# Allow read-only access
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
COLLECTION_NAME: {
|
||||
'service_type': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
'name': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
'default': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Servicetype(api_extensions.ExtensionDescriptor):
|
||||
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
return _("Neutron Service Type Management")
|
||||
|
||||
@classmethod
|
||||
def get_alias(cls):
|
||||
return EXT_ALIAS
|
||||
|
||||
@classmethod
|
||||
def get_description(cls):
|
||||
return _("API for retrieving service providers for "
|
||||
"Neutron advanced services")
|
||||
|
||||
@classmethod
|
||||
def get_updated(cls):
|
||||
return "2013-01-20T00:00:00-00:00"
|
||||
api_definition = apidef
|
||||
|
||||
@classmethod
|
||||
def get_resources(cls):
|
||||
"""Returns Extended Resource for service type management."""
|
||||
attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
|
||||
collection_name = COLLECTION_NAME.replace('_', '-')
|
||||
attr_map = apidef.RESOURCE_ATTRIBUTE_MAP[apidef.COLLECTION_NAME]
|
||||
collection_name = apidef.COLLECTION_NAME.replace('_', '-')
|
||||
controller = base.create_resource(
|
||||
collection_name,
|
||||
RESOURCE_NAME,
|
||||
apidef.RESOURCE_NAME,
|
||||
servicetype_db.ServiceTypeManager.get_instance(),
|
||||
attr_map)
|
||||
return [extensions.ResourceExtension(collection_name,
|
||||
controller,
|
||||
attr_map=attr_map)]
|
||||
|
||||
def get_extended_resources(self, version):
|
||||
if version == "2.0":
|
||||
return RESOURCE_ATTRIBUTE_MAP
|
||||
else:
|
||||
return {}
|
||||
|
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api.definitions import servicetype as svctype_apidef
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.services import base as service_base
|
||||
@ -21,7 +22,6 @@ from oslo_utils import uuidutils
|
||||
from neutron.api import extensions
|
||||
from neutron.api.v2 import base
|
||||
from neutron.db import servicetype_db
|
||||
from neutron.extensions import servicetype
|
||||
from neutron import neutron_plugin_base_v2
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ class DummyServicePlugin(service_base.ServicePluginBase):
|
||||
or VPN will adopt a similar solution.
|
||||
"""
|
||||
|
||||
supported_extension_aliases = [RESOURCE_NAME, servicetype.EXT_ALIAS]
|
||||
supported_extension_aliases = [RESOURCE_NAME, svctype_apidef.ALIAS]
|
||||
path_prefix = "/dummy_svc"
|
||||
agent_notifiers = {RESOURCE_NAME: 'dummy_agent_notifier'}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.api.definitions import servicetype as svctype_apidef
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import constants
|
||||
@ -197,7 +198,7 @@ class ServiceTypeExtensionTestCaseBase(testlib_api.WebTestCase):
|
||||
ext_mgr = TestServiceTypeExtensionManager()
|
||||
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||
self.api = webtest.TestApp(self.ext_mdw)
|
||||
self.resource_name = servicetype.RESOURCE_NAME.replace('-', '_')
|
||||
self.resource_name = svctype_apidef.RESOURCE_NAME.replace('-', '_')
|
||||
super(ServiceTypeExtensionTestCaseBase, self).setUp()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user