diff --git a/manila/context.py b/manila/context.py index 1cb82d82e8..f6b5be8dcf 100644 --- a/manila/context.py +++ b/manila/context.py @@ -54,12 +54,14 @@ class RequestContext(object): :param kwargs: Extra arguments that might be present, but we ignore because they possibly came in from older rpc messages. """ + user = kwargs.pop('user', None) + tenant = kwargs.pop('tenant', None) if kwargs: LOG.warn(_LW('Arguments dropped when creating context: %s'), str(kwargs)) - self.user_id = user_id - self.project_id = project_id + self.user_id = user_id or user + self.project_id = project_id or tenant self.roles = roles or [] self.is_admin = is_admin if self.is_admin is None: diff --git a/manila/tests/test_context.py b/manila/tests/test_context.py index 444b0c89be..843fcfdf80 100644 --- a/manila/tests/test_context.py +++ b/manila/tests/test_context.py @@ -74,7 +74,12 @@ class ContextTestCase(test.TestCase): c = context.RequestContext('user', 'project', extra_arg1='meow', - extra_arg2='wuff') + extra_arg2='wuff', + user='user', + tenant='project') self.assertTrue(c) self.assertIn("'extra_arg1': 'meow'", info['log_msg']) self.assertIn("'extra_arg2': 'wuff'", info['log_msg']) + # user and tenant kwargs get popped off before we log anything + self.assertNotIn("'user': 'user'", info['log_msg']) + self.assertNotIn("'tenant': 'project'", info['log_msg'])