summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-08-05 11:58:21 -0400
committerAlex Meade <alex.meade@rackspace.com>2011-08-05 11:58:21 -0400
commit4acc4a9757af6e68456aba1fea2b320b2311b971 (patch)
tree4a11e2efc203145544e094e4f246271976ba0f3c /nova/api
parent9da88eac8fe728f506633f86ec6e75cf0212795b (diff)
Pass tenant ids through on on requests
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/__init__.py17
-rw-r--r--nova/api/openstack/wsgi.py3
2 files changed, 19 insertions, 1 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 9ab8aeb58..9475f961c 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -65,6 +65,15 @@ class FaultWrapper(base_wsgi.Middleware):
return faults.Fault(exc)
+class TenantMapper(routes.Mapper):
+
+ def resource(self, member_name, collection_name, **kwargs):
+ routes.Mapper.resource(self, member_name,
+ collection_name,
+ path_prefix='{tenant_id}/',
+ **kwargs)
+
+
class APIRouter(base_wsgi.Router):
"""
Routes requests on the OpenStack API to the appropriate controller
@@ -168,6 +177,12 @@ class APIRouterV10(APIRouter):
class APIRouterV11(APIRouter):
"""Define routes specific to OpenStack API V1.1."""
+ def __init__(self, ext_mgr=None):
+ mapper = TenantMapper()
+ self.server_members = {}
+ self._setup_routes(mapper)
+ super(APIRouter, self).__init__(mapper)
+
def _setup_routes(self, mapper):
super(APIRouterV11, self)._setup_routes(mapper, '1.1')
image_metadata_controller = image_metadata.create_resource()
@@ -176,7 +191,7 @@ class APIRouterV11(APIRouter):
parent_resource=dict(member_name='image',
collection_name='images'))
- mapper.connect("metadata", "/images/{image_id}/metadata",
+ mapper.connect("metadata", "{tenant_id}/images/{image_id}/metadata",
controller=image_metadata_controller,
action='update_all',
conditions={"method": ['PUT']})
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 0eb47044e..7c22ed57a 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -486,6 +486,9 @@ class Resource(wsgi.Application):
msg = _("Malformed request body")
return faults.Fault(webob.exc.HTTPBadRequest(explanation=msg))
+ #Remove tenant id
+ args.pop("tenant_id")
+
try:
action_result = self.dispatch(request, action, args)
except webob.exc.HTTPException as ex: