Use new oslo.context arg names

Various RequestContext values have been renamed and the old names
deprecated. This results in a large amount of DeprecationWarning
messages in the logs.

This updates glance.context.RequestContext to use the new names.

Change-Id: Id34637542051cfdc532eebdfbf95edd8a58467da
This commit is contained in:
Sean McGinnis 2017-11-22 11:41:37 -06:00
parent d88bd2ca8e
commit a919fa1ed7
2 changed files with 15 additions and 15 deletions

View File

@ -45,8 +45,8 @@ class RequestContext(context.RequestContext):
def to_policy_values(self):
pdict = super(RequestContext, self).to_policy_values()
pdict['user'] = self.user
pdict['tenant'] = self.tenant
pdict['user'] = self.user_id
pdict['tenant'] = self.project_id
return pdict
@classmethod
@ -56,7 +56,7 @@ class RequestContext(context.RequestContext):
@property
def owner(self):
"""Return the owner to correlate with an image."""
return self.tenant if self.owner_is_tenant else self.user
return self.project_id if self.owner_is_tenant else self.user_id
@property
def can_see_deleted(self):
@ -67,7 +67,7 @@ class RequestContext(context.RequestContext):
def get_admin_context(show_deleted=False):
"""Create an administrator context."""
return RequestContext(auth_token=None,
tenant=None,
project_id=None,
is_admin=True,
show_deleted=show_deleted,
overwrite=False)

View File

@ -113,7 +113,7 @@ class TestContext(utils.BaseTestCase):
Tests that an authenticated context (with is_admin set to
False) can access an image with is_public set to True.
"""
self.do_visible(True, None, True, tenant='froggy')
self.do_visible(True, None, True, project_id='froggy')
def test_auth_public_unowned(self):
"""
@ -121,7 +121,7 @@ class TestContext(utils.BaseTestCase):
False) can access an image (which it does not own) with
is_public set to True.
"""
self.do_visible(True, 'pattieblack', True, tenant='froggy')
self.do_visible(True, 'pattieblack', True, project_id='froggy')
def test_auth_public_owned(self):
"""
@ -129,14 +129,14 @@ class TestContext(utils.BaseTestCase):
False) can access an image (which it does own) with is_public
set to True.
"""
self.do_visible(True, 'pattieblack', True, tenant='pattieblack')
self.do_visible(True, 'pattieblack', True, project_id='pattieblack')
def test_auth_private(self):
"""
Tests that an authenticated context (with is_admin set to
False) can access an image with is_public set to False.
"""
self.do_visible(True, None, False, tenant='froggy')
self.do_visible(True, None, False, project_id='froggy')
def test_auth_private_unowned(self):
"""
@ -144,7 +144,7 @@ class TestContext(utils.BaseTestCase):
False) cannot access an image (which it does not own) with
is_public set to False.
"""
self.do_visible(False, 'pattieblack', False, tenant='froggy')
self.do_visible(False, 'pattieblack', False, project_id='froggy')
def test_auth_private_owned(self):
"""
@ -152,7 +152,7 @@ class TestContext(utils.BaseTestCase):
False) can access an image (which it does own) with is_public
set to False.
"""
self.do_visible(True, 'pattieblack', False, tenant='pattieblack')
self.do_visible(True, 'pattieblack', False, project_id='pattieblack')
def test_request_id(self):
contexts = [context.RequestContext().request_id for _ in range(5)]
@ -164,10 +164,10 @@ class TestContext(utils.BaseTestCase):
self.assertEqual(['foo'], ctx.service_catalog)
def test_user_identity(self):
ctx = context.RequestContext(user="user",
tenant="tenant",
domain="domain",
user_domain="user-domain",
project_domain="project-domain")
ctx = context.RequestContext(user_id="user",
project_id="tenant",
domain_id="domain",
user_domain_id="user-domain",
project_domain_id="project-domain")
self.assertEqual('user tenant domain user-domain project-domain',
ctx.to_dict()["user_identity"])