summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorWilliam Wolf <throughnothing@gmail.com>2011-08-11 14:40:05 -0400
committerWilliam Wolf <throughnothing@gmail.com>2011-08-11 14:40:05 -0400
commit01c7da9e861fee3201e2bc5dcc289024aa5ced61 (patch)
treeaaf0a465407cd03a76b2ad8600b9023820e0ea09 /nova/api
parent76e9bbde798012628a27b8330706a77467ee2d2a (diff)
downloadnova-01c7da9e861fee3201e2bc5dcc289024aa5ced61.tar.gz
nova-01c7da9e861fee3201e2bc5dcc289024aa5ced61.tar.xz
nova-01c7da9e861fee3201e2bc5dcc289024aa5ced61.zip
got rid of tenant_id everywhere, got rid of X-Auth-Project-Id header support (not in the spec), and updated tests
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/__init__.py4
-rw-r--r--nova/api/openstack/auth.py10
-rw-r--r--nova/api/openstack/extensions.py2
-rw-r--r--nova/api/openstack/wsgi.py5
4 files changed, 13 insertions, 8 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index de2aee96a..8805c4ef6 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -68,7 +68,7 @@ class FaultWrapper(base_wsgi.Middleware):
return faults.Fault(exc)
-class TenantMapper(routes.Mapper):
+class ProjectMapper(routes.Mapper):
def resource(self, member_name, collection_name, **kwargs):
if not ('parent_resource' in kwargs):
@@ -191,7 +191,7 @@ class APIRouterV11(APIRouter):
"""Define routes specific to OpenStack API V1.1."""
def __init__(self, ext_mgr=None):
- mapper = TenantMapper()
+ mapper = ProjectMapper()
self.server_members = {}
self._setup_routes(mapper)
super(APIRouter, self).__init__(mapper)
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index d42abe1f8..164a60cbc 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -55,9 +55,13 @@ class AuthMiddleware(wsgi.Middleware):
LOG.warn(msg % locals())
return faults.Fault(webob.exc.HTTPUnauthorized())
- try:
- project_id = req.headers["X-Auth-Project-Id"]
- except KeyError:
+ project_id = ""
+ path_parts = req.path.split('/')
+ # TODO(wwolf): this v1.1 check will be temporary as
+ # keystone should be taking this over at some point
+ if len(path_parts) > 1 and path_parts[1] == 'v1.1':
+ project_id = path_parts[2]
+ elif len(path_parts) > 1 and path_parts[1] == 'v1.0':
# FIXME(usrleon): It needed only for compatibility
# while osapi clients don't use this header
projects = self.auth.get_projects(user_id)
diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py
index 86ffb91c6..9c4d32eb4 100644
--- a/nova/api/openstack/extensions.py
+++ b/nova/api/openstack/extensions.py
@@ -260,7 +260,7 @@ class ExtensionMiddleware(base_wsgi.Middleware):
ext_mgr = ExtensionManager(FLAGS.osapi_extensions_path)
self.ext_mgr = ext_mgr
- mapper = nova.api.openstack.TenantMapper()
+ mapper = nova.api.openstack.ProjectMapper()
serializer = wsgi.ResponseSerializer(
{'application/xml': ExtensionsXMLSerializer()})
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 82fef6df8..dc0f1b93e 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -486,8 +486,9 @@ class Resource(wsgi.Application):
msg = _("Malformed request body")
return faults.Fault(webob.exc.HTTPBadRequest(explanation=msg))
- if "project_id" in args:
- project_id = args.pop("project_id")
+ project_id = args.pop("project_id", None)
+ if 'nova.context' in request.environ and project_id:
+ request.environ['nova.context'].project_id = project_id
try:
action_result = self.dispatch(request, action, args)