From 5ec88acbe25e315c9b16a8bd9c064b92e16751c6 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Tue, 29 Aug 2017 08:48:33 +1000 Subject: 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 --- nova/context.py | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) (limited to 'nova/context.py') diff --git a/nova/context.py b/nova/context.py index b47b63f985..03cb953790 100644 --- a/nova/context.py +++ b/nova/context.py @@ -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) -- cgit v1.2.1