Remove unneeded attributes from context
In the last few cycles oslo.context has picked up a standard way of representing most of the information available from a token context. There's no more need for nova to manage these properties. Remove properties that shadow the base oslo.context properties and helpers that we don't need. Change-Id: I1b11e405232b1acee053cb3bd30c18202d3b7c8f
This commit is contained in:
parent
6119f6ff51
commit
5ec88acbe2
@ -88,9 +88,8 @@ class RequestContext(context.RequestContext):
|
||||
|
||||
def __init__(self, user_id=None, project_id=None, is_admin=None,
|
||||
read_deleted="no", remote_address=None, timestamp=None,
|
||||
quota_class=None, user_name=None, project_name=None,
|
||||
service_catalog=None, instance_lock_checked=False,
|
||||
user_auth_plugin=None, **kwargs):
|
||||
quota_class=None, service_catalog=None,
|
||||
instance_lock_checked=False, user_auth_plugin=None, **kwargs):
|
||||
""":param read_deleted: 'no' indicates deleted records are hidden,
|
||||
'yes' indicates deleted records are visible,
|
||||
'only' indicates that *only* deleted records are visible.
|
||||
@ -131,8 +130,6 @@ class RequestContext(context.RequestContext):
|
||||
# rs_limits turnstile pre-processor.
|
||||
# See https://lists.launchpad.net/openstack/msg12200.html
|
||||
self.quota_class = quota_class
|
||||
self.user_name = user_name
|
||||
self.project_name = project_name
|
||||
|
||||
# NOTE(dheeraj): The following attributes are used by cellsv2 to store
|
||||
# connection information for connecting to the target cell.
|
||||
@ -166,25 +163,6 @@ class RequestContext(context.RequestContext):
|
||||
read_deleted = property(_get_read_deleted, _set_read_deleted,
|
||||
_del_read_deleted)
|
||||
|
||||
# FIXME(dims): user_id and project_id duplicate information that is
|
||||
# already present in the oslo_context's RequestContext. We need to
|
||||
# get rid of them.
|
||||
@property
|
||||
def project_id(self):
|
||||
return self.tenant
|
||||
|
||||
@project_id.setter
|
||||
def project_id(self, value):
|
||||
self.tenant = value
|
||||
|
||||
@property
|
||||
def user_id(self):
|
||||
return self.user
|
||||
|
||||
@user_id.setter
|
||||
def user_id(self, value):
|
||||
self.user = value
|
||||
|
||||
def to_dict(self):
|
||||
values = super(RequestContext, self).to_dict()
|
||||
# FIXME(dims): defensive hasattr() checks need to be
|
||||
@ -232,19 +210,6 @@ class RequestContext(context.RequestContext):
|
||||
instance_lock_checked=values.get('instance_lock_checked', False),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_environ(cls, environ, **kwargs):
|
||||
ctx = super(RequestContext, cls).from_environ(environ, **kwargs)
|
||||
|
||||
# the base oslo.context sets its user param and tenant param but not
|
||||
# our user_id and project_id param so fix those up.
|
||||
if ctx.user and not ctx.user_id:
|
||||
ctx.user_id = ctx.user
|
||||
if ctx.tenant and not ctx.project_id:
|
||||
ctx.project_id = ctx.tenant
|
||||
|
||||
return ctx
|
||||
|
||||
def elevated(self, read_deleted=None):
|
||||
"""Return a version of this context with admin flag set."""
|
||||
context = copy.copy(self)
|
||||
|
@ -96,8 +96,8 @@ def _endpoint_from_image_ref(image_href):
|
||||
def generate_identity_headers(context, status='Confirmed'):
|
||||
return {
|
||||
'X-Auth-Token': getattr(context, 'auth_token', None),
|
||||
'X-User-Id': getattr(context, 'user', None),
|
||||
'X-Tenant-Id': getattr(context, 'tenant', None),
|
||||
'X-User-Id': getattr(context, 'user_id', None),
|
||||
'X-Tenant-Id': getattr(context, 'project_id', None),
|
||||
'X-Roles': ','.join(getattr(context, 'roles', [])),
|
||||
'X-Identity-Status': status,
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class TestNeutronDriver(test.NoDBTestCase):
|
||||
'list_security_groups',
|
||||
return_value=security_groups_list) as mock_list_secgroup:
|
||||
sg_api = neutron_driver.SecurityGroupAPI()
|
||||
sg_api.list(self.context, project=self.context.tenant,
|
||||
sg_api.list(self.context, project=self.context.project_id,
|
||||
search_opts=search_opts)
|
||||
|
||||
mock_list_secgroup.assert_called_once_with(
|
||||
@ -144,7 +144,7 @@ class TestNeutronDriver(test.NoDBTestCase):
|
||||
expected_sg_id = '85cc3048-abc3-43cc-89b3-377341426ac5'
|
||||
expected_sg = {'security_group': {'name': sg_name,
|
||||
'id': expected_sg_id,
|
||||
'tenant_id': self.context.tenant,
|
||||
'tenant_id': self.context.project_id,
|
||||
'description': 'server', 'rules': []}}
|
||||
self.mocked_client.show_security_group.return_value = expected_sg
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user