# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+
+import paste.urlmap
+
+from cinder import flags
+
+
+FLAGS = flags.FLAGS
+
+
+def root_app_factory(loader, global_conf, **local_conf):
+ if not FLAGS.enable_v1_api:
+ del local_conf['/v1']
+ if not FLAGS.enable_v2_api:
+ del local_conf['/v2']
+ return paste.urlmap.urlmap_factory(loader, global_conf, **local_conf)
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-
-"""
-WSGI middleware for OpenStack Volume API.
-"""
-
-from cinder.api import extensions
-import cinder.api.openstack
-from cinder.api.openstack.volume import limits
-from cinder.api.openstack.volume import snapshots
-from cinder.api.openstack.volume import types
-from cinder.api.openstack.volume import volumes
-from cinder.api import versions
-from cinder.openstack.common import log as logging
-
-
-LOG = logging.getLogger(__name__)
-
-
-class APIRouter(cinder.api.openstack.APIRouter):
- """
- Routes requests on the OpenStack API to the appropriate controller
- and method.
- """
- ExtensionManager = extensions.ExtensionManager
-
- def _setup_routes(self, mapper, ext_mgr):
- self.resources['versions'] = versions.create_resource()
- mapper.connect("versions", "/",
- controller=self.resources['versions'],
- action='show')
-
- mapper.redirect("", "/")
-
- self.resources['volumes'] = volumes.create_resource(ext_mgr)
- mapper.resource("volume", "volumes",
- controller=self.resources['volumes'],
- collection={'detail': 'GET'},
- member={'action': 'POST'})
-
- self.resources['types'] = types.create_resource()
- mapper.resource("type", "types",
- controller=self.resources['types'])
-
- self.resources['snapshots'] = snapshots.create_resource(ext_mgr)
- mapper.resource("snapshot", "snapshots",
- controller=self.resources['snapshots'],
- collection={'detail': 'GET'},
- member={'action': 'POST'})
-
- self.resources['limits'] = limits.create_resource()
- mapper.resource("limit", "limits",
- controller=self.resources['limits'])
import webob
from cinder.api import extensions
-from cinder.api.openstack.volume import types
from cinder.api.openstack import wsgi
+from cinder.api.v1 import types
from cinder.api.views import types as views_types
from cinder import exception
from cinder.volume import volume_types
--- /dev/null
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2011 OpenStack LLC.
+# Copyright 2011 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+WSGI middleware for OpenStack Volume API.
+"""
+
+from cinder.api import extensions
+import cinder.api.openstack
+from cinder.api.v1 import limits
+from cinder.api.v1 import snapshots
+from cinder.api.v1 import types
+from cinder.api.v1 import volumes
+from cinder.api import versions
+from cinder.openstack.common import log as logging
+
+
+LOG = logging.getLogger(__name__)
+
+
+class APIRouter(cinder.api.openstack.APIRouter):
+ """
+ Routes requests on the OpenStack API to the appropriate controller
+ and method.
+ """
+ ExtensionManager = extensions.ExtensionManager
+
+ def _setup_routes(self, mapper, ext_mgr):
+ self.resources['versions'] = versions.create_resource()
+ mapper.connect("versions", "/",
+ controller=self.resources['versions'],
+ action='show')
+
+ mapper.redirect("", "/")
+
+ self.resources['volumes'] = volumes.create_resource(ext_mgr)
+ mapper.resource("volume", "volumes",
+ controller=self.resources['volumes'],
+ collection={'detail': 'GET'},
+ member={'action': 'POST'})
+
+ self.resources['types'] = types.create_resource()
+ mapper.resource("type", "types",
+ controller=self.resources['types'])
+
+ self.resources['snapshots'] = snapshots.create_resource(ext_mgr)
+ mapper.resource("snapshot", "snapshots",
+ controller=self.resources['snapshots'],
+ collection={'detail': 'GET'},
+ member={'action': 'POST'})
+
+ self.resources['limits'] = limits.create_resource()
+ mapper.resource("limit", "limits",
+ controller=self.resources['limits'])
from webob import exc
from cinder.api import common
-from cinder.api.openstack.volume import volumes
from cinder.api.openstack import wsgi
+from cinder.api.v1 import volumes
from cinder.api import xmlutil
from cinder import exception
from cinder import flags
cfg.StrOpt('volume_topic',
default='cinder-volume',
help='the topic volume nodes listen on'),
+ cfg.BoolOpt('enable_v1_api', default=True,
+ help=_("Deploy v1 of the Cinder API")),
+ cfg.BoolOpt('enable_v2_api', default=True,
+ help=_("Deploy v2 of the Cinder API")),
cfg.BoolOpt('api_rate_limit',
default=True,
help='whether to rate limit the api'),
from cinder.api.middleware import auth
from cinder.api.middleware import fault
-from cinder.api.openstack import volume
-from cinder.api.openstack.volume import limits
from cinder.api.openstack import wsgi as os_wsgi
from cinder.api import urlmap
+from cinder.api.v1 import limits
+from cinder.api.v1 import router
from cinder.api import versions
from cinder import context
from cinder import exception as exc
def wsgi_app(inner_app_v1=None, fake_auth=True, fake_auth_context=None,
use_no_auth=False, ext_mgr=None):
if not inner_app_v1:
- inner_app_v1 = volume.APIRouter(ext_mgr)
+ inner_app_v1 = router.APIRouter(ext_mgr)
if fake_auth:
if fake_auth_context is not None:
def app():
# no auth, just let environ['cinder.context'] pass through
- api = fakes.volume.APIRouter()
+ api = fakes.router.APIRouter()
mapper = fakes.urlmap.URLMap()
mapper['/v1'] = api
return mapper
def app():
# no auth, just let environ['cinder.context'] pass through
- api = fakes.volume.APIRouter()
+ api = fakes.router.APIRouter()
mapper = fakes.urlmap.URLMap()
mapper['/v1'] = api
return mapper
def app():
# no auth, just let environ['cinder.context'] pass through
- api = fakes.volume.APIRouter()
+ api = fakes.router.APIRouter()
mapper = fakes.urlmap.URLMap()
mapper['/v1'] = api
return mapper
from lxml import etree
import webob
-from cinder.api.openstack import volume
+from cinder.api.v1 import router
from cinder.api import xmlutil
from cinder import flags
from cinder.openstack.common import jsonutils
self.ext_list.sort()
def test_list_extensions_json(self):
- app = volume.APIRouter()
+ app = router.APIRouter()
request = webob.Request.blank("/fake/extensions")
response = request.get_response(app)
self.assertEqual(200, response.status_int)
self.assertEqual(output['extension']['alias'], ext['alias'])
def test_get_extension_json(self):
- app = volume.APIRouter()
+ app = router.APIRouter()
request = webob.Request.blank("/fake/extensions/FOXNSOX")
response = request.get_response(app)
self.assertEqual(200, response.status_int)
"links": []})
def test_get_non_existing_extension_json(self):
- app = volume.APIRouter()
+ app = router.APIRouter()
request = webob.Request.blank("/fake/extensions/4")
response = request.get_response(app)
self.assertEqual(404, response.status_int)
def test_list_extensions_xml(self):
- app = volume.APIRouter()
+ app = router.APIRouter()
request = webob.Request.blank("/fake/extensions")
request.accept = "application/xml"
response = request.get_response(app)
xmlutil.validate_schema(root, 'extensions')
def test_get_extension_xml(self):
- app = volume.APIRouter()
+ app = router.APIRouter()
request = webob.Request.blank("/fake/extensions/FOXNSOX")
request.accept = "application/xml"
response = request.get_response(app)
# under the License.
-from cinder.api.openstack import volume
-from cinder.api.openstack.volume import snapshots
-from cinder.api.openstack.volume import volumes
from cinder.api.openstack import wsgi
+from cinder.api.v1 import router
+from cinder.api.v1 import snapshots
+from cinder.api.v1 import volumes
from cinder.api import versions
from cinder import flags
from cinder.openstack.common import log as logging
# NOTE(vish): versions is just returning text so, no need to stub.
self.stubs.Set(snapshots, 'create_resource', create_resource)
self.stubs.Set(volumes, 'create_resource', create_resource)
- self.app = volume.APIRouter()
+ self.app = router.APIRouter()
def test_versions(self):
req = fakes.HTTPRequest.blank('')
from lxml import etree
import webob
-from cinder.api.openstack.volume import limits
+from cinder.api.v1 import limits
from cinder.api import views
from cinder.api import xmlutil
import cinder.context
from lxml import etree
import webob
-from cinder.api.openstack.volume import snapshots
+from cinder.api.v1 import snapshots
from cinder import db
from cinder import exception
from cinder import flags
from lxml import etree
import webob
-from cinder.api.openstack.volume import types
+from cinder.api.v1 import types
from cinder.api.views import types as views_types
from cinder import exception
from cinder.openstack.common import timeutils
from lxml import etree
import webob
-from cinder.api.openstack.volume import extensions
-from cinder.api.openstack.volume import volumes
+from cinder.api import extensions
+from cinder.api.v1 import volumes
from cinder import context
from cinder import db
from cinder import exception
#############
[composite:osapi_volume]
-use = call:cinder.api.urlmap:urlmap_factory
-/: osvolumeversions
+use = call:cinder.api:root_app_factory
+/: apiversions
/v1: openstack_volume_api_v1
[composite:openstack_volume_api_v1]
use = call:cinder.api.middleware.auth:pipeline_factory
-noauth = faultwrap sizelimit noauth osapi_volume_app_v1
-keystone = faultwrap sizelimit authtoken keystonecontext osapi_volume_app_v1
-keystone_nolimit = faultwrap sizelimit authtoken keystonecontext osapi_volume_app_v1
+noauth = faultwrap sizelimit noauth apiv1
+keystone = faultwrap sizelimit authtoken keystonecontext apiv1
+keystone_nolimit = faultwrap sizelimit authtoken keystonecontext apiv1
[filter:faultwrap]
paste.filter_factory = cinder.api.middleware.fault:FaultWrapper.factory
[filter:sizelimit]
paste.filter_factory = cinder.api.middleware.sizelimit:RequestBodySizeLimiter.factory
-[app:osapi_volume_app_v1]
-paste.app_factory = cinder.api.openstack.volume:APIRouter.factory
+[app:apiv1]
+paste.app_factory = cinder.api.v1.router:APIRouter.factory
-[pipeline:osvolumeversions]
+[pipeline:apiversions]
pipeline = faultwrap osvolumeversionapp
[app:osvolumeversionapp]