Merge "Use the from_environ features of oslo_context"
This commit is contained in:
commit
5f1942259b
@ -20,12 +20,5 @@ from octavia.common import context
|
||||
class ContextHook(hooks.PecanHook):
|
||||
|
||||
def on_route(self, state):
|
||||
user_id = state.request.headers.get('X-User-Id')
|
||||
user_id = state.request.headers.get('X-User', user_id)
|
||||
project = state.request.headers.get('X-Tenant-Id')
|
||||
project = state.request.headers.get('X-Tenant', project)
|
||||
project = state.request.headers.get('X-Project-Id', project)
|
||||
project = state.request.headers.get('X-Project', project)
|
||||
auth_token = state.request.headers.get('X-Auth-Token')
|
||||
state.request.context['octavia_context'] = context.Context(
|
||||
user_id=user_id, project_id=project, auth_token=auth_token)
|
||||
context_obj = context.Context.from_environ(state.request.environ)
|
||||
state.request.context['octavia_context'] = context_obj
|
||||
|
@ -18,14 +18,15 @@ from octavia.db import api as db_api
|
||||
|
||||
|
||||
class Context(common_context.RequestContext):
|
||||
def __init__(self, user_id, project_id, is_admin=False, auth_token=None):
|
||||
super(Context, self).__init__(tenant=project_id, auth_token=auth_token,
|
||||
is_admin=is_admin, user=user_id)
|
||||
self._session = None
|
||||
self.project_id = project_id
|
||||
|
||||
_session = None
|
||||
|
||||
@property
|
||||
def session(self):
|
||||
if self._session is None:
|
||||
self._session = db_api.get_session()
|
||||
return self._session
|
||||
|
||||
@property
|
||||
def project_id(self):
|
||||
return self.tenant
|
||||
|
Loading…
x
Reference in New Issue
Block a user