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
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from neutron_lib.api.definitions import servicetype as apidef
|
||||||
from neutron_lib.api import extensions as api_extensions
|
from neutron_lib.api import extensions as api_extensions
|
||||||
|
|
||||||
from neutron._i18n import _
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron.api.v2 import base
|
from neutron.api.v2 import base
|
||||||
from neutron.db import servicetype_db
|
from neutron.db import servicetype_db
|
||||||
|
|
||||||
|
|
||||||
RESOURCE_NAME = "service_provider"
|
class Servicetype(api_extensions.APIExtensionDescriptor):
|
||||||
COLLECTION_NAME = "%ss" % RESOURCE_NAME
|
|
||||||
SERVICE_ATTR = 'service_type'
|
|
||||||
PLUGIN_ATTR = 'plugin'
|
|
||||||
DRIVER_ATTR = 'driver'
|
|
||||||
EXT_ALIAS = 'service-type'
|
|
||||||
|
|
||||||
# Attribute Map for Service Provider Resource
|
api_definition = apidef
|
||||||
# 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"
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
"""Returns Extended Resource for service type management."""
|
"""Returns Extended Resource for service type management."""
|
||||||
attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
|
attr_map = apidef.RESOURCE_ATTRIBUTE_MAP[apidef.COLLECTION_NAME]
|
||||||
collection_name = COLLECTION_NAME.replace('_', '-')
|
collection_name = apidef.COLLECTION_NAME.replace('_', '-')
|
||||||
controller = base.create_resource(
|
controller = base.create_resource(
|
||||||
collection_name,
|
collection_name,
|
||||||
RESOURCE_NAME,
|
apidef.RESOURCE_NAME,
|
||||||
servicetype_db.ServiceTypeManager.get_instance(),
|
servicetype_db.ServiceTypeManager.get_instance(),
|
||||||
attr_map)
|
attr_map)
|
||||||
return [extensions.ResourceExtension(collection_name,
|
return [extensions.ResourceExtension(collection_name,
|
||||||
controller,
|
controller,
|
||||||
attr_map=attr_map)]
|
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
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from neutron_lib.api.definitions import servicetype as svctype_apidef
|
||||||
from neutron_lib import exceptions
|
from neutron_lib import exceptions
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
from neutron_lib.services import base as service_base
|
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 import extensions
|
||||||
from neutron.api.v2 import base
|
from neutron.api.v2 import base
|
||||||
from neutron.db import servicetype_db
|
from neutron.db import servicetype_db
|
||||||
from neutron.extensions import servicetype
|
|
||||||
from neutron import neutron_plugin_base_v2
|
from neutron import neutron_plugin_base_v2
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class DummyServicePlugin(service_base.ServicePluginBase):
|
|||||||
or VPN will adopt a similar solution.
|
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"
|
path_prefix = "/dummy_svc"
|
||||||
agent_notifiers = {RESOURCE_NAME: 'dummy_agent_notifier'}
|
agent_notifiers = {RESOURCE_NAME: 'dummy_agent_notifier'}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from neutron_lib.api.definitions import servicetype as svctype_apidef
|
||||||
from neutron_lib import context
|
from neutron_lib import context
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.plugins import constants
|
from neutron_lib.plugins import constants
|
||||||
@ -197,7 +198,7 @@ class ServiceTypeExtensionTestCaseBase(testlib_api.WebTestCase):
|
|||||||
ext_mgr = TestServiceTypeExtensionManager()
|
ext_mgr = TestServiceTypeExtensionManager()
|
||||||
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||||
self.api = webtest.TestApp(self.ext_mdw)
|
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()
|
super(ServiceTypeExtensionTestCaseBase, self).setUp()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user