Define context.roles with base class

In f383bd2973c58c5272504603e4f9dddd55c5bb68, oslo.context (2.2.0)
added roles support in the context itself. This passes roles to
super()__init__.

Cleanup of to_dict() to construct initially with base class.

Change-Id: I688eed81bfeddd9455121ac0ce1b6903bf8d5e87
This commit is contained in:
Ronald Bradford 2016-04-06 12:14:30 -04:00
parent 5798a372be
commit 590ccac630

View File

@ -60,14 +60,14 @@ class Context(context.RequestContext):
tenant=tenant_id, tenant=tenant_id,
is_admin=is_admin, is_admin=is_admin,
resource_uuid=resource_uuid, resource_uuid=resource_uuid,
request_id=request_id) request_id=request_id,
roles=roles)
self.service_catalog = service_catalog self.service_catalog = service_catalog
self.username = username self.username = username
self.tenant_name = tenant_name self.tenant_name = tenant_name
self.remote_semaphore = remote_semaphore or semaphore.Semaphore( self.remote_semaphore = remote_semaphore or semaphore.Semaphore(
CONF.cluster_remote_threshold) CONF.cluster_remote_threshold)
self.auth_plugin = auth_plugin self.auth_plugin = auth_plugin
self.roles = roles
if overwrite or not hasattr(context._request_store, 'context'): if overwrite or not hasattr(context._request_store, 'context'):
self.update_store() self.update_store()
@ -94,20 +94,16 @@ class Context(context.RequestContext):
overwrite=False) overwrite=False)
def to_dict(self): def to_dict(self):
return { d = super(Context, self).to_dict()
d.update({
'user_id': self.user_id, 'user_id': self.user_id,
'tenant_id': self.tenant_id, 'tenant_id': self.tenant_id,
'auth_token': self.auth_token,
'service_catalog': self.service_catalog, 'service_catalog': self.service_catalog,
'username': self.username, 'username': self.username,
'tenant_name': self.tenant_name, 'tenant_name': self.tenant_name,
'user_name': self.username, 'user_name': self.username,
'project_name': self.tenant_name, 'project_name': self.tenant_name})
'is_admin': self.is_admin, return d
'roles': self.roles,
'resource_uuid': self.resource_uuid,
'request_id': self.request_id,
}
def is_auth_capable(self): def is_auth_capable(self):
return (self.service_catalog and self.auth_token and self.tenant and return (self.service_catalog and self.auth_token and self.tenant and