Merge "Set user_id when creating leases"

This commit is contained in:
Jenkins 2017-08-21 07:17:39 +00:00 committed by Gerrit Code Review
commit 7977c90152
2 changed files with 8 additions and 1 deletions

View File

@ -49,6 +49,11 @@ class API(object):
:param data: New lease characteristics. :param data: New lease characteristics.
:type data: dict :type data: dict
""" """
# TODO(priteau): If possible, extend the context object used in the
# manager to keep track of the trustor, instead of using the following
# two lines
ctx = context.current()
data['user_id'] = ctx.user_id
return self.manager_rpcapi.create_lease(data) return self.manager_rpcapi.create_lease(data)
@policy.authorize('leases', 'get') @policy.authorize('leases', 'get')

View File

@ -208,7 +208,9 @@ class ManagerService(service_utils.RPCServer):
'Start date must later than current date') 'Start date must later than current date')
with trusts.create_ctx_from_trust(trust_id) as ctx: with trusts.create_ctx_from_trust(trust_id) as ctx:
lease_values['user_id'] = ctx.user_id # NOTE(priteau): We should not get user_id from ctx, because we are
# in the context of the trustee (blazar user).
# lease_values['user_id'] is set in blazar/api/v1/service.py
lease_values['project_id'] = ctx.project_id lease_values['project_id'] = ctx.project_id
lease_values['start_date'] = start_date lease_values['start_date'] = start_date
lease_values['end_date'] = end_date lease_values['end_date'] = end_date