From 956e7b78f7e1aaa51284794c7e1a509e868904fd Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 24 Feb 2016 09:41:58 -0800 Subject: Tolerate roles in context.RequestContext In Ia575ba803a0fb70f39146bd75d381ed19414bd23, oslo.context added roles support in the context itself. Once that change is released in oslo.context and the global requirements has been updated, we should switch to passing in the roles in the __init__ parameter. Until then we should set self.roles *after* the constructor since the constructor sets the roles to None when the new library gets released. Closes-Bug: 1549317 Change-Id: Ie28a4144ccac5d6894405ba7f801617376e35c51 (cherry picked from commit b0ae5e9f2dc078af8e80a284c8692b79e98e0ed2) --- ironic/common/context.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ironic/common/context.py b/ironic/common/context.py index aaeffb333..ccd2222ea 100644 --- a/ironic/common/context.py +++ b/ironic/common/context.py @@ -33,18 +33,20 @@ class RequestContext(context.RequestContext): before sending back to API call. """ - self.is_public_api = is_public_api - self.domain_id = domain_id - self.domain_name = domain_name - self.roles = roles or [] - self.show_password = show_password - super(RequestContext, self).__init__(auth_token=auth_token, user=user, tenant=tenant, is_admin=is_admin, read_only=read_only, show_deleted=show_deleted, request_id=request_id) + self.is_public_api = is_public_api + self.domain_id = domain_id + self.domain_name = domain_name + self.show_password = show_password + # NOTE(dims): roles was added in context.RequestContext recently. + # we should pass roles in __init__ above instead of setting the + # value here once the minimum version of oslo.context is updated. + self.roles = roles or [] def to_dict(self): return {'auth_token': self.auth_token, -- cgit v1.2.1